Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI build matrix to be more automatic #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading