Skip to content

Commit

Permalink
Update CI build matrix to me more automatic
Browse files Browse the repository at this point in the history
Rails 8 changed sqlite3 version requirements and made the matrix harder to do by hand.
  • Loading branch information
danielmorrison committed Jan 11, 2025
1 parent 82c1ad0 commit 8732450
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
35 changes: 28 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,48 @@ on:
pull_request:

jobs:
versions:
name: Get latest versions
runs-on: ubuntu-latest
strategy:
matrix:
product: ["ruby", "rails"]
outputs:
ruby: ${{ steps.supported.outputs.ruby }}
rails: ${{ steps.supported.outputs.rails }}
steps:
- id: supported
run: |
product="${{ matrix.product }}"
data=$(curl https://endoflife.date/api/$product.json)
supported=$(echo $data | jq '[.[] | select(.eol > (now | strftime("%Y-%m-%d")))]')
echo "${product}=$(echo $supported | jq -c 'map(.latest)')" >> $GITHUB_OUTPUT
build:
needs: versions
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
name: Test on Ruby ${{ matrix.ruby }} and Rails ${{ matrix.rails }}
strategy:
fail-fast: false
matrix:
ruby:
- 2.7
- '3.0' # keep as string or it turns into "3" which pulls the newest 3.x, not 3.0.x
- 3.1
- 3.2
- 3.3
ruby: ${{ fromJSON(needs.versions.outputs.ruby) }}
rails: ${{ fromJSON(needs.versions.outputs.rails) }}

env:
RAILS_VERSION: ${{ matrix.rails }}
RUBYOPT: --enable=frozen-string-literal

steps:
- uses: actions/checkout@v3
- name: Set up Ruby
id: setup-ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
continue-on-error: true
- name: Incompatible Versions
if: steps.setup-ruby.outcome == 'failure'
run: echo "Ruby ${{ matrix.ruby }} is not supported with Rails ${{ matrix.rails }}"
- name: Run the default task
if: steps.setup-ruby.outcome != 'failure'
run: bundle exec rake
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ gemspec

gem "rake"

gem "rails", "~> #{ENV["RAILS_VERSION"] || "8.0"}"

gem "debug"
gem "rspec-rails"
gem "standard", ">= 1.35.1"
Expand Down

0 comments on commit 8732450

Please sign in to comment.