Skip to content

Commit 2537ad5

Browse files
committed
Test against the production GitHub caching server in CI
1 parent 1e7e871 commit 2537ad5

File tree

4 files changed

+65
-4
lines changed

4 files changed

+65
-4
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868
WIREIT_PARALLEL: 1
6969
- run: xvfb-run -a npm test
7070
if: runner.os == 'Linux'
71+
- run: npm run test:cache-github-real
7172

7273
lint-and-format:
7374
timeout-minutes: 5

package.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"test:local": "wireit",
3434
"test:analysis": "wireit",
3535
"test:basic": "wireit",
36-
"test:cache-github": "wireit",
36+
"test:cache-github-fake": "wireit",
37+
"test:cache-github-real": "wireit",
3738
"test:cache-local": "wireit",
3839
"test:clean": "wireit",
3940
"test:cli-options": "wireit",
@@ -78,7 +79,7 @@
7879
},
7980
"test:headless": {
8081
"dependencies": [
81-
"test:cache-github",
82+
"test:cache-github-fake",
8283
"test:local"
8384
]
8485
},
@@ -146,8 +147,20 @@
146147
"files": [],
147148
"output": []
148149
},
149-
"test:cache-github": {
150-
"command": "uvu lib/test \"^cache-github\\.test\\.js$\"",
150+
"test:cache-github-fake": {
151+
"command": "uvu lib/test \"^cache-github-fake\\.test\\.js$\"",
152+
"env": {
153+
"NODE_OPTIONS": "--enable-source-maps"
154+
},
155+
"dependencies": [
156+
"build"
157+
],
158+
"files": [],
159+
"output": []
160+
},
161+
"test:cache-github-real": {
162+
"#comment": "Only works on GitHub CI",
163+
"command": "uvu lib/test \"^cache-github-real\\.test\\.js$\"",
151164
"env": {
152165
"NODE_OPTIONS": "--enable-source-maps"
153166
},

src/test/cache-github-real.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import {suite} from 'uvu';
8+
import {registerCommonCacheTests} from './cache-common.js';
9+
import {WireitTestRig} from './util/test-rig.js';
10+
11+
const test = suite<{rig: WireitTestRig}>();
12+
13+
test.before.each(async (ctx) => {
14+
try {
15+
ctx.rig = new WireitTestRig();
16+
ctx.rig.env = {
17+
...ctx.rig.env,
18+
WIREIT_CACHE: 'github',
19+
// We're testing against the actual production GitHub API, so we must pass
20+
// down access to the real credentials (normally our test rig removes any
21+
// WIREIT_ variables from being inherited).
22+
WIREIT_CACHE_GITHUB_CUSTODIAN_PORT:
23+
process.env.WIREIT_CACHE_GITHUB_CUSTODIAN_PORT,
24+
};
25+
await ctx.rig.setup();
26+
} catch (error) {
27+
// Uvu has a bug where it silently ignores failures in before and after,
28+
// see https://github.com/lukeed/uvu/issues/191.
29+
console.error('uvu before error', error);
30+
process.exit(1);
31+
}
32+
});
33+
34+
test.after.each(async (ctx) => {
35+
try {
36+
await ctx.rig.cleanup();
37+
} catch (error) {
38+
// Uvu has a bug where it silently ignores failures in before and after,
39+
// see https://github.com/lukeed/uvu/issues/191.
40+
console.error('uvu after error', error);
41+
process.exit(1);
42+
}
43+
});
44+
45+
registerCommonCacheTests(test, 'github');
46+
47+
test.run();

0 commit comments

Comments
 (0)