mirror of https://github.com/actions/cache
Allow configured env fallback for GCS bucket
This commit is contained in:
parent
993ce21c74
commit
2f176eae24
|
|
@ -207,11 +207,13 @@ test("getGCSBucket returns gcs-bucket input when provided", () => {
|
||||||
try {
|
try {
|
||||||
testUtils.setInput("gcs-bucket", "input-bucket");
|
testUtils.setInput("gcs-bucket", "input-bucket");
|
||||||
process.env["CULA_CACHE_GCS_BUCKET"] = "env-bucket";
|
process.env["CULA_CACHE_GCS_BUCKET"] = "env-bucket";
|
||||||
|
process.env["CONFIGURED_GCS_BUCKET"] = "configured-bucket";
|
||||||
|
|
||||||
expect(actionUtils.getGCSBucket()).toBe("input-bucket");
|
expect(actionUtils.getGCSBucket()).toBe("input-bucket");
|
||||||
} finally {
|
} finally {
|
||||||
testUtils.clearInputs();
|
testUtils.clearInputs();
|
||||||
delete process.env["CULA_CACHE_GCS_BUCKET"];
|
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", () => {
|
test("getGCSBucket returns empty string without input or environment variable", () => {
|
||||||
try {
|
try {
|
||||||
testUtils.clearInputs();
|
testUtils.clearInputs();
|
||||||
delete process.env["CULA_CACHE_GCS_BUCKET"];
|
delete process.env["CULA_CACHE_GCS_BUCKET"];
|
||||||
|
delete process.env["CONFIGURED_GCS_BUCKET"];
|
||||||
|
|
||||||
expect(actionUtils.getGCSBucket()).toBe("");
|
expect(actionUtils.getGCSBucket()).toBe("");
|
||||||
} finally {
|
} finally {
|
||||||
testUtils.clearInputs();
|
testUtils.clearInputs();
|
||||||
delete process.env["CULA_CACHE_GCS_BUCKET"];
|
delete process.env["CULA_CACHE_GCS_BUCKET"];
|
||||||
|
delete process.env["CONFIGURED_GCS_BUCKET"];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ inputs:
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
gcs-bucket:
|
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
|
required: false
|
||||||
gcs-path-prefix:
|
gcs-path-prefix:
|
||||||
description: 'Optional prefix path within the GCS bucket for cache files'
|
description: 'Optional prefix path within the GCS bucket for cache files'
|
||||||
|
|
|
||||||
|
|
@ -78376,7 +78376,10 @@ function getInputAsBool(name, options) {
|
||||||
return result.toLowerCase() === "true";
|
return result.toLowerCase() === "true";
|
||||||
}
|
}
|
||||||
function getGCSBucket() {
|
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
|
// Check if GCS is configured and available
|
||||||
function isGCSAvailable() {
|
function isGCSAvailable() {
|
||||||
|
|
|
||||||
|
|
@ -78376,7 +78376,10 @@ function getInputAsBool(name, options) {
|
||||||
return result.toLowerCase() === "true";
|
return result.toLowerCase() === "true";
|
||||||
}
|
}
|
||||||
function getGCSBucket() {
|
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
|
// Check if GCS is configured and available
|
||||||
function isGCSAvailable() {
|
function isGCSAvailable() {
|
||||||
|
|
|
||||||
|
|
@ -78389,7 +78389,10 @@ function getInputAsBool(name, options) {
|
||||||
return result.toLowerCase() === "true";
|
return result.toLowerCase() === "true";
|
||||||
}
|
}
|
||||||
function getGCSBucket() {
|
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
|
// Check if GCS is configured and available
|
||||||
function isGCSAvailable() {
|
function isGCSAvailable() {
|
||||||
|
|
|
||||||
|
|
@ -78389,7 +78389,10 @@ function getInputAsBool(name, options) {
|
||||||
return result.toLowerCase() === "true";
|
return result.toLowerCase() === "true";
|
||||||
}
|
}
|
||||||
function getGCSBucket() {
|
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
|
// Check if GCS is configured and available
|
||||||
function isGCSAvailable() {
|
function isGCSAvailable() {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ inputs:
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
gcs-bucket:
|
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
|
required: false
|
||||||
gcs-path-prefix:
|
gcs-path-prefix:
|
||||||
description: 'Optional prefix path within the GCS bucket for cache files'
|
description: 'Optional prefix path within the GCS bucket for cache files'
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ inputs:
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
gcs-bucket:
|
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
|
required: false
|
||||||
gcs-path-prefix:
|
gcs-path-prefix:
|
||||||
description: 'Optional prefix path within the GCS bucket for cache files'
|
description: 'Optional prefix path within the GCS bucket for cache files'
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,12 @@ export function getInputAsBool(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGCSBucket(): string {
|
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
|
// Check if GCS is configured and available
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue