Compare commits

...
5 Commits
Author SHA1 Message Date
Benoit Daloze 77ca66ce27 Add 2.0.0 on Windows too 2021-05-31 22:18:27 +02:00
Filipe Brandenburger fd1a6a00ca Mention Ruby 2.0 in README and add it to CI 2021-05-31 22:07:29 +02:00
Filipe Brandenburger 01144718b5 Add ruby-2.0.0-p648 to the list
It was added to toolcache in commit 9fa277367b8cd338cfc5aca4b91d854e8e0a58b2.
2021-05-31 22:07:29 +02:00
Jakub Pavlik b161cb92f0 document cache-version 2021-05-15 16:32:01 +02:00
Jakub Pavlik fa2182b2a4 cache-version input allowing a forced change of the cache key 2021-05-15 16:32:01 +02:00
10 changed files with 54 additions and 21 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11.0, windows-2016, windows-2019 ] os: [ ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11.0, windows-2016, windows-2019 ]
ruby: [ 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, '3.0', ruby-head, jruby, jruby-head, truffleruby, truffleruby-head ] ruby: [ '2.0', 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, '3.0', ruby-head, jruby, jruby-head, truffleruby, truffleruby-head ]
include: include:
- { os: windows-2016, ruby: mingw } - { os: windows-2016, ruby: mingw }
- { os: windows-2019, ruby: mingw } - { os: windows-2019, ruby: mingw }
+15 -1
View File
@@ -14,7 +14,7 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
| Interpreter | Versions | | Interpreter | Versions |
| ----------- | -------- | | ----------- | -------- |
| `ruby` | 2.1.9, 2.2, all versions from 2.3.0 until 3.0.1, head, debug, mingw, mswin | | `ruby` | 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.0.1, head, debug, mingw, mswin |
| `jruby` | 9.1.17.0, 9.2.9.0 - 9.2.17.0, head | | `jruby` | 9.1.17.0, 9.2.9.0 - 9.2.17.0, head |
| `truffleruby` | 19.3.0 - 21.1.0, head | | `truffleruby` | 19.3.0 - 21.1.0, head |
@@ -180,6 +180,20 @@ When there is no lockfile, one is generated with `bundle lock`, which is the sam
In other words, it works exactly like `bundle install`. In other words, it works exactly like `bundle install`.
The hash of the generated lockfile is then used for caching, which is the only correct approach. The hash of the generated lockfile is then used for caching, which is the only correct approach.
#### Dealing with a corrupted cache
In some rare scenarios (like using gems with C extensions whose functionality depends on libraries found on the system
at the time of the gem's build) it may be necessary to ignore contents of the cache and get and build all the gems anew.
In order to achieve this, set the `cache-version` option to any value other than `0` (or change it to a new unique value
if you have already used it before.)
```yaml
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
cache-version: 1
```
#### Caching `bundle install` manually #### Caching `bundle install` manually
It is also possible to cache gems manually, but this is not recommended because it is verbose and *very difficult* to do correctly. It is also possible to cache gems manually, but this is not recommended because it is verbose and *very difficult* to do correctly.
+6
View File
@@ -24,6 +24,12 @@ inputs:
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions and Gemfile.lock.' description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions and Gemfile.lock.'
required: false required: false
default: '.' default: '.'
cache-version:
description: |
Arbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need
to invalidate the cache.
required: false
default: '0'
outputs: outputs:
ruby-prefix: ruby-prefix:
description: 'The prefix of the installed ruby' description: 'The prefix of the installed ruby'
+7 -4
View File
@@ -5,6 +5,8 @@ const exec = require('@actions/exec')
const cache = require('@actions/cache') const cache = require('@actions/cache')
const common = require('./common') const common = require('./common')
export const DEFAULT_CACHE_VERSION = '0'
// The returned gemfile is guaranteed to exist, the lockfile might not exist // The returned gemfile is guaranteed to exist, the lockfile might not exist
export function detectGemfiles() { export function detectGemfiles() {
const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile' const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile'
@@ -95,7 +97,7 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
return bundlerVersion return bundlerVersion
} }
export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, bundlerVersion) { export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, bundlerVersion, cacheVersion) {
if (gemfile === null) { if (gemfile === null) {
console.log('Could not determine gemfile path, skipping "bundle install" and caching') console.log('Could not determine gemfile path, skipping "bundle install" and caching')
return false return false
@@ -128,7 +130,7 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
// cache key // cache key
const paths = [cachePath] const paths = [cachePath]
const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile) const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile, cacheVersion)
const key = `${baseKey}-${await common.hashFile(lockFile)}` const key = `${baseKey}-${await common.hashFile(lockFile)}`
// If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below // If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below
const restoreKeys = [`${baseKey}-`] const restoreKeys = [`${baseKey}-`]
@@ -177,8 +179,9 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
return true return true
} }
async function computeBaseKey(platform, engine, version, lockFile) { async function computeBaseKey(platform, engine, version, lockFile, cacheVersion) {
let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}` const cacheVersionSuffix = DEFAULT_CACHE_VERSION === cacheVersion ? '' : `-cachever:${cacheVersion}`
let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}${cacheVersionSuffix}`
if (engine !== 'jruby' && common.isHeadVersion(version)) { if (engine !== 'jruby' && common.isHeadVersion(version)) {
let revision = ''; let revision = '';
Generated Vendored
+16 -9
View File
@@ -27753,10 +27753,10 @@ const rubyInstallerVersions = __webpack_require__(223).versions
const drive = common.drive const drive = common.drive
// needed for 2.1, 2.2, 2.3, and mswin, cert file used by Git for Windows // needed for 2.0-2.3, and mswin, cert file used by Git for Windows
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem' const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.1, 2.2 and 2.3 // location & path for old RubyInstaller DevKit (MSYS), Ruby 2.0-2.3
const msys = `${drive}:\\DevKit64` const msys = `${drive}:\\DevKit64`
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys}\\mingw\\bin`, `${msys}\\bin`] const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys}\\mingw\\bin`, `${msys}\\bin`]
@@ -27822,7 +27822,7 @@ async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
async function setupMingw(version) { async function setupMingw(version) {
core.exportVariable('MAKE', 'make.exe') core.exportVariable('MAKE', 'make.exe')
if (version.match(/^2\.[123]/)) { if (version.match(/^2\.[0123]/)) {
core.exportVariable('SSL_CERT_FILE', certFile) core.exportVariable('SSL_CERT_FILE', certFile)
await common.measure('Installing MSYS', async () => installMSYS(version)) await common.measure('Installing MSYS', async () => installMSYS(version))
return msysPathEntries return msysPathEntries
@@ -27831,7 +27831,7 @@ async function setupMingw(version) {
} }
} }
// Ruby 2.1, 2.2 and 2.3 // Ruby 2.0, 2.1, 2.2 and 2.3
async function installMSYS(version) { async function installMSYS(version) {
const url = 'https://github.com/oneclick/rubyinstaller/releases/download/devkit-4.7.2/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe' const url = 'https://github.com/oneclick/rubyinstaller/releases/download/devkit-4.7.2/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe'
const downloadPath = await tc.downloadTool(url) const downloadPath = await tc.downloadTool(url)
@@ -28202,6 +28202,7 @@ exports.debug = debug; // for test
__webpack_require__.r(__webpack_exports__); __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "versions", function() { return versions; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "versions", function() { return versions; });
const versions = { const versions = {
"2.0.0": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.0.0-p648/ruby-2.0.0-p648-x64-mingw32.7z",
"2.1.9": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.1.9/ruby-2.1.9-x64-mingw32.7z", "2.1.9": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.1.9/ruby-2.1.9-x64-mingw32.7z",
"2.2.6": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.2.6/ruby-2.2.6-x64-mingw32.7z", "2.2.6": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.2.6/ruby-2.2.6-x64-mingw32.7z",
"2.3.0": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.3.0/ruby-2.3.0-x64-mingw32.7z", "2.3.0": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.3.0/ruby-2.3.0-x64-mingw32.7z",
@@ -44537,6 +44538,7 @@ module.exports = require("net");
"use strict"; "use strict";
__webpack_require__.r(__webpack_exports__); __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_CACHE_VERSION", function() { return DEFAULT_CACHE_VERSION; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "detectGemfiles", function() { return detectGemfiles; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "detectGemfiles", function() { return detectGemfiles; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "installBundler", function() { return installBundler; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "installBundler", function() { return installBundler; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bundleInstall", function() { return bundleInstall; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bundleInstall", function() { return bundleInstall; });
@@ -44547,6 +44549,8 @@ const exec = __webpack_require__(514)
const cache = __webpack_require__(799) const cache = __webpack_require__(799)
const common = __webpack_require__(390) const common = __webpack_require__(390)
const DEFAULT_CACHE_VERSION = '0'
// The returned gemfile is guaranteed to exist, the lockfile might not exist // The returned gemfile is guaranteed to exist, the lockfile might not exist
function detectGemfiles() { function detectGemfiles() {
const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile' const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile'
@@ -44637,7 +44641,7 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
return bundlerVersion return bundlerVersion
} }
async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, bundlerVersion) { async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, bundlerVersion, cacheVersion) {
if (gemfile === null) { if (gemfile === null) {
console.log('Could not determine gemfile path, skipping "bundle install" and caching') console.log('Could not determine gemfile path, skipping "bundle install" and caching')
return false return false
@@ -44670,7 +44674,7 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
// cache key // cache key
const paths = [cachePath] const paths = [cachePath]
const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile) const baseKey = await computeBaseKey(platform, engine, rubyVersion, lockFile, cacheVersion)
const key = `${baseKey}-${await common.hashFile(lockFile)}` const key = `${baseKey}-${await common.hashFile(lockFile)}`
// If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below // If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below
const restoreKeys = [`${baseKey}-`] const restoreKeys = [`${baseKey}-`]
@@ -44719,8 +44723,9 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
return true return true
} }
async function computeBaseKey(platform, engine, version, lockFile) { async function computeBaseKey(platform, engine, version, lockFile, cacheVersion) {
let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}` const cacheVersionSuffix = DEFAULT_CACHE_VERSION === cacheVersion ? '' : `-cachever:${cacheVersion}`
let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}${cacheVersionSuffix}`
if (engine !== 'jruby' && common.isHeadVersion(version)) { if (engine !== 'jruby' && common.isHeadVersion(version)) {
let revision = ''; let revision = '';
@@ -45350,6 +45355,7 @@ __webpack_require__.r(__webpack_exports__);
function getVersions(platform) { function getVersions(platform) {
const versions = { const versions = {
"ruby": [ "ruby": [
"2.0.0-p648",
"2.1.9", "2.1.9",
"2.2.10", "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.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",
@@ -52071,6 +52077,7 @@ const inputDefaults = {
'bundler': 'default', 'bundler': 'default',
'bundler-cache': 'true', 'bundler-cache': 'true',
'working-directory': '.', 'working-directory': '.',
'cache-version': bundler.DEFAULT_CACHE_VERSION,
} }
// entry point when this action is run on its own // entry point when this action is run on its own
@@ -52126,7 +52133,7 @@ async function setupRuby(options = {}) {
if (inputs['bundler-cache'] === 'true') { if (inputs['bundler-cache'] === 'true') {
await common.measure('bundle install', async () => await common.measure('bundle install', async () =>
bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion)) bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version']))
} }
} }
+1 -1
View File
@@ -2,7 +2,7 @@ require 'net/http'
require 'yaml' require 'yaml'
require 'json' require 'json'
min_requirements = ['~> 2.1.9', '>= 2.2.6'].map { |req| Gem::Requirement.new(req) } min_requirements = ['~> 2.0.0', '~> 2.1.9', '>= 2.2.6'].map { |req| Gem::Requirement.new(req) }
url = 'https://raw.githubusercontent.com/oneclick/rubyinstaller.org-website/master/_data/downloads.yaml' url = 'https://raw.githubusercontent.com/oneclick/rubyinstaller.org-website/master/_data/downloads.yaml'
entries = YAML.load(Net::HTTP.get(URI(url)), symbolize_names: true) entries = YAML.load(Net::HTTP.get(URI(url)), symbolize_names: true)
+2 -1
View File
@@ -12,6 +12,7 @@ const inputDefaults = {
'bundler': 'default', 'bundler': 'default',
'bundler-cache': 'true', 'bundler-cache': 'true',
'working-directory': '.', 'working-directory': '.',
'cache-version': bundler.DEFAULT_CACHE_VERSION,
} }
// entry point when this action is run on its own // entry point when this action is run on its own
@@ -67,7 +68,7 @@ export async function setupRuby(options = {}) {
if (inputs['bundler-cache'] === 'true') { if (inputs['bundler-cache'] === 'true') {
await common.measure('bundle install', async () => await common.measure('bundle install', async () =>
bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion)) bundler.bundleInstall(gemfile, lockFile, platform, engine, version, bundlerVersion, inputs['cache-version']))
} }
} }
+1
View File
@@ -1,6 +1,7 @@
export function getVersions(platform) { export function getVersions(platform) {
const versions = { const versions = {
"ruby": [ "ruby": [
"2.0.0-p648",
"2.1.9", "2.1.9",
"2.2.10", "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.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",
+1
View File
@@ -1,4 +1,5 @@
export const versions = { export const versions = {
"2.0.0": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.0.0-p648/ruby-2.0.0-p648-x64-mingw32.7z",
"2.1.9": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.1.9/ruby-2.1.9-x64-mingw32.7z", "2.1.9": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.1.9/ruby-2.1.9-x64-mingw32.7z",
"2.2.6": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.2.6/ruby-2.2.6-x64-mingw32.7z", "2.2.6": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.2.6/ruby-2.2.6-x64-mingw32.7z",
"2.3.0": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.3.0/ruby-2.3.0-x64-mingw32.7z", "2.3.0": "https://github.com/oneclick/rubyinstaller/releases/download/ruby-2.3.0/ruby-2.3.0-x64-mingw32.7z",
+4 -4
View File
@@ -13,10 +13,10 @@ const rubyInstallerVersions = require('./windows-versions').versions
const drive = common.drive const drive = common.drive
// needed for 2.1, 2.2, 2.3, and mswin, cert file used by Git for Windows // needed for 2.0-2.3, and mswin, cert file used by Git for Windows
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem' const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.1, 2.2 and 2.3 // location & path for old RubyInstaller DevKit (MSYS), Ruby 2.0-2.3
const msys = `${drive}:\\DevKit64` const msys = `${drive}:\\DevKit64`
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys}\\mingw\\bin`, `${msys}\\bin`] const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys}\\mingw\\bin`, `${msys}\\bin`]
@@ -82,7 +82,7 @@ async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
async function setupMingw(version) { async function setupMingw(version) {
core.exportVariable('MAKE', 'make.exe') core.exportVariable('MAKE', 'make.exe')
if (version.match(/^2\.[123]/)) { if (version.match(/^2\.[0123]/)) {
core.exportVariable('SSL_CERT_FILE', certFile) core.exportVariable('SSL_CERT_FILE', certFile)
await common.measure('Installing MSYS', async () => installMSYS(version)) await common.measure('Installing MSYS', async () => installMSYS(version))
return msysPathEntries return msysPathEntries
@@ -91,7 +91,7 @@ async function setupMingw(version) {
} }
} }
// Ruby 2.1, 2.2 and 2.3 // Ruby 2.0, 2.1, 2.2 and 2.3
async function installMSYS(version) { async function installMSYS(version) {
const url = 'https://github.com/oneclick/rubyinstaller/releases/download/devkit-4.7.2/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe' const url = 'https://github.com/oneclick/rubyinstaller/releases/download/devkit-4.7.2/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe'
const downloadPath = await tc.downloadTool(url) const downloadPath = await tc.downloadTool(url)