Skip to content

Commit

Permalink
fix: strange bug on cache dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Dec 14, 2023
1 parent ce42f0d commit 01c6cb8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
11 changes: 6 additions & 5 deletions gh_action/dist/main/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions gh_action/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import * as tc from "@actions/tool-cache";
import * as cache from "@actions/cache";
import * as exec from "@actions/exec";
import * as path from "path";
import * as util from "util";
import * as os from "os";
import crypto from "crypto";
import { info } from "console";

// TODO: auto-manage this version
const DENO_VERSION = "1.38.5";
Expand Down Expand Up @@ -94,9 +92,11 @@ async function run(): Promise<void> {

const envsDir = core.toPlatformPath(path.resolve(ghjkDir, "envs"));
const cacheDirs = [envsDir];
await cache.restoreCache(cacheDirs, key);
core.info(JSON.stringify({ cacheDirs, envsDir, ghjkDir }));
// NOTE: restoreCache modifies the array it's given for some reason
await cache.restoreCache([...cacheDirs], key);
if (inputCacheSaveIf == "true") {
core.info(`enabling cache with key ${key}`);
core.info(`enabling cache with key ${key}: [${cacheDirs}]`);
core.saveState("ghjk-cache-save", true);
core.saveState("ghjk-post-args", {
key,
Expand Down Expand Up @@ -145,7 +145,7 @@ export async function installGhjk(
core.debug(`unable to find cached ghjk tool under version ${version}`);
}
}
core.debug(`installing ghjk using install.sh`);
core.debug(`installing ghjk using install.ts`);

const installDir = process.env["GHJK_INSTALL_EXE_DIR"] ??
core.toPlatformPath(path.resolve(os.homedir(), ".local", "bin"));
Expand All @@ -159,7 +159,7 @@ export async function installGhjk(
// which won't be the same after tool cache restore
env["GHJK_INSTALL_DENO_EXEC"] = "deno";

core.debug(util.inspect({ denoExec, env }, false, undefined, false));
core.debug(JSON.stringify({ denoExec, env }, undefined, " "));
await exec.exec(`"${denoExec}" run -A`, [installerUrl], { env });
if (version) {
return await tc.cacheDir(installDir, "ghjk", version);
Expand Down
2 changes: 1 addition & 1 deletion gh_action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"scripts": {
"lint": "pnpm dlx eslint . -c ./.github/linters/.eslintrc.yml",
"build:main": "ncc build main.ts -o dist/main .",
"build:main": "ncc build main.ts -o dist/main",
"build:main:watch": "ncc build main.ts -w -o dist/main",
"build:post": "ncc build post.ts -o dist/post",
"build:post:watch": "ncc build post.ts -w -o dist/post"
Expand Down

0 comments on commit 01c6cb8

Please sign in to comment.