From 2c572d755635fcea11f62f8a068d0ac0283446cb Mon Sep 17 00:00:00 2001 From: Quint Daenen Date: Tue, 30 Apr 2024 09:31:51 +0200 Subject: [PATCH] Fix DFX cache path. --- dist/cache-save/index.js | 5 +++-- dist/setup/index.js | 3 ++- src/cache-paths.ts | 3 ++- src/cache-save.ts | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 058cf6a..bacae53 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -79477,6 +79477,7 @@ const core_1 = __nccwpck_require__(2186); const os_1 = __nccwpck_require__(2037); const fs_1 = __nccwpck_require__(7147); const glob_1 = __nccwpck_require__(8090); +const child_process_1 = __nccwpck_require__(2081); function resolveDFXVersion() { const dfxVersion = (0, core_1.getInput)('dfx-version'); const dfxFilePath = (0, core_1.getInput)('dfx-version-file'); @@ -79501,7 +79502,7 @@ exports.resolveDFXVersion = resolveDFXVersion; function getCachePaths() { let cachePaths = []; if ((0, core_1.getInput)("dfx-version") || (0, core_1.getInput)("dfx-version-file")) { - cachePaths.push(`${process.env.GITHUB_WORKSPACE}/.cache/dfinity`); + cachePaths.push((0, child_process_1.execSync)("dfx cache show").toString().trim()); cachePaths.push(`${process.env.GITHUB_WORKSPACE}/.dfx`); } if ((0, core_1.getInput)("vessel-version")) { @@ -79612,7 +79613,7 @@ const cacheDFX = () => __awaiter(void 0, void 0, void 0, function* () { logWarning(`Some cache paths do not exist: ${nonExistendPaths.join(', ')}`); } if (primaryKey === state) { - core.info(`Cache key is the same as the previous run. Skipping cache save.`); + core.info(`Cache key (${primaryKey}) is the same as the previous run. Skipping cache save.`); return; } const cacheID = yield cache.saveCache(cachePaths, primaryKey); diff --git a/dist/setup/index.js b/dist/setup/index.js index 55da00f..560307b 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -82756,6 +82756,7 @@ const core_1 = __nccwpck_require__(2186); const os_1 = __nccwpck_require__(2037); const fs_1 = __nccwpck_require__(7147); const glob_1 = __nccwpck_require__(8090); +const child_process_1 = __nccwpck_require__(2081); function resolveDFXVersion() { const dfxVersion = (0, core_1.getInput)('dfx-version'); const dfxFilePath = (0, core_1.getInput)('dfx-version-file'); @@ -82780,7 +82781,7 @@ exports.resolveDFXVersion = resolveDFXVersion; function getCachePaths() { let cachePaths = []; if ((0, core_1.getInput)("dfx-version") || (0, core_1.getInput)("dfx-version-file")) { - cachePaths.push(`${process.env.GITHUB_WORKSPACE}/.cache/dfinity`); + cachePaths.push((0, child_process_1.execSync)("dfx cache show").toString().trim()); cachePaths.push(`${process.env.GITHUB_WORKSPACE}/.dfx`); } if ((0, core_1.getInput)("vessel-version")) { diff --git a/src/cache-paths.ts b/src/cache-paths.ts index a9d30c1..184a9f2 100644 --- a/src/cache-paths.ts +++ b/src/cache-paths.ts @@ -2,6 +2,7 @@ import {getInput, warning} from '@actions/core'; import { platform } from 'os'; import { existsSync, readFileSync } from 'fs'; import { hashFiles } from '@actions/glob'; +import { execSync } from 'child_process'; export function resolveDFXVersion(): string | undefined { const dfxVersion = getInput('dfx-version'); @@ -32,7 +33,7 @@ export function resolveDFXVersion(): string | undefined { export function getCachePaths(): string[] { let cachePaths: string[] = []; if (getInput("dfx-version") || getInput("dfx-version-file")) { - cachePaths.push(`${process.env.HOME}/.cache/dfinity`); + cachePaths.push(execSync("dfx cache show").toString().trim()); cachePaths.push(`${process.env.GITHUB_WORKSPACE}/.dfx`); } if (getInput("vessel-version")) { diff --git a/src/cache-save.ts b/src/cache-save.ts index 5321032..c9cf06c 100644 --- a/src/cache-save.ts +++ b/src/cache-save.ts @@ -48,7 +48,7 @@ const cacheDFX = async () => { } if (primaryKey === state) { - core.info(`Cache key is the same as the previous run. Skipping cache save.`); + core.info(`Cache key (${primaryKey}) is the same as the previous run. Skipping cache save.`); return; }