mirror of https://github.com/actions/cache.git
Compare commits
9 Commits
571d5327eb
...
93f976e2a4
Author | SHA1 | Date |
---|---|---|
Karl Horky | 93f976e2a4 | |
Bassem Dghaidi | e5dc90df92 | |
dependabot[bot] | 8585f2ac5c | |
Bassem Dghaidi | 9803087a86 | |
John Wesley Walker III | e7e2547a88 | |
John Wesley Walker III | 71d826cc33 | |
John Wesley Walker III | 25942a73ac | |
John Wesley Walker III | d73025053b | |
Karl Horky | 0e22a2cc98 |
|
@ -8,17 +8,26 @@ 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
beforeEach(() => {
|
||||||
|
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";
|
||||||
|
@ -231,3 +240,28 @@ 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();
|
||||||
|
});
|
||||||
|
|
|
@ -59586,7 +59586,11 @@ 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");
|
||||||
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;
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isExactKeyMatch(key, cacheKey) {
|
function isExactKeyMatch(key, cacheKey) {
|
||||||
|
|
|
@ -59586,7 +59586,11 @@ 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");
|
||||||
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;
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isExactKeyMatch(key, cacheKey) {
|
function isExactKeyMatch(key, cacheKey) {
|
||||||
|
|
|
@ -59599,7 +59599,11 @@ 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");
|
||||||
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;
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isExactKeyMatch(key, cacheKey) {
|
function isExactKeyMatch(key, cacheKey) {
|
||||||
|
|
|
@ -59599,7 +59599,11 @@ 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");
|
||||||
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;
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isExactKeyMatch(key, cacheKey) {
|
function isExactKeyMatch(key, cacheKey) {
|
||||||
|
|
17
examples.md
17
examples.md
|
@ -22,6 +22,7 @@
|
||||||
- [Java - Maven](#java---maven)
|
- [Java - Maven](#java---maven)
|
||||||
- [Node - npm](#node---npm)
|
- [Node - npm](#node---npm)
|
||||||
- [Node - Lerna](#node---lerna)
|
- [Node - Lerna](#node---lerna)
|
||||||
|
- [Node - pnpm](#node---pnpm)
|
||||||
- [Node - Yarn](#node---yarn)
|
- [Node - Yarn](#node---yarn)
|
||||||
- [Node - Yarn 2](#node---yarn-2)
|
- [Node - Yarn 2](#node---yarn-2)
|
||||||
- [OCaml/Reason - esy](#ocamlreason---esy)
|
- [OCaml/Reason - esy](#ocamlreason---esy)
|
||||||
|
@ -374,6 +375,22 @@ After [deprecation](https://github.blog/changelog/2022-10-11-github-actions-depr
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Node - pnpm
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Get pnpm store directory
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
name: Setup pnpm cache
|
||||||
|
with:
|
||||||
|
path: ${{ env.STORE_PATH }}
|
||||||
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pnpm-store-
|
||||||
|
```
|
||||||
|
|
||||||
## Node - Yarn
|
## Node - Yarn
|
||||||
The yarn cache directory will depend on your operating system and version of `yarn`. See https://yarnpkg.com/lang/en/docs/cli/cache/ for more info.
|
The yarn cache directory will depend on your operating system and version of `yarn`. See https://yarnpkg.com/lang/en/docs/cli/cache/ for more info.
|
||||||
|
|
||||||
|
|
|
@ -3521,12 +3521,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/braces": {
|
"node_modules/braces": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
||||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fill-range": "^7.0.1"
|
"fill-range": "^7.1.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
|
@ -4622,9 +4622,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fill-range": {
|
"node_modules/fill-range": {
|
||||||
"version": "7.0.1",
|
"version": "7.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
||||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"to-regex-range": "^5.0.1"
|
"to-regex-range": "^5.0.1"
|
||||||
|
@ -12302,12 +12302,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"braces": {
|
"braces": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
||||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"fill-range": "^7.0.1"
|
"fill-range": "^7.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
|
@ -13127,9 +13127,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"fill-range": {
|
"fill-range": {
|
||||||
"version": "7.0.1",
|
"version": "7.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
||||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"to-regex-range": "^5.0.1"
|
"to-regex-range": "^5.0.1"
|
||||||
|
|
|
@ -7,7 +7,13 @@ 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