fix: add install_args
hash to cache key (#136)
* fix: add install_args hash to cache key * fix: sort tools before hashing
This commit is contained in:
parent
4d056cf31b
commit
f2a7466821
3 changed files with 27 additions and 1 deletions
13
dist/index.js
generated
vendored
13
dist/index.js
generated
vendored
|
@ -62425,6 +62425,7 @@ const io = __importStar(__nccwpck_require__(4994));
|
|||
const core = __importStar(__nccwpck_require__(7484));
|
||||
const exec = __importStar(__nccwpck_require__(5236));
|
||||
const glob = __importStar(__nccwpck_require__(7206));
|
||||
const crypto = __importStar(__nccwpck_require__(6982));
|
||||
const fs = __importStar(__nccwpck_require__(9896));
|
||||
const os = __importStar(__nccwpck_require__(857));
|
||||
const path = __importStar(__nccwpck_require__(6928));
|
||||
|
@ -62476,6 +62477,7 @@ async function setEnvVars() {
|
|||
async function restoreMiseCache() {
|
||||
core.startGroup('Restoring mise cache');
|
||||
const version = core.getInput('version');
|
||||
const installArgs = core.getInput('install_args');
|
||||
const cachePath = (0, utils_1.miseDir)();
|
||||
const fileHash = await glob.hashFiles([
|
||||
`**/.config/mise/config.toml`,
|
||||
|
@ -62497,6 +62499,17 @@ async function restoreMiseCache() {
|
|||
if (version) {
|
||||
primaryKey = `${primaryKey}-${version}`;
|
||||
}
|
||||
if (installArgs) {
|
||||
const tools = installArgs
|
||||
.split(' ')
|
||||
.filter(arg => !arg.startsWith('-'))
|
||||
.sort()
|
||||
.join(' ');
|
||||
if (tools) {
|
||||
const toolsHash = crypto.createHash('sha256').update(tools).digest('hex');
|
||||
primaryKey = `${primaryKey}-${toolsHash}`;
|
||||
}
|
||||
}
|
||||
core.saveState('CACHE', core.getBooleanInput('cache_save'));
|
||||
core.saveState('PRIMARY_KEY', primaryKey);
|
||||
core.saveState('MISE_DIR', cachePath);
|
||||
|
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
13
src/index.ts
13
src/index.ts
|
@ -3,6 +3,7 @@ import * as io from '@actions/io'
|
|||
import * as core from '@actions/core'
|
||||
import * as exec from '@actions/exec'
|
||||
import * as glob from '@actions/glob'
|
||||
import * as crypto from 'crypto'
|
||||
import * as fs from 'fs'
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
|
@ -56,6 +57,7 @@ async function setEnvVars(): Promise<void> {
|
|||
async function restoreMiseCache(): Promise<void> {
|
||||
core.startGroup('Restoring mise cache')
|
||||
const version = core.getInput('version')
|
||||
const installArgs = core.getInput('install_args')
|
||||
const cachePath = miseDir()
|
||||
const fileHash = await glob.hashFiles(
|
||||
[
|
||||
|
@ -79,6 +81,17 @@ async function restoreMiseCache(): Promise<void> {
|
|||
if (version) {
|
||||
primaryKey = `${primaryKey}-${version}`
|
||||
}
|
||||
if (installArgs) {
|
||||
const tools = installArgs
|
||||
.split(' ')
|
||||
.filter(arg => !arg.startsWith('-'))
|
||||
.sort()
|
||||
.join(' ')
|
||||
if (tools) {
|
||||
const toolsHash = crypto.createHash('sha256').update(tools).digest('hex')
|
||||
primaryKey = `${primaryKey}-${toolsHash}`
|
||||
}
|
||||
}
|
||||
|
||||
core.saveState('CACHE', core.getBooleanInput('cache_save'))
|
||||
core.saveState('PRIMARY_KEY', primaryKey)
|
||||
|
|
Loading…
Add table
Reference in a new issue