cache-version input allowing a forced change of the cache key

This commit is contained in:
Jakub Pavlik
2021-05-15 16:32:01 +02:00
committed by Benoit Daloze
parent 2eb6adbfb1
commit fa2182b2a4
4 changed files with 25 additions and 10 deletions
Generated Vendored
+10 -5
View File
@@ -44537,6 +44537,7 @@ module.exports = require("net");
"use strict";
__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__, "installBundler", function() { return installBundler; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bundleInstall", function() { return bundleInstall; });
@@ -44547,6 +44548,8 @@ const exec = __webpack_require__(514)
const cache = __webpack_require__(799)
const common = __webpack_require__(390)
const DEFAULT_CACHE_VERSION = '0'
// The returned gemfile is guaranteed to exist, the lockfile might not exist
function detectGemfiles() {
const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile'
@@ -44637,7 +44640,7 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
return bundlerVersion
}
async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, bundlerVersion) {
async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, bundlerVersion, cacheVersion) {
if (gemfile === null) {
console.log('Could not determine gemfile path, skipping "bundle install" and caching')
return false
@@ -44670,7 +44673,7 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
// cache key
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)}`
// If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below
const restoreKeys = [`${baseKey}-`]
@@ -44719,8 +44722,9 @@ async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, b
return true
}
async function computeBaseKey(platform, engine, version, lockFile) {
let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}`
async function computeBaseKey(platform, engine, version, lockFile, cacheVersion) {
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)) {
let revision = '';
@@ -52071,6 +52075,7 @@ const inputDefaults = {
'bundler': 'default',
'bundler-cache': 'true',
'working-directory': '.',
'cache-version': bundler.DEFAULT_CACHE_VERSION,
}
// entry point when this action is run on its own
@@ -52126,7 +52131,7 @@ async function setupRuby(options = {}) {
if (inputs['bundler-cache'] === 'true') {
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']))
}
}