Compare commits

...
7 Commits
Author SHA1 Message Date
dependabot[bot] 8bc9ca9ace Bump @actions/core from 1.2.4 to 1.2.6
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.4 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-01 22:10:14 +02:00
Benoit Daloze 965ef501d4 Tweak wording 2020-09-19 12:14:15 +02:00
Benoit Daloze 153ca5e38f Update documentation about self-hosted runners 2020-09-19 12:06:35 +02:00
Benoit Daloze 0effb2cc50 Document that gems.rb/gems.locked is supported now 2020-09-19 11:43:36 +02:00
Benoit Daloze b62e5d53aa Take advantage that detectGemfiles() only returns existing paths
* So use !== null instead of redoing the existsSync() check.
* Rename a few variables for consistency.
2020-09-19 11:31:18 +02:00
Samuel Williams 1c172ef5dc Add support for gems.rb/gems.locked during bundle install (#84)
* Extract detection of gemfile and lockfile.
2020-09-19 11:18:52 +02:00
dependabot[bot] 4cbbce6b48 Bump node-fetch from 2.6.0 to 2.6.1
Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/bitinn/node-fetch/compare/v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-13 13:21:14 +02:00
6 changed files with 409 additions and 582 deletions
+11 -6
View File
@@ -31,7 +31,7 @@ On Windows, Ruby 2.4 uses OpenSSL 1.0.2, which is no longer maintained.
### Supported Platforms ### Supported Platforms
The action works for all [GitHub-hosted runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners), and [self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners), under [certain conditions](#limitations) The action works for all [GitHub-hosted runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners).
| Operating System | Recommended | Other Supported Versions | | Operating System | Recommended | Other Supported Versions |
| ----------- | -------- | -------- | | ----------- | -------- | -------- |
@@ -115,7 +115,7 @@ if they are not at the root of the repository, see [action.yml](action.yml) for
### Bundler ### Bundler
By default, if there is a `Gemfile.lock` file (or `$BUNDLE_GEMFILE.lock` if `$BUNDLE_GEMFILE` is set) with a `BUNDLED WITH` section, By default, if there is a `Gemfile.lock` file (or `$BUNDLE_GEMFILE.lock` or `gems.locked`) with a `BUNDLED WITH` section,
the latest version of Bundler with the same major version will be installed. the latest version of Bundler with the same major version will be installed.
Otherwise, the latest compatible Bundler version is installed (Bundler 2 on Ruby >= 2.4, Bundler 1 on Ruby < 2.4). Otherwise, the latest compatible Bundler version is installed (Bundler 2 on Ruby >= 2.4, Bundler 1 on Ruby < 2.4).
@@ -131,9 +131,8 @@ This action provides a way to automatically run `bundle install` and cache the r
``` ```
This caching speeds up installing gems significantly and avoids too many requests to RubyGems.org. This caching speeds up installing gems significantly and avoids too many requests to RubyGems.org.
It needs a `Gemfile` (or `$BUNDLE_GEMFILE`) under the [`working-directory`](#working-directory). It needs a `Gemfile` (or `$BUNDLE_GEMFILE` or `gems.rb`) under the [`working-directory`](#working-directory).
The caching works whether there is a `Gemfile.lock` or not. If there is a `Gemfile.lock` (or `$BUNDLE_GEMFILE.lock` or `gems.locked`), `bundle config --local deployment true` is used.
If there is a `Gemfile.lock`, `bundle config --local deployment true` is used.
To perform caching, this action will use `bundle config --local path vendor/bundle`. To perform caching, this action will use `bundle config --local path vendor/bundle`.
Therefore, the Bundler `path` should not be changed in your workflow for the cache to work. Therefore, the Bundler `path` should not be changed in your workflow for the cache to work.
@@ -192,11 +191,17 @@ This action follows semantic versioning with a moving `v1` branch.
This follows the [recommendations](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) of GitHub Actions. This follows the [recommendations](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) of GitHub Actions.
## Using self-hosted runners ## Using self-hosted runners
You must meet the following parameters to use this action with self-hosted runners:
This action might work with [self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners)
if the [virtual environment](https://github.com/actions/virtual-environments) is very similar to the ones used by GitHub runners. Notably:
* Make sure to use the same operating system and version.
* Make sure to use the same version of libssl.
* Make sure that the operating system has `libyaml-0` installed * Make sure that the operating system has `libyaml-0` installed
* The runner software is running as user `runner` with a home directory of `/home/runner`, or you have created a symlink for the home directory of whatever user that the runner is running as to `/home/runner`. * The runner software is running as user `runner` with a home directory of `/home/runner`, or you have created a symlink for the home directory of whatever user that the runner is running as to `/home/runner`.
In other cases, please use a system Ruby or [install Ruby manually](https://github.com/postmodern/chruby/wiki#installing-rubies) instead.
## History ## History
This action used to be at `eregon/use-ruby-action` and was moved to the `ruby` organization. This action used to be at `eregon/use-ruby-action` and was moved to the `ruby` organization.
+2 -2
View File
@@ -12,8 +12,8 @@ inputs:
bundler: bundler:
description: | description: |
The version of Bundler to install. Either 'none', 1, 2, 'latest' or 'Gemfile.lock'. The version of Bundler to install. Either 'none', 1, 2, 'latest' or 'Gemfile.lock'.
For 'Gemfile.lock', the version is determined based on the BUNDLED WITH section from the file ($BUNDLE_GEMFILE || Gemfile).lock. For 'Gemfile.lock', the version is determined based on the BUNDLED WITH section from the file Gemfile.lock, $BUNDLE_GEMFILE.lock or gems.locked.
Defaults to 'Gemfile.lock' if it exists and 'latest' otherwise. Defaults to 'Gemfile.lock' if the file exists and 'latest' otherwise.
required: false required: false
default: 'default' default: 'default'
bundler-cache: bundler-cache:
Generated Vendored
+342 -543
View File
File diff suppressed because it is too large Load Diff
+46 -18
View File
@@ -61,18 +61,44 @@ export async function setupRuby(options = {}) {
} }
if (inputs['bundler'] !== 'none') { if (inputs['bundler'] !== 'none') {
const [gemfile, lockFile] = detectGemfiles()
await common.measure('Installing Bundler', async () => await common.measure('Installing Bundler', async () =>
installBundler(inputs['bundler'], platform, rubyPrefix, engine, version)) installBundler(inputs['bundler'], lockFile, platform, rubyPrefix, engine, version))
if (inputs['bundler-cache'] === 'true') { if (inputs['bundler-cache'] === 'true') {
await common.measure('bundle install', async () => await common.measure('bundle install', async () =>
bundleInstall(platform, engine, version)) bundleInstall(gemfile, lockFile, platform, engine, version))
} }
} }
core.setOutput('ruby-prefix', rubyPrefix) core.setOutput('ruby-prefix', rubyPrefix)
} }
function detectGemfiles() {
const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile'
if (fs.existsSync(gemfilePath)) {
const lockPath = `${gemfilePath}.lock`
if (fs.existsSync(lockPath)) {
return [gemfilePath, lockPath]
} else {
return [gemfilePath, null]
}
}
const gemsRbPath = "gems.rb"
if (fs.existsSync(gemsRbPath)) {
const lockPath = "gems.locked"
if (fs.existsSync(lockPath)) {
return [gemsRbPath, lockPath]
} else {
return [gemsRbPath, null]
}
}
return [null, null]
}
function parseRubyEngineAndVersion(rubyVersion) { function parseRubyEngineAndVersion(rubyVersion) {
if (rubyVersion === 'default') { if (rubyVersion === 'default') {
if (fs.existsSync('.ruby-version')) { if (fs.existsSync('.ruby-version')) {
@@ -150,9 +176,9 @@ function envPreInstall() {
} }
} }
function readBundledWithFromGemfileLock(path) { function readBundledWithFromGemfileLock(lockFile) {
if (fs.existsSync(path)) { if (lockFile !== null) {
const contents = fs.readFileSync(path, 'utf8') const contents = fs.readFileSync(lockFile, 'utf8')
const lines = contents.split(/\r?\n/) const lines = contents.split(/\r?\n/)
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim())) const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
if (bundledWithLine !== -1) { if (bundledWithLine !== -1) {
@@ -160,7 +186,7 @@ function readBundledWithFromGemfileLock(path) {
if (nextLine && /^\d+/.test(nextLine.trim())) { if (nextLine && /^\d+/.test(nextLine.trim())) {
const bundlerVersion = nextLine.trim() const bundlerVersion = nextLine.trim()
const majorVersion = bundlerVersion.match(/^\d+/)[0] const majorVersion = bundlerVersion.match(/^\d+/)[0]
console.log(`Using Bundler ${majorVersion} from ${path} BUNDLED WITH ${bundlerVersion}`) console.log(`Using Bundler ${majorVersion} from ${lockFile} BUNDLED WITH ${bundlerVersion}`)
return majorVersion return majorVersion
} }
} }
@@ -168,12 +194,12 @@ function readBundledWithFromGemfileLock(path) {
return null return null
} }
async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine, rubyVersion) { async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefix, engine, rubyVersion) {
var bundlerVersion = bundlerVersionInput var bundlerVersion = bundlerVersionInput
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') { if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
const gemfilePath = `${process.env['BUNDLE_GEMFILE'] || 'Gemfile'}.lock` bundlerVersion = readBundledWithFromGemfileLock(lockFile)
bundlerVersion = readBundledWithFromGemfileLock(gemfilePath)
if (!bundlerVersion) { if (!bundlerVersion) {
bundlerVersion = 'latest' bundlerVersion = 'latest'
} }
@@ -209,16 +235,16 @@ async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine,
} }
} }
async function bundleInstall(platform, engine, version) { async function bundleInstall(gemfile, lockFile, platform, engine, version) {
if (!fs.existsSync('Gemfile')) { if (gemfile === null) {
console.log('No Gemfile, skipping "bundle install" and caching') console.log('Could not determine gemfile path, skipping "bundle install" and caching')
return return false
} }
// config // config
const path = 'vendor/bundle' const path = 'vendor/bundle'
const hasGemfileLock = fs.existsSync('Gemfile.lock');
if (hasGemfileLock) { if (lockFile !== null) {
await exec.exec('bundle', ['config', '--local', 'deployment', 'true']) await exec.exec('bundle', ['config', '--local', 'deployment', 'true'])
} }
await exec.exec('bundle', ['config', '--local', 'path', path]) await exec.exec('bundle', ['config', '--local', 'path', path])
@@ -228,10 +254,10 @@ async function bundleInstall(platform, engine, version) {
const baseKey = await computeBaseKey(platform, engine, version) const baseKey = await computeBaseKey(platform, engine, version)
let key = baseKey let key = baseKey
let restoreKeys let restoreKeys
if (hasGemfileLock) { if (lockFile !== null) {
key += `-Gemfile.lock-${await common.hashFile('Gemfile.lock')}` key += `-${lockFile}-${await common.hashFile(lockFile)}`
// If only Gemfile.lock we can reuse some of the cache (but it will keep old gem versions in the cache) // If only Gemfile.lock we can reuse some of the cache (but it will keep old gem versions in the cache)
restoreKeys = [`${baseKey}-Gemfile.lock-`] restoreKeys = [`${baseKey}-${lockFile}-`]
} else { } else {
// Only exact key, to never mix native gems of different platforms or Ruby versions // Only exact key, to never mix native gems of different platforms or Ruby versions
restoreKeys = [] restoreKeys = []
@@ -277,6 +303,8 @@ async function bundleInstall(platform, engine, version) {
} }
} }
} }
return true
} }
async function computeBaseKey(platform, engine, version) { async function computeBaseKey(platform, engine, version) {
+1 -1
View File
@@ -23,7 +23,7 @@
"homepage": "https://github.com/ruby/setup-ruby", "homepage": "https://github.com/ruby/setup-ruby",
"dependencies": { "dependencies": {
"@actions/cache": "^1.0.2", "@actions/cache": "^1.0.2",
"@actions/core": "^1.2.4", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.3", "@actions/exec": "^1.0.3",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.3.4" "@actions/tool-cache": "^1.3.4"
Generated
+7 -12
View File
@@ -17,15 +17,10 @@
semver "^6.1.0" semver "^6.1.0"
uuid "^3.3.3" uuid "^3.3.3"
"@actions/core@^1.2.0", "@actions/core@^1.2.4": "@actions/core@^1.2.0", "@actions/core@^1.2.3", "@actions/core@^1.2.4", "@actions/core@^1.2.6":
version "1.2.4" version "1.2.6"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.4.tgz#96179dbf9f8d951dd74b40a0dbd5c22555d186ab" resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
integrity sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg== integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
"@actions/core@^1.2.3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.3.tgz#e844b4fa0820e206075445079130868f95bfca95"
integrity sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w==
"@actions/exec@^1.0.0", "@actions/exec@^1.0.1", "@actions/exec@^1.0.3": "@actions/exec@^1.0.0", "@actions/exec@^1.0.1", "@actions/exec@^1.0.3":
version "1.0.4" version "1.0.4"
@@ -331,9 +326,9 @@ minimatch@^3.0.4:
brace-expansion "^1.1.7" brace-expansion "^1.1.7"
node-fetch@^2.6.0: node-fetch@^2.6.0:
version "2.6.0" version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
process@^0.11.10: process@^0.11.10:
version "0.11.10" version "0.11.10"