diff --git a/dist/index/index.js b/dist/index/index.js index ecd0fc3..1fb2bd8 100644 --- a/dist/index/index.js +++ b/dist/index/index.js @@ -27002,7 +27002,7 @@ var external_path_ = __nccwpck_require__(1017); // EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js var core = __nccwpck_require__(2186); // EXTERNAL MODULE: ./node_modules/@actions/exec/lib/exec.js -var lib_exec = __nccwpck_require__(1514); +var exec = __nccwpck_require__(1514); // EXTERNAL MODULE: ./node_modules/@actions/io/lib/io.js var io = __nccwpck_require__(7436); ;// CONCATENATED MODULE: ./src/utils.ts @@ -27057,7 +27057,7 @@ const Input_Path = "path"; const Input_Cache = "cache"; const Input_FailOnCacheMiss = "fail-on-cache-miss"; const Output_CacheHit = "cache-hit"; -const ActionVersion = "nscloud-action-cache@v4"; +const ActionVersion = "nscloud-action-cache@v1"; void main(); async function main() { const localCachePath = process.env[Env_CacheRoot]; @@ -27079,14 +27079,19 @@ async function main() { else { core.info(`All cache paths found and restored.`); } + // Write/update cache volume metadata file let metadata = await ensureCacheMetadata(localCachePath); metadata.updatedAt = new Date().toISOString(); metadata.version = 1; if (!metadata.userRequest) { metadata.userRequest = {}; } + if (!metadata.preExecution) { + metadata.preExecution = { usage: {} }; + } for (const p of cachePaths) { metadata.userRequest[p.pathInCache] = { cacheFramework: p.framework, mountTarget: [p.mountTarget], source: ActionVersion }; + metadata.preExecution.usage[p.pathInCache] = await getCacheUtil(p.pathInCache); } writeCacheMetadata(localCachePath, metadata); const cacheUtilInfo = await getCacheSummaryUtil(localCachePath); @@ -27104,7 +27109,7 @@ async function restoreLocalCache(cachePaths) { const expandedFilePath = resolveHome(p.mountTarget); await io.mkdirP(expandedFilePath); await io.mkdirP(p.pathInCache); - await lib_exec.exec(`sudo mount --bind ${p.pathInCache} ${expandedFilePath}`); + await exec.exec(`sudo mount --bind ${p.pathInCache} ${expandedFilePath}`); } return cacheMisses; } @@ -27171,13 +27176,13 @@ async function resolveCacheMode(cacheMode) { } } async function getExecStdout(cmd) { - const { stdout } = await lib_exec.getExecOutput(cmd, [], { + const { stdout } = await exec.getExecOutput(cmd, [], { silent: true, }); return stdout.trim(); } async function getCacheSummaryUtil(cachePath) { - const { stdout } = await lib_exec.getExecOutput(`/bin/sh -c "df -h ${cachePath} | awk 'FNR == 2 {print $2,$3}'"`, [], { + const { stdout } = await exec.getExecOutput(`/bin/sh -c "df -h ${cachePath} | awk 'FNR == 2 {print $2,$3}'"`, [], { silent: true, ignoreReturnCode: true, }); diff --git a/src/index.ts b/src/index.ts index b5c6863..4499ef6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,7 @@ const Input_Path = "path"; const Input_Cache = "cache"; const Input_FailOnCacheMiss = "fail-on-cache-miss"; const Output_CacheHit = "cache-hit"; -const ActionVersion = "nscloud-action-cache@v4"; +const ActionVersion = "nscloud-action-cache@v1"; void main(); @@ -47,15 +47,20 @@ async function main() { core.info(`All cache paths found and restored.`); } + // Write/update cache volume metadata file let metadata = await utils.ensureCacheMetadata(localCachePath); metadata.updatedAt = new Date().toISOString(); metadata.version = 1; if (!metadata.userRequest) { metadata.userRequest = {}; } + if (!metadata.preExecution) { + metadata.preExecution = {usage: {}}; + } for (const p of cachePaths) { metadata.userRequest[p.pathInCache] = {cacheFramework: p.framework, mountTarget: [p.mountTarget], source: ActionVersion}; + metadata.preExecution.usage[p.pathInCache] = await utils.getCacheUtil(p.pathInCache); } utils.writeCacheMetadata(localCachePath, metadata);