From a4abe39c8ec39db7ce0612247575a7e4cf2f0f93 Mon Sep 17 00:00:00 2001 From: Rafael Petersen Date: Thu, 9 Mar 2023 14:51:20 +0100 Subject: [PATCH] ci: [DX-32] Add github actions for spec, release and rubocop (#11) * [DX-32] Add github actions for spec, release and rubocop * [DX-32] Fix 18n references --- .github/workflows/release.yml | 34 ++++++++++++++++++++++++++++++++++ .github/workflows/rubocop.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/specs.yml | 20 ++++++++++++++++++++ Gemfile.lock | 1 + 4 files changed, 83 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/rubocop.yml create mode 100644 .github/workflows/specs.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ec70eb3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Create release pull request +on: + push: + branches: + - 'master' +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: GoogleCloudPlatform/release-please-action@v3 + id: release + with: + release-type: ruby + package-name: factiva-api-client + bump-minor-pre-major: true + version-file: 'lib/factiva/version.rb' + - uses: actions/checkout@v2 + if: ${{ steps.release.outputs.release_created }} + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.1' + if: ${{ steps.release.outputs.release_created }} + - name: Publish gem to Github repostiory packages + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials + gem build *.gemspec + gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem + env: + GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}" + OWNER: ${{ github.repository_owner }} + if: ${{ steps.release.outputs.release_created }} \ No newline at end of file diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 0000000..7141399 --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,28 @@ +name: Run gem static analysis +on: + pull_request: + types: [opened, synchronize] + +jobs: + rubocop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - run: | + git fetch --no-tags --prune origin + - name: Set up Ruby 3.1 + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.1' + bundler-cache: true + cache-version: 1 + - name: rubocop + uses: reviewdog/action-rubocop@v2 + with: + use_bundler: true + reporter: github-pr-review + filter_mode: file + fail_on_error: true + \ No newline at end of file diff --git a/.github/workflows/specs.yml b/.github/workflows/specs.yml new file mode 100644 index 0000000..8934fad --- /dev/null +++ b/.github/workflows/specs.yml @@ -0,0 +1,20 @@ +name: Run url_shortener-client gem specs +on: + push: + branches: + - "**" # matches every branch + - '!master' # excludes master +jobs: + run-specs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + bundler-cache: true + cache-version: 1 + - name: Run tests + run: | + bundle exec rspec diff --git a/Gemfile.lock b/Gemfile.lock index e910d8e..bb5e560 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -121,6 +121,7 @@ GEM PLATFORMS ruby + x86_64-linux DEPENDENCIES factiva-api-client!