Last active
June 2, 2022 13:11
-
-
Save ybiquitous/54586327550d57a4ad435da635d080a8 to your computer and use it in GitHub Desktop.
Dynamic Ruby versions matrix on GitHub Actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: push | |
jobs: | |
ruby-versions: | |
runs-on: ubuntu-latest | |
outputs: | |
versions: ${{ steps.versions.outputs.value }} | |
steps: | |
- id: versions | |
name: Fetch Ruby versions | |
run: | | |
versions="$(curl -s 'https://cache.ruby-lang.org/pub/misc/ci_versions/cruby.json' | jq -c)" | |
echo "Fetched Ruby versions: ${versions}" | |
echo "::set-output name=value::${versions}" | |
test: | |
name: Test on Ruby ${{ matrix.ruby }} | |
needs: ruby-versions | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ matrix.ruby }} | |
bundler-cache: true | |
- run: bundle exec rake |
An example to add outdated versions to the matrix:
versions=$(curl -s 'https://cache.ruby-lang.org/pub/misc/ci_versions/all.json' | jq -c '. |= . + ["2.6", "2.5", "2.4"]')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://cache.ruby-lang.org/pub/misc/ci_versions/ for other versions (e.g. jruby)