3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2026-08-07 03:53:42 +00:00

Allow configured env fallback for GCS bucket

This commit is contained in:
Jasperhino 2026-05-22 08:13:30 +02:00
parent 993ce21c74
commit 2f176eae24
9 changed files with 51 additions and 8 deletions

View file

@ -207,11 +207,13 @@ test("getGCSBucket returns gcs-bucket input when provided", () => {
try {
testUtils.setInput("gcs-bucket", "input-bucket");
process.env["CULA_CACHE_GCS_BUCKET"] = "env-bucket";
process.env["CONFIGURED_GCS_BUCKET"] = "configured-bucket";
expect(actionUtils.getGCSBucket()).toBe("input-bucket");
} finally {
testUtils.clearInputs();
delete process.env["CULA_CACHE_GCS_BUCKET"];
delete process.env["CONFIGURED_GCS_BUCKET"];
}
});
@ -225,15 +227,39 @@ test("getGCSBucket falls back to CULA_CACHE_GCS_BUCKET", () => {
}
});
test("getGCSBucket falls back to CONFIGURED_GCS_BUCKET", () => {
try {
process.env["CONFIGURED_GCS_BUCKET"] = "configured-bucket";
expect(actionUtils.getGCSBucket()).toBe("configured-bucket");
} finally {
delete process.env["CONFIGURED_GCS_BUCKET"];
}
});
test("getGCSBucket prefers CULA_CACHE_GCS_BUCKET over CONFIGURED_GCS_BUCKET", () => {
try {
process.env["CULA_CACHE_GCS_BUCKET"] = "env-bucket";
process.env["CONFIGURED_GCS_BUCKET"] = "configured-bucket";
expect(actionUtils.getGCSBucket()).toBe("env-bucket");
} finally {
delete process.env["CULA_CACHE_GCS_BUCKET"];
delete process.env["CONFIGURED_GCS_BUCKET"];
}
});
test("getGCSBucket returns empty string without input or environment variable", () => {
try {
testUtils.clearInputs();
delete process.env["CULA_CACHE_GCS_BUCKET"];
delete process.env["CONFIGURED_GCS_BUCKET"];
expect(actionUtils.getGCSBucket()).toBe("");
} finally {
testUtils.clearInputs();
delete process.env["CULA_CACHE_GCS_BUCKET"];
delete process.env["CONFIGURED_GCS_BUCKET"];
}
});

View file

@ -27,7 +27,7 @@ inputs:
default: 'false'
required: false
gcs-bucket:
description: 'Google Cloud Storage bucket name to use for caching. When provided, GCS will be used as the cache backend. Defaults to the CULA_CACHE_GCS_BUCKET environment variable when omitted.'
description: 'Google Cloud Storage bucket name to use for caching. When provided, GCS will be used as the cache backend. Defaults to the CULA_CACHE_GCS_BUCKET or CONFIGURED_GCS_BUCKET environment variable when omitted.'
required: false
gcs-path-prefix:
description: 'Optional prefix path within the GCS bucket for cache files'

View file

@ -78376,7 +78376,10 @@ function getInputAsBool(name, options) {
return result.toLowerCase() === "true";
}
function getGCSBucket() {
return core.getInput(constants_1.Inputs.GCSBucket) || process.env["CULA_CACHE_GCS_BUCKET"] || "";
return (core.getInput(constants_1.Inputs.GCSBucket) ||
process.env["CULA_CACHE_GCS_BUCKET"] ||
process.env["CONFIGURED_GCS_BUCKET"] ||
"");
}
// Check if GCS is configured and available
function isGCSAvailable() {

View file

@ -78376,7 +78376,10 @@ function getInputAsBool(name, options) {
return result.toLowerCase() === "true";
}
function getGCSBucket() {
return core.getInput(constants_1.Inputs.GCSBucket) || process.env["CULA_CACHE_GCS_BUCKET"] || "";
return (core.getInput(constants_1.Inputs.GCSBucket) ||
process.env["CULA_CACHE_GCS_BUCKET"] ||
process.env["CONFIGURED_GCS_BUCKET"] ||
"");
}
// Check if GCS is configured and available
function isGCSAvailable() {

View file

@ -78389,7 +78389,10 @@ function getInputAsBool(name, options) {
return result.toLowerCase() === "true";
}
function getGCSBucket() {
return core.getInput(constants_1.Inputs.GCSBucket) || process.env["CULA_CACHE_GCS_BUCKET"] || "";
return (core.getInput(constants_1.Inputs.GCSBucket) ||
process.env["CULA_CACHE_GCS_BUCKET"] ||
process.env["CONFIGURED_GCS_BUCKET"] ||
"");
}
// Check if GCS is configured and available
function isGCSAvailable() {

5
dist/save/index.js vendored
View file

@ -78389,7 +78389,10 @@ function getInputAsBool(name, options) {
return result.toLowerCase() === "true";
}
function getGCSBucket() {
return core.getInput(constants_1.Inputs.GCSBucket) || process.env["CULA_CACHE_GCS_BUCKET"] || "";
return (core.getInput(constants_1.Inputs.GCSBucket) ||
process.env["CULA_CACHE_GCS_BUCKET"] ||
process.env["CONFIGURED_GCS_BUCKET"] ||
"");
}
// Check if GCS is configured and available
function isGCSAvailable() {

View file

@ -24,7 +24,7 @@ inputs:
default: 'false'
required: false
gcs-bucket:
description: 'Google Cloud Storage bucket name to use for caching. When provided, GCS will be used as the cache backend. Defaults to the CULA_CACHE_GCS_BUCKET environment variable when omitted.'
description: 'Google Cloud Storage bucket name to use for caching. When provided, GCS will be used as the cache backend. Defaults to the CULA_CACHE_GCS_BUCKET or CONFIGURED_GCS_BUCKET environment variable when omitted.'
required: false
gcs-path-prefix:
description: 'Optional prefix path within the GCS bucket for cache files'

View file

@ -16,7 +16,7 @@ inputs:
default: 'false'
required: false
gcs-bucket:
description: 'Google Cloud Storage bucket name to use for caching. When provided, GCS will be used as the cache backend. Defaults to the CULA_CACHE_GCS_BUCKET environment variable when omitted.'
description: 'Google Cloud Storage bucket name to use for caching. When provided, GCS will be used as the cache backend. Defaults to the CULA_CACHE_GCS_BUCKET or CONFIGURED_GCS_BUCKET environment variable when omitted.'
required: false
gcs-path-prefix:
description: 'Optional prefix path within the GCS bucket for cache files'

View file

@ -67,7 +67,12 @@ export function getInputAsBool(
}
export function getGCSBucket(): string {
return core.getInput(Inputs.GCSBucket) || process.env["CULA_CACHE_GCS_BUCKET"] || "";
return (
core.getInput(Inputs.GCSBucket) ||
process.env["CULA_CACHE_GCS_BUCKET"] ||
process.env["CONFIGURED_GCS_BUCKET"] ||
""
);
}
// Check if GCS is configured and available