From 87324500d40b1c8b39548ac56cfa376baca20e32 Mon Sep 17 00:00:00 2001 From: Daniel Morrison Date: Fri, 10 Jan 2025 10:26:07 -0500 Subject: [PATCH] Update CI build matrix to me more automatic Rails 8 changed sqlite3 version requirements and made the matrix harder to do by hand. --- .github/workflows/ci.yml | 35 ++++++++++++++++++++++++++++------- Gemfile | 2 ++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3fcd91..2a7c73c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Gemfile b/Gemfile index b75a2c3..3580d8e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,8 @@ gemspec gem "rake" +gem "rails", "~> #{ENV["RAILS_VERSION"] || "8.0"}" + gem "debug" gem "rspec-rails" gem "standard", ">= 1.35.1"