mirror of
https://github.com/actions/cache.git
synced 2024-12-01 14:22:24 +08:00
Compare commits
1 Commits
e60ad5c987
...
707ad40d6c
Author | SHA1 | Date | |
---|---|---|---|
|
707ad40d6c |
@ -8,26 +8,17 @@ import * as testUtils from "../src/utils/testUtils";
|
|||||||
jest.mock("@actions/core");
|
jest.mock("@actions/core");
|
||||||
jest.mock("@actions/cache");
|
jest.mock("@actions/cache");
|
||||||
|
|
||||||
let pristineEnv: NodeJS.ProcessEnv;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
pristineEnv = process.env;
|
|
||||||
jest.spyOn(core, "getInput").mockImplementation((name, options) => {
|
jest.spyOn(core, "getInput").mockImplementation((name, options) => {
|
||||||
return jest.requireActual("@actions/core").getInput(name, options);
|
return jest.requireActual("@actions/core").getInput(name, options);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
afterEach(() => {
|
||||||
jest.resetModules();
|
|
||||||
process.env = pristineEnv;
|
|
||||||
delete process.env[Events.Key];
|
delete process.env[Events.Key];
|
||||||
delete process.env[RefKey];
|
delete process.env[RefKey];
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
process.env = pristineEnv;
|
|
||||||
});
|
|
||||||
|
|
||||||
test("isGhes returns true if server url is not github.com", () => {
|
test("isGhes returns true if server url is not github.com", () => {
|
||||||
try {
|
try {
|
||||||
process.env["GITHUB_SERVER_URL"] = "http://example.com";
|
process.env["GITHUB_SERVER_URL"] = "http://example.com";
|
||||||
@ -240,28 +231,3 @@ test("isCacheFeatureAvailable for ac disabled on dotcom", () => {
|
|||||||
delete process.env["GITHUB_SERVER_URL"];
|
delete process.env["GITHUB_SERVER_URL"];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("isGhes returns false when the GITHUB_SERVER_URL environment variable is not defined", async () => {
|
|
||||||
delete process.env["GITHUB_SERVER_URL"];
|
|
||||||
expect(actionUtils.isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("isGhes returns false when the GITHUB_SERVER_URL environment variable is set to github.com", async () => {
|
|
||||||
process.env["GITHUB_SERVER_URL"] = "https://github.com";
|
|
||||||
expect(actionUtils.isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("isGhes returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL", async () => {
|
|
||||||
process.env["GITHUB_SERVER_URL"] = "https://contoso.ghe.com";
|
|
||||||
expect(actionUtils.isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("isGhes returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix", async () => {
|
|
||||||
process.env["GITHUB_SERVER_URL"] = "https://mock-github.localhost";
|
|
||||||
expect(actionUtils.isGhes()).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("isGhes returns true when the GITHUB_SERVER_URL environment variable is set to some other URL", async () => {
|
|
||||||
process.env["GITHUB_SERVER_URL"] = "https://src.onpremise.fabrikam.com";
|
|
||||||
expect(actionUtils.isGhes()).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
6
dist/restore-only/index.js
vendored
6
dist/restore-only/index.js
vendored
@ -59586,11 +59586,7 @@ const core = __importStar(__nccwpck_require__(2186));
|
|||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com");
|
const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com");
|
||||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
|
||||||
const isGitHubHost = hostname === "GITHUB.COM";
|
|
||||||
const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM");
|
|
||||||
const isLocalHost = hostname.endsWith(".LOCALHOST");
|
|
||||||
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isExactKeyMatch(key, cacheKey) {
|
function isExactKeyMatch(key, cacheKey) {
|
||||||
|
6
dist/restore/index.js
vendored
6
dist/restore/index.js
vendored
@ -59586,11 +59586,7 @@ const core = __importStar(__nccwpck_require__(2186));
|
|||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com");
|
const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com");
|
||||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
|
||||||
const isGitHubHost = hostname === "GITHUB.COM";
|
|
||||||
const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM");
|
|
||||||
const isLocalHost = hostname.endsWith(".LOCALHOST");
|
|
||||||
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isExactKeyMatch(key, cacheKey) {
|
function isExactKeyMatch(key, cacheKey) {
|
||||||
|
6
dist/save-only/index.js
vendored
6
dist/save-only/index.js
vendored
@ -59599,11 +59599,7 @@ const core = __importStar(__nccwpck_require__(2186));
|
|||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com");
|
const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com");
|
||||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
|
||||||
const isGitHubHost = hostname === "GITHUB.COM";
|
|
||||||
const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM");
|
|
||||||
const isLocalHost = hostname.endsWith(".LOCALHOST");
|
|
||||||
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isExactKeyMatch(key, cacheKey) {
|
function isExactKeyMatch(key, cacheKey) {
|
||||||
|
6
dist/save/index.js
vendored
6
dist/save/index.js
vendored
@ -59599,11 +59599,7 @@ const core = __importStar(__nccwpck_require__(2186));
|
|||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com");
|
const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com");
|
||||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
|
||||||
const isGitHubHost = hostname === "GITHUB.COM";
|
|
||||||
const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM");
|
|
||||||
const isLocalHost = hostname.endsWith(".LOCALHOST");
|
|
||||||
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isExactKeyMatch(key, cacheKey) {
|
function isExactKeyMatch(key, cacheKey) {
|
||||||
|
@ -7,13 +7,7 @@ export function isGhes(): boolean {
|
|||||||
const ghUrl = new URL(
|
const ghUrl = new URL(
|
||||||
process.env["GITHUB_SERVER_URL"] || "https://github.com"
|
process.env["GITHUB_SERVER_URL"] || "https://github.com"
|
||||||
);
|
);
|
||||||
|
return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
|
||||||
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
|
||||||
const isGitHubHost = hostname === "GITHUB.COM";
|
|
||||||
const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM");
|
|
||||||
const isLocalHost = hostname.endsWith(".LOCALHOST");
|
|
||||||
|
|
||||||
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isExactKeyMatch(key: string, cacheKey?: string): boolean {
|
export function isExactKeyMatch(key: string, cacheKey?: string): boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user