Skip to content
Merged
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
108 changes: 97 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test this action
name: CI
on:
pull_request:
push:
Expand Down Expand Up @@ -95,6 +95,12 @@ jobs:
- run: gem env
- name: C extension test
run: gem install json -v 2.2.0
- name: C extension test with vcpkg libraries (mswin)
run: gem install fiddle:1.1.8 zlib:3.2.4
if: matrix.ruby == 'mswin'
- name: Load C extensions linked to vcpkg libraries (mswin)
run: ruby -rfiddle -e 'gem %q(zlib), %q(3.2.4); require %q(zlib); p Zlib.crc32(%q(a))'
if: matrix.ruby == 'mswin'
- run: bundle --version
# This step is redundant with `bundler-cache: true` but is there to check a redundant `bundle install` still works
- run: bundle install
Expand Down Expand Up @@ -155,9 +161,9 @@ jobs:
egress-policy: audit

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- run: echo "ruby-3.4.0" > .ruby-version
- run: echo "ruby-3.4.12" > .ruby-version
- uses: ./
- run: ruby -v | grep -F "ruby 3.4.0"
- run: ruby -v | grep -F "ruby 3.4.12"

testToolVersions:
name: "Test .tool-versions"
Expand All @@ -169,9 +175,9 @@ jobs:
egress-policy: audit

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- run: echo -e "nodejs 16.0.0\nruby 3.4.0" > .tool-versions
- run: echo -e "nodejs 16.0.0\nruby 3.4.12" > .tool-versions
- uses: ./
- run: ruby -v | grep -F "ruby 3.4.0"
- run: ruby -v | grep -F "ruby 3.4.12"

testMise:
name: "Test mise.toml"
Expand All @@ -183,9 +189,9 @@ jobs:
egress-policy: audit

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- run: echo -e "[tools]\nnode = '18'\nruby = '3.4.0'" > mise.toml
- run: echo -e "[tools]\nnode = '18'\nruby = '3.4.12'" > mise.toml
- uses: ./
- run: ruby -v | grep -F "ruby 3.4.0"
- run: ruby -v | grep -F "ruby 3.4.12"

testNoGemfile:
name: "Test with no Gemfile"
Expand Down Expand Up @@ -233,7 +239,6 @@ jobs:
- { ruby: '2.6', expected_rubygems_version: '3.4.22' }
- { ruby: '2.5', expected_rubygems_version: '3.3.27' }
- { ruby: '2.3', expected_rubygems_version: '3.3.27' }
- { ruby: '2.0', expected_rubygems_version: '2.7.11' }
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@v2
Expand Down Expand Up @@ -275,9 +280,31 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ./
with:
ruby-version: '3.1.0'
ruby-version: '3.1.7'
rubygems: 3.2.3
- run: gem --version | grep -F "3.3.3"
- run: gem --version | grep -F "3.3.27"

testFixedRubygemsBetaVersionUpgrades:
name: "Test rubygems: beta version upgrades RubyGems to that version if the default is older"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
Comment thread
anurag-stepsecurity marked this conversation as resolved.
Resolved
- uses: ./
with:
ruby-version: '4.0.7'
rubygems: 4.1.0.beta2
- run: gem --version | grep -F "4.1.0.beta2"

testFixedRubygemsBetaVersionNoop:
name: "Test rubygems: beta version noops if the default is newer"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
Comment thread
anurag-stepsecurity marked this conversation as resolved.
Resolved
- uses: ./
with:
ruby-version: '4.0.7'
rubygems: 4.0.0.beta2
- run: gem --version | grep -F "4.0.20"

testUseBundlerFromRubyGemsUpdate:
name: "Test rubygems: version uses the Bundler installed by the rubygems update"
Expand All @@ -291,7 +318,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ./
with:
ruby-version: '3.1.0'
ruby-version: '3.1.7'
rubygems: 3.4.0
- run: gem --version | grep -F "3.4.0"
- run: bundle --version | grep -F "2.4.0"
Expand Down Expand Up @@ -429,6 +456,31 @@ jobs:
bundler-cache: true
- run: bundle --version | grep -F "Bundler version 1."

testTwiceInSameJob:
name: "Test using setup-ruby twice in the same job"
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
Comment thread
anurag-stepsecurity marked this conversation as resolved.
Resolved
- uses: ./
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/bundler1.gemfile
with:
ruby-version: '2.7'
bundler: 1
bundler-cache: true
- run: ruby --version | grep -F "ruby 2.7."
- run: bundle --version | grep -F "Bundler version 1."
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/bundler1.gemfile
# The Ruby and Bundler versions used by the first setup-ruby step must not leak into the second one
- uses: ./
with:
ruby-version: '3.4'
bundler-cache: true
- run: ruby --version | grep -F "ruby 3.4."
- run: bundle --version | grep -P "Bundler version 2\.6\.\d+"
- run: bundle exec rake --version

testGemfileMatrix:
strategy:
fail-fast: false
Expand Down Expand Up @@ -501,3 +553,37 @@ jobs:
- run: yarn run package
Comment thread
anurag-stepsecurity marked this conversation as resolved.
Resolved
- name: Check generated files are up to date
run: git diff --exit-code

result:
if: ${{ always() }}
name: Result
runs-on: ubuntu-latest
needs:
- test-matrix
- test
- testDotRubyVersion
- testToolVersions
- testMise
- testNoGemfile
- testNoGemfileWithBundlerCache
- testLatestRubygemsVersion
- testFixedRubygemsVersionUpgrades
- testFixedRubygemsVersionNoop
- testFixedRubygemsBetaVersionUpgrades
- testFixedRubygemsBetaVersionNoop
- testUseBundlerFromRubyGemsUpdate
- testFixedBundlerVersionForOldRuby
- testMajorBundlerVersion
- testMinorBundlerVersion
- testExactBundlerVersion
- testOlderBundlerVersion
- testBundlerPre
- testBundlerDev
- testDependencyOnBundler1
- testGemfileMatrix
- testWindowsToolchain
- validate-windows-versions
- check-dist-index
steps:
- run: exit 1
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ typings/

# next.js build output
.next
.idea
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,20 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
| Interpreter | Versions |
| ----------- | -------- |
| `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 4.1.0-preview1, head, debug, mingw, mswin, ucrt |
| `jruby` | 9.1.17.0 - 10.1.2.0, head |
| `jruby` | 9.1.17.0 - 10.1.3.0, head |
| `truffleruby` | 19.3.0 - 40.0.0, head |
| `truffleruby+graalvm` | 21.2.0 - 40.0.0, head |

`ruby-debug` is the same as `ruby-head` but with assertions enabled (`-DRUBY_DEBUG=1`).

`ruby-asan` is the same as `ruby-head` but with AddressSanitizer (ASan) enabled, helpful for finding memory issues in native extensions.
Native extensions are automatically compiled with AddressSanitizer when using `ruby-asan`.
`ruby-asan` is currently only available on `ubuntu-24.04`.

`asan-release` is similar to `ruby-asan` but built from the latest stable release tag.
Like `ruby-asan`, it's currently only available on `ubuntu-24.04`.

`ruby-asan` and `asan-release` are currently only available on `ubuntu-24.04` and `ubuntu-26.04`.

Regarding Windows ruby master builds, `mingw` is a MSYS2/MinGW build, `head` & `ucrt` are MSYS2/UCRT64
builds, and `mswin` is a MSVC/VS 2022 build.
builds, and `mswin` is a MSVC build.

Preview and RC versions of Ruby might be available too on Ubuntu and macOS (not on Windows).
However, it is recommended to test against `ruby-head` rather than previews,
Expand All @@ -52,17 +51,21 @@ The action works on these [GitHub-hosted runners](https://docs.github.com/en/act
| Operating System | Supported |
| ---------------- | --------- |
| Ubuntu | `ubuntu-22.04`, `ubuntu-24.04`, `ubuntu-26.04`, `ubuntu-22.04-arm`, `ubuntu-24.04-arm`, `ubuntu-26.04-arm` |
| macOS | `macos-14` and newer versions |
| macOS | `macos-15` and newer versions |
| Windows | `windows-2022`, `windows-2025`, `windows-11-arm` |

Not all combinations of runner images and versions are supported.
The list of available Ruby versions can be seen in [ruby-builder-versions.json](ruby-builder-versions.json) for Ubuntu and macOS
(although some combinations are not available, see [the full list](https://github.com/ruby/ruby-builder/releases/tag/toolcache))
The full list of available Ruby versions can be seen in [here for Ubuntu and macOS](https://github.com/ruby/ruby-builder/releases)
and in [windows-versions.json](windows-versions.json) for Windows.
Newer runner images only have builds of the latest patch release of each series,
so prefer a short version like `'3.4'` over an exact one like `'3.4.2'`, or pin to a specific runner version (e.g. `ubuntu-24.04`).
For example, `ubuntu-26.04` (which `ubuntu-latest` now points to, see [this announcement](https://github.com/actions/runner-images/issues/14748))
only has builds of CRuby 2.3 and newer, as older CRuby versions do not compile on it.

The prebuilt releases are generated by [ruby-builder](https://github.com/ruby/ruby-builder)
and on Windows by [RubyInstaller2](https://github.com/oneclick/rubyinstaller2).
The `mingw`, `ucrt` and `mswin` builds are generated by [ruby-loco](https://github.com/MSP-Greg/ruby-loco).
The `mingw` and `ucrt` builds are generated by [ruby-loco](https://github.com/MSP-Greg/ruby-loco).
The `mswin` build is the daily master build published at [cache.ruby-lang.org](https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/).
`ruby-head` is generated by [ruby-dev-builder](https://github.com/ruby/ruby-dev-builder),
`jruby-head` is generated by [jruby-dev-builder](https://github.com/ruby/jruby-dev-builder),
`truffleruby-head` and `truffleruby+graalvm-head` are generated by [truffleruby-dev-builder](https://github.com/ruby/truffleruby-dev-builder).
Expand Down Expand Up @@ -203,6 +206,9 @@ They should be set in the `env` at the job level as shown in the [example](#matr
To find the correct the environment variable name, see the [Bundler docs](https://bundler.io/man/bundle-config.1.html) or look at `.bundle/config` after running `bundle config --local KEY VALUE` locally.
You might need to `"`-quote the environment variable name in YAML if it has unusual characters like `/`.

By default, `bundle install` is run with `--jobs` set to the number of available processors (up to 8).
This can be changed by setting `BUNDLE_JOBS`.

To perform caching, this action will use `bundle config --local path $PWD/vendor/bundle`.
Therefore, the Bundler `path` should not be changed in your workflow for the cache to work (no `bundle config path`).

Expand Down
11 changes: 8 additions & 3 deletions bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,15 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
console.log(`Found cache for key: ${cachedKey}`)
}

// Number of jobs should scale with runner, up to a point
const jobs = Math.min(os.availableParallelism(), 8)
const installArgs = ['install']
// Honor $BUNDLE_JOBS if set, as passing --jobs would override it
if (!process.env['BUNDLE_JOBS']) {
// Number of jobs should scale with runner, up to a point
const jobs = Math.min(os.availableParallelism(), 8)
installArgs.push('--jobs', `${jobs}`)
}
// Always run 'bundle install' to list the gems
await exec.exec('bundle', ['install', '--jobs', `${jobs}`])
await exec.exec('bundle', installArgs)

// @actions/cache only allows to save for non-existing keys
// Also, skip saving cache for merge_group event
Expand Down
3 changes: 2 additions & 1 deletion common.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ export function isExactCacheKeyMatch(key, cacheKey) {
}

export async function download(url) {
const auth = inputs.token ? `token ${inputs.token}` : undefined
// The token is for github.com, so it must not reach other hosts such as cache.ruby-lang.org
const auth = inputs.token && new URL(url).hostname === 'github.com' ? `token ${inputs.token}` : undefined
return await tc.downloadTool(url, undefined, auth)
}
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"action_type": "node",
"upstream": {
"repository": "ruby/setup-ruby",
"synced_tag": "v1.329.0",
"synced_commit": "651ff0d62c5c79bed6d53ec518387aae20e72c1a",
"synced_tag": "v1.344.0",
Comment thread
anurag-stepsecurity marked this conversation as resolved.
Resolved
"synced_commit": "78c62f2208e480ce3d5ae4dfd9b9e181acf48b63",
"archived": false
},
"build": {
Expand Down
Loading
Loading