From cf17762f7be3a5f7d8b73ec7eaf46a98ded223f9 Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Sat, 11 May 2024 11:50:26 -0400 Subject: [PATCH 1/4] Configure bundler cache in setup-ruby action The ruby/setup-ruby GitHub Action [1] supports a `bundler-cache` config that, "runs 'bundle install' and caches installed gems automatically." Using this configuration simplifies later job steps and speeds up subsequent workflow runs. [1] https://github.com/ruby/setup-ruby --- .github/workflows/ruby.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 716d0be..2fd35d1 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -12,14 +12,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 + - uses: ruby/setup-ruby@v1 with: + bundler-cache: true ruby-version: ${{ matrix.ruby_version }} - - name: Build and test with Rake run: | - gem install bundler - bundle install --jobs 4 --retry 3 bundle exec rspec bundle exec rubocop From 09411b49cc220411b02618d84de09e79715d58d2 Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Sat, 11 May 2024 11:54:46 -0400 Subject: [PATCH 2/4] Configure `workflow_dispatch` event Allows for manual running of a workflow. Occasionally handy. https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow --- .github/workflows/ruby.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 2fd35d1..6aedcb0 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -1,6 +1,9 @@ name: Ruby -on: [push, pull_request] +on: + pull_request: + push: + workflow_dispatch: jobs: build: From 59f6f581994c20c4950d7c5453366155da9c5010 Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Sat, 11 May 2024 14:39:35 -0400 Subject: [PATCH 3/4] Split lint and test jobs This commit breaks out linting and testing into two separate, parallel jobs. Since the RuboCop config specifies the target Ruby version (3.1), there _shouldn't_ be a need to run the tool in each tested Ruby. In this configuration, the linting job will run and report any errors in parallel with the test job(s) defined in the matrix. The previous addition that caches dependencies in the Ruby setup step should make all of this run pretty quick. --- .github/workflows/ruby.yml | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 6aedcb0..2e8d7d2 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -6,20 +6,24 @@ on: workflow_dispatch: jobs: - build: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: "3.3" + - run: bundle exec rubocop + test: + runs-on: ubuntu-latest strategy: matrix: - ruby_version: [3.3, 3.2, 3.1] - - runs-on: ubuntu-latest - + ruby: [3.3, 3.2, 3.1] steps: - - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - ruby-version: ${{ matrix.ruby_version }} - - name: Build and test with Rake - run: | - bundle exec rspec - bundle exec rubocop + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: ${{ matrix.ruby }} + - run: bundle exec rspec From 160e2a89720d8a0697c492ffec2bb77b396cc9e4 Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Sat, 11 May 2024 16:08:42 -0400 Subject: [PATCH 4/4] Don't fail fast This setting allows all jobs in the matrix to continue to completion whether or not any of them fail along the way. This is most useful in cases where, say, Ruby 3.3 fails on an actual error but we'd want to know whether or not the same error appears in Ruby 3.2 and 3.1. Absent this configuration, if the Ruby 3.3 error was encountered first, all jobs would be cancelled without reporting success or failure of the test suite. --- .github/workflows/ruby.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 2e8d7d2..457372b 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -18,6 +18,7 @@ jobs: test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: ruby: [3.3, 3.2, 3.1] steps: