diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b07c79402..d9371a319 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -240,6 +240,18 @@ jobs: ruby-version: '2.6' - run: ruby -v + testNoGemfileWithBundlerCache: + name: "Test with no Gemfile but with bundler-cache" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: rm Gemfile + - uses: ./ + with: + ruby-version: '2.6' + bundler-cache: true + - run: ruby -v + testLatestRubygemsVersion: name: "Test rubygems: latest on ${{ matrix.ruby }}" runs-on: ubuntu-latest diff --git a/README.md b/README.md index c8fd9ffba..c27d8a303 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ 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 3.5.0-preview1, head, debug, mingw, mswin, ucrt | -| `jruby` | 9.1.17.0 - 10.0.1.0, head | +| `jruby` | 9.1.17.0 - 10.0.2.0, head | | `truffleruby` | 19.3.0 - 24.2.1, head | | `truffleruby+graalvm` | 21.2.0 - 24.2.1, head | @@ -45,7 +45,7 @@ which means Ruby ≤ 2.4 is unmaintained and considered insecure. ### Supported Platforms -The action works on these [GitHub-hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources) images. Runner images not listed below are not supported yet. `$OS-latest` just alias to one of these images. +The action works on these [GitHub-hosted runners](https://docs.github.com/en/actions/reference/runners/github-hosted-runners) images. Runner images not listed below are not supported yet. `$OS-latest` just alias to one of these images. | Operating System | Supported | | ---------------- | --------- | @@ -79,7 +79,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.3' # Not needed with a .ruby-version, .tool-versions or mise.toml + ruby-version: '3.4' # Not needed with a .ruby-version, .tool-versions or mise.toml bundler-cache: true # runs 'bundle install' and caches installed gems automatically - run: bundle exec rake ``` @@ -98,7 +98,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest] # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', head, jruby, jruby-head, truffleruby, truffleruby-head] + ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', head, jruby, jruby-head, truffleruby, truffleruby-head] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -127,7 +127,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.3' + ruby-version: '3.4' bundler-cache: true # runs 'bundle install' and caches installed gems automatically - run: bundle exec rake ``` diff --git a/bundler.js b/bundler.js index 711871bae..816c56bf8 100644 --- a/bundler.js +++ b/bundler.js @@ -206,7 +206,7 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer await exec.exec('bundle', ['install', '--jobs', '4']) // @actions/cache only allows to save for non-existing keys - if (cachedKey !== key) { + if (!common.isExactCacheKeyMatch(key, cachedKey)) { if (cachedKey) { // existing cache but Gemfile.lock differs, clean old gems await exec.exec('bundle', ['clean']) } diff --git a/common.js b/common.js index de1598457..72e2a9ceb 100644 --- a/common.js +++ b/common.js @@ -360,24 +360,23 @@ export function setupPath(newPathEntries) { const originalPath = process.env[envPath].split(path.delimiter) let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry)) - core.startGroup(`Modifying ${envPath}`) - - // First remove the conflicting path entries - if (cleanPath.length !== originalPath.length) { - console.log(`Entries removed from ${envPath} to avoid conflicts with default Ruby:`) - for (const entry of originalPath) { - if (!cleanPath.includes(entry)) { - console.log(` ${entry}`) + core.group(`Modifying ${envPath}`, async () => { + // First remove the conflicting path entries + if (cleanPath.length !== originalPath.length) { + console.log(`Entries removed from ${envPath} to avoid conflicts with default Ruby:`) + for (const entry of originalPath) { + if (!cleanPath.includes(entry)) { + console.log(` ${entry}`) + } } + core.exportVariable(envPath, cleanPath.join(path.delimiter)) } - core.exportVariable(envPath, cleanPath.join(path.delimiter)) - } - console.log(`Entries added to ${envPath} to use selected Ruby:`) - for (const entry of newPathEntries) { - console.log(` ${entry}`) - } - core.endGroup() + console.log(`Entries added to ${envPath} to use selected Ruby:`) + for (const entry of newPathEntries) { + console.log(` ${entry}`) + } + }) core.addPath(newPathEntries.join(path.delimiter)) } @@ -413,3 +412,15 @@ export async function setupJavaHome(rubyPrefix) { } }) } + +// Determines if two keys are an exact match for the purposes of cache matching +// Specifically, this is a case-insensitive match that ignores accents +// From actions/cache@v3 src/utils/actionUtils.ts (MIT) +export function isExactCacheKeyMatch(key, cacheKey) { + return !!( + cacheKey && + cacheKey.localeCompare(key, undefined, { + sensitivity: 'accent' + }) === 0 + ); +} diff --git a/dist/index.js b/dist/index.js index 160f36172..54dac9fe9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -220,7 +220,7 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b await exec.exec('bundle', ['install', '--jobs', '4']) // @actions/cache only allows to save for non-existing keys - if (cachedKey !== key) { + if (!common.isExactCacheKeyMatch(key, cachedKey)) { if (cachedKey) { // existing cache but Gemfile.lock differs, clean old gems await exec.exec('bundle', ['clean']) } @@ -299,6 +299,7 @@ __nccwpck_require__.r(__webpack_exports__); /* harmony export */ isBundler1Default: () => (/* binding */ isBundler1Default), /* harmony export */ isBundler2Default: () => (/* binding */ isBundler2Default), /* harmony export */ isBundler2dot2Default: () => (/* binding */ isBundler2dot2Default), +/* harmony export */ isExactCacheKeyMatch: () => (/* binding */ isExactCacheKeyMatch), /* harmony export */ isHeadVersion: () => (/* binding */ isHeadVersion), /* harmony export */ isSelfHostedRunner: () => (/* binding */ isSelfHostedRunner), /* harmony export */ isStableVersion: () => (/* binding */ isStableVersion), @@ -677,24 +678,23 @@ function setupPath(newPathEntries) { const originalPath = process.env[envPath].split(path.delimiter) let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry)) - core.startGroup(`Modifying ${envPath}`) - - // First remove the conflicting path entries - if (cleanPath.length !== originalPath.length) { - console.log(`Entries removed from ${envPath} to avoid conflicts with default Ruby:`) - for (const entry of originalPath) { - if (!cleanPath.includes(entry)) { - console.log(` ${entry}`) + core.group(`Modifying ${envPath}`, async () => { + // First remove the conflicting path entries + if (cleanPath.length !== originalPath.length) { + console.log(`Entries removed from ${envPath} to avoid conflicts with default Ruby:`) + for (const entry of originalPath) { + if (!cleanPath.includes(entry)) { + console.log(` ${entry}`) + } } + core.exportVariable(envPath, cleanPath.join(path.delimiter)) } - core.exportVariable(envPath, cleanPath.join(path.delimiter)) - } - console.log(`Entries added to ${envPath} to use selected Ruby:`) - for (const entry of newPathEntries) { - console.log(` ${entry}`) - } - core.endGroup() + console.log(`Entries added to ${envPath} to use selected Ruby:`) + for (const entry of newPathEntries) { + console.log(` ${entry}`) + } + }) core.addPath(newPathEntries.join(path.delimiter)) } @@ -731,6 +731,18 @@ async function setupJavaHome(rubyPrefix) { }) } +// Determines if two keys are an exact match for the purposes of cache matching +// Specifically, this is a case-insensitive match that ignores accents +// From actions/cache@v3 src/utils/actionUtils.ts (MIT) +function isExactCacheKeyMatch(key, cacheKey) { + return !!( + cacheKey && + cacheKey.localeCompare(key, undefined, { + sensitivity: 'accent' + }) === 0 + ); +} + /***/ }), @@ -42920,7 +42932,7 @@ function expand(str, isTop) { var isOptions = m.body.indexOf(',') >= 0; if (!isSequence && !isOptions) { // {a},b} - if (m.post.match(/,.*\}/)) { + if (m.post.match(/,(?!,).*\}/)) { str = m.pre + '{' + m.body + escClose + m.post; return expand(str); } @@ -85155,7 +85167,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4. /***/ ((module) => { "use strict"; -module.exports = /*#__PURE__*/JSON.parse('{"ruby":["1.9.3-p551","2.0.0-p648","2.1.9","2.2.10","2.3.0","2.3.1","2.3.2","2.3.3","2.3.4","2.3.5","2.3.6","2.3.7","2.3.8","2.4.0","2.4.1","2.4.2","2.4.3","2.4.4","2.4.5","2.4.6","2.4.7","2.4.9","2.4.10","2.5.0","2.5.1","2.5.2","2.5.3","2.5.4","2.5.5","2.5.6","2.5.7","2.5.8","2.5.9","2.6.0","2.6.1","2.6.2","2.6.3","2.6.4","2.6.5","2.6.6","2.6.7","2.6.8","2.6.9","2.6.10","2.7.0","2.7.1","2.7.2","2.7.3","2.7.4","2.7.5","2.7.6","2.7.7","2.7.8","3.0.0-preview1","3.0.0-preview2","3.0.0-rc1","3.0.0","3.0.1","3.0.2","3.0.3","3.0.4","3.0.5","3.0.6","3.0.7","3.1.0-preview1","3.1.0","3.1.1","3.1.2","3.1.3","3.1.4","3.1.5","3.1.6","3.1.7","3.2.0-preview1","3.2.0-preview2","3.2.0-preview3","3.2.0-rc1","3.2.0","3.2.1","3.2.2","3.2.3","3.2.4","3.2.5","3.2.6","3.2.7","3.2.8","3.2.9","3.3.0-preview1","3.3.0-preview2","3.3.0-preview3","3.3.0-rc1","3.3.0","3.3.1","3.3.2","3.3.3","3.3.4","3.3.5","3.3.6","3.3.7","3.3.8","3.3.9","3.4.0-preview1","3.4.0-preview2","3.4.0-rc1","3.4.0","3.4.1","3.4.2","3.4.3","3.4.4","3.4.5","3.5.0-preview1","head","debug","asan","3.4-asan"],"jruby":["9.1.17.0","9.2.9.0","9.2.10.0","9.2.11.0","9.2.11.1","9.2.12.0","9.2.13.0","9.2.14.0","9.2.15.0","9.2.16.0","9.2.17.0","9.2.18.0","9.2.19.0","9.2.20.0","9.2.20.1","9.2.21.0","9.3.0.0","9.3.1.0","9.3.2.0","9.3.3.0","9.3.4.0","9.3.6.0","9.3.7.0","9.3.8.0","9.3.9.0","9.3.10.0","9.3.11.0","9.3.13.0","9.3.14.0","9.3.15.0","9.4.0.0","9.4.1.0","9.4.2.0","9.4.3.0","9.4.4.0","9.4.5.0","9.4.6.0","9.4.7.0","9.4.8.0","9.4.9.0","9.4.10.0","9.4.11.0","9.4.12.0","9.4.12.1","9.4.13.0","10.0.0.0","10.0.0.1","10.0.1.0","head"],"truffleruby":["19.3.0","19.3.1","20.0.0","20.1.0","20.2.0","20.3.0","21.0.0","21.1.0","21.2.0","21.2.0.1","21.3.0","22.0.0.2","22.1.0","22.2.0","22.3.0","22.3.1","23.0.0-preview1","23.0.0","23.1.0","23.1.1","23.1.2","24.0.0","24.0.1","24.0.2","24.1.0","24.1.1","24.1.2","24.2.0","24.2.1","head"],"truffleruby+graalvm":["21.2.0","21.3.0","22.0.0.2","22.1.0","22.2.0","22.3.0","22.3.1","23.0.0-preview1","23.0.0","23.1.0","23.1.1","23.1.2","24.0.0","24.0.1","24.0.2","24.1.0","24.1.1","24.1.2","24.2.0","24.2.1","head"]}'); +module.exports = /*#__PURE__*/JSON.parse('{"ruby":["1.9.3-p551","2.0.0-p648","2.1.9","2.2.10","2.3.0","2.3.1","2.3.2","2.3.3","2.3.4","2.3.5","2.3.6","2.3.7","2.3.8","2.4.0","2.4.1","2.4.2","2.4.3","2.4.4","2.4.5","2.4.6","2.4.7","2.4.9","2.4.10","2.5.0","2.5.1","2.5.2","2.5.3","2.5.4","2.5.5","2.5.6","2.5.7","2.5.8","2.5.9","2.6.0","2.6.1","2.6.2","2.6.3","2.6.4","2.6.5","2.6.6","2.6.7","2.6.8","2.6.9","2.6.10","2.7.0","2.7.1","2.7.2","2.7.3","2.7.4","2.7.5","2.7.6","2.7.7","2.7.8","3.0.0-preview1","3.0.0-preview2","3.0.0-rc1","3.0.0","3.0.1","3.0.2","3.0.3","3.0.4","3.0.5","3.0.6","3.0.7","3.1.0-preview1","3.1.0","3.1.1","3.1.2","3.1.3","3.1.4","3.1.5","3.1.6","3.1.7","3.2.0-preview1","3.2.0-preview2","3.2.0-preview3","3.2.0-rc1","3.2.0","3.2.1","3.2.2","3.2.3","3.2.4","3.2.5","3.2.6","3.2.7","3.2.8","3.2.9","3.3.0-preview1","3.3.0-preview2","3.3.0-preview3","3.3.0-rc1","3.3.0","3.3.1","3.3.2","3.3.3","3.3.4","3.3.5","3.3.6","3.3.7","3.3.8","3.3.9","3.4.0-preview1","3.4.0-preview2","3.4.0-rc1","3.4.0","3.4.1","3.4.2","3.4.3","3.4.4","3.4.5","3.5.0-preview1","head","debug","asan","3.4-asan"],"jruby":["9.1.17.0","9.2.9.0","9.2.10.0","9.2.11.0","9.2.11.1","9.2.12.0","9.2.13.0","9.2.14.0","9.2.15.0","9.2.16.0","9.2.17.0","9.2.18.0","9.2.19.0","9.2.20.0","9.2.20.1","9.2.21.0","9.3.0.0","9.3.1.0","9.3.2.0","9.3.3.0","9.3.4.0","9.3.6.0","9.3.7.0","9.3.8.0","9.3.9.0","9.3.10.0","9.3.11.0","9.3.13.0","9.3.14.0","9.3.15.0","9.4.0.0","9.4.1.0","9.4.2.0","9.4.3.0","9.4.4.0","9.4.5.0","9.4.6.0","9.4.7.0","9.4.8.0","9.4.9.0","9.4.10.0","9.4.11.0","9.4.12.0","9.4.12.1","9.4.13.0","10.0.0.0","10.0.0.1","10.0.1.0","10.0.2.0","head"],"truffleruby":["19.3.0","19.3.1","20.0.0","20.1.0","20.2.0","20.3.0","21.0.0","21.1.0","21.2.0","21.2.0.1","21.3.0","22.0.0.2","22.1.0","22.2.0","22.3.0","22.3.1","23.0.0-preview1","23.0.0","23.1.0","23.1.1","23.1.2","24.0.0","24.0.1","24.0.2","24.1.0","24.1.1","24.1.2","24.2.0","24.2.1","head"],"truffleruby+graalvm":["21.2.0","21.3.0","22.0.0.2","22.1.0","22.2.0","22.3.0","22.3.1","23.0.0-preview1","23.0.0","23.1.0","23.1.1","23.1.2","24.0.0","24.0.1","24.0.2","24.1.0","24.1.1","24.1.2","24.2.0","24.2.1","head"]}'); /***/ }), @@ -85351,6 +85363,11 @@ async function setupRuby(options = {}) { if (inputs['bundler-cache'] === 'true') { await common.time('bundle install', async () => bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version'])) + + if (lockFile !== null && fs.existsSync(lockFile)) { + await core.group(`Print lockfile`, async () => + await exec.exec('cat', [lockFile])) + } } core.setOutput('ruby-prefix', rubyPrefix) diff --git a/index.js b/index.js index 62e46feb9..2d29628d7 100644 --- a/index.js +++ b/index.js @@ -99,6 +99,11 @@ export async function setupRuby(options = {}) { if (inputs['bundler-cache'] === 'true') { await common.time('bundle install', async () => bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version'])) + + if (lockFile !== null && fs.existsSync(lockFile)) { + await core.group(`Print lockfile`, async () => + await exec.exec('cat', [lockFile])) + } } core.setOutput('ruby-prefix', rubyPrefix) diff --git a/ruby-builder-versions.json b/ruby-builder-versions.json index 227b91a9f..398939a67 100644 --- a/ruby-builder-versions.json +++ b/ruby-builder-versions.json @@ -22,7 +22,7 @@ "9.2.9.0", "9.2.10.0", "9.2.11.0", "9.2.11.1", "9.2.12.0", "9.2.13.0", "9.2.14.0", "9.2.15.0", "9.2.16.0", "9.2.17.0", "9.2.18.0", "9.2.19.0", "9.2.20.0", "9.2.20.1", "9.2.21.0", "9.3.0.0", "9.3.1.0", "9.3.2.0", "9.3.3.0", "9.3.4.0", "9.3.6.0", "9.3.7.0", "9.3.8.0", "9.3.9.0", "9.3.10.0", "9.3.11.0", "9.3.13.0", "9.3.14.0", "9.3.15.0", "9.4.0.0", "9.4.1.0", "9.4.2.0", "9.4.3.0", "9.4.4.0", "9.4.5.0", "9.4.6.0", "9.4.7.0", "9.4.8.0", "9.4.9.0", "9.4.10.0", "9.4.11.0", "9.4.12.0", "9.4.12.1", "9.4.13.0", - "10.0.0.0", "10.0.0.1", "10.0.1.0", + "10.0.0.0", "10.0.0.1", "10.0.1.0", "10.0.2.0", "head" ], "truffleruby": [ diff --git a/yarn.lock b/yarn.lock index 19e5e64af..9b8cfef48 100644 --- a/yarn.lock +++ b/yarn.lock @@ -283,9 +283,9 @@ balanced-match@^1.0.0: integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + version "1.1.12" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.12.tgz#ab9b454466e5a8cc3a187beaad580412a9c5b843" + integrity sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg== dependencies: balanced-match "^1.0.0" concat-map "0.0.1" @@ -376,13 +376,14 @@ fast-xml-parser@^5.0.7: strnum "^2.1.0" form-data@^2.5.0: - version "2.5.3" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.5.3.tgz#f9bcf87418ce748513c0c3494bb48ec270c97acc" - integrity sha512-XHIrMD0NpDrNM/Ckf7XJiBbLl57KEhT3+i3yY+eWm+cqYZJQTZrKo8Y8AWKnuV5GT4scfuUGt9LzNoIx3dU1nQ== + version "2.5.5" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.5.5.tgz#a5f6364ad7e4e67e95b4a07e2d8c6f711c74f624" + integrity sha512-jqdObeR2rxZZbPSGL+3VckHMYtu+f9//KXBsVny6JSX/pa38Fy+bGjuG8eW/H6USNQWhLi8Num++cU2yOCNz4A== dependencies: asynckit "^0.4.0" combined-stream "^1.0.8" es-set-tostringtag "^2.1.0" + hasown "^2.0.2" mime-types "^2.1.35" safe-buffer "^5.2.1"