diff --git a/package-lock.json b/package-lock.json index 26fc79e..7024a0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@actions/exec": "^1.1.1", "@actions/http-client": "^2.2.3", "@actions/tool-cache": "^2.0.2", - "@google-github-actions/actions-utils": "^0.8.9", + "@google-github-actions/actions-utils": "^1.0.0", "semver": "^7.7.2" }, "devDependencies": { @@ -34,8 +34,8 @@ "typescript-eslint": "^8.40.0" }, "engines": { - "node": "20.x", - "npm": ">= 10.x" + "node": ">= 24.x", + "npm": ">= 11.x" } }, "node_modules/@actions/core": { @@ -260,9 +260,9 @@ } }, "node_modules/@google-github-actions/actions-utils": { - "version": "0.8.9", - "resolved": "https://registry.npmjs.org/@google-github-actions/actions-utils/-/actions-utils-0.8.9.tgz", - "integrity": "sha512-2bCdbHpUHK3WIxVkNCfYyPDH9MgDHFhw5kuUuM/TKJFwxSJnGfVKoukeAd5DmTV+CL59mzbSR3PKwAnGJi8yOQ==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@google-github-actions/actions-utils/-/actions-utils-1.0.0.tgz", + "integrity": "sha512-azTb8xdCjfN+lzs+w2e34kvXel9rDQlr4UVZ2BX48WzThcodJPQXx9yRKpNoKsYHIGJSWrpKWYq2QFQWZ7/pAw==", "license": "Apache-2.0", "dependencies": { "yaml": "^2.8.1" @@ -271,8 +271,8 @@ "actions-gen-readme": "bin/actions-gen-readme.mjs" }, "engines": { - "node": ">= 20.x", - "npm": ">= 10.x" + "node": ">= 24.x", + "npm": ">= 11.x" } }, "node_modules/@humanfs/core": { diff --git a/package.json b/package.json index af26db3..829013d 100644 --- a/package.json +++ b/package.json @@ -6,15 +6,15 @@ "main": "dist/index.js", "types": "dist/index.d.js", "engines": { - "node": ">= 20.x", - "npm": ">= 10.x" + "node": ">= 24.x", + "npm": ">= 11.x" }, "scripts": { "build": "rm -rf dist/ && ncc build --source-map --no-source-map-register src/index.ts", "lint": "eslint .", "format": "eslint --fix", "docs": "rm -rf docs/ && typedoc --plugin typedoc-plugin-markdown", - "test": "node --require ts-node/register --test-reporter spec --test tests/download-util.test.ts tests/format-url.test.ts tests/index.test.ts" + "test": "node --require ts-node/register --test-reporter spec --test tests/**/*.test.ts" }, "files": [ "dist/**/*" @@ -35,7 +35,7 @@ "@actions/exec": "^1.1.1", "@actions/http-client": "^2.2.3", "@actions/tool-cache": "^2.0.2", - "@google-github-actions/actions-utils": "^0.8.9", + "@google-github-actions/actions-utils": "^1.0.0", "semver": "^7.7.2" }, "devDependencies": { diff --git a/src/index.ts b/src/index.ts index cf04400..c609706 100644 --- a/src/index.ts +++ b/src/index.ts @@ -165,7 +165,10 @@ export async function isAuthenticated(): Promise { * specification is installed. * @returns The path of the installed tool. */ -export async function installGcloudSDK(version: string, skipToolCache?: boolean): Promise { +export async function installGcloudSDK( + version: string, + useToolCache: boolean = false, +): Promise { // Retrieve the release corresponding to the specified version and OS const osPlat = os.platform(); const osArch = os.arch(); @@ -181,22 +184,23 @@ export async function installGcloudSDK(version: string, skipToolCache?: boolean) } // Either cache the tool or just add it directly to the path. - if (skipToolCache) { - // Caching the tool on disk takes a really long time, and it's not clear - // whether it's even valuable since it's ONLY cached on disk on the runner. - // For GitHub-managed runners, that is useless since they are ephemeral. - // - // See https://github.com/google-github-actions/setup-gcloud/issues/701 for - // discussion, but it's actually faster to skip the caching and just add the - // tool directly to the path. - const toolRoot = path.join(extPath, 'google-cloud-sdk'); - core.addPath(path.join(toolRoot, 'bin')); - return toolRoot; - } else { + // + // Caching the tool on disk takes a really long time, and it's not clear + // whether it's even valuable since it's ONLY cached on disk on the runner. + // For GitHub-managed runners, that is useless since they are ephemeral. + // + // See https://github.com/google-github-actions/setup-gcloud/issues/701 for + // discussion, but it's actually faster to skip the caching and just add the + // tool directly to the path. + if (useToolCache) { const toolRoot = path.join(extPath, 'google-cloud-sdk'); const cachedToolRoot = await toolCache.cacheDir(toolRoot, 'gcloud', resolvedVersion, osArch); core.addPath(path.join(cachedToolRoot, 'bin')); return cachedToolRoot; + } else { + const toolRoot = path.join(extPath, 'google-cloud-sdk'); + core.addPath(path.join(toolRoot, 'bin')); + return toolRoot; } } diff --git a/tests/index.test.ts b/tests/index.test.ts index a16b07d..0839b35 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -67,7 +67,7 @@ test('#setupCloudSDK', { concurrency: true }, async (suite) => { t.before(async () => { await TestToolCache.start(); const version = await setupCloudSDK.getLatestGcloudSDKVersion(); - await setupCloudSDK.installGcloudSDK(version); + await setupCloudSDK.installGcloudSDK(version, true); }); t.beforeEach(async () => {