Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*"
Expand All @@ -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": {
Expand Down
30 changes: 17 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ export async function isAuthenticated(): Promise<boolean> {
* specification is installed.
* @returns The path of the installed tool.
*/
export async function installGcloudSDK(version: string, skipToolCache?: boolean): Promise<string> {
export async function installGcloudSDK(
version: string,
useToolCache: boolean = false,
): Promise<string> {
// Retrieve the release corresponding to the specified version and OS
const osPlat = os.platform();
const osArch = os.arch();
Expand All @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Loading