Skip to content

Commit c2e2bc1

Browse files
authored
test(ci): keep isolated CLI checks offline (#97)
* test(ci): keep isolated CLI checks offline * test(ci): isolate remaining CLI drift probes
1 parent 31880ab commit c2e2bc1

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ jobs:
3737
# Isolate every home-relative write (kit.json, CLAUDE.md, settings).
3838
HOME: ${{ runner.temp }}/kit-home
3939
USERPROFILE: ${{ runner.temp }}\kit-home
40+
XDG_CONFIG_HOME: ${{ runner.temp }}/kit-home/.config
4041
APPDATA: ${{ runner.temp }}\kit-home\AppData\Roaming
4142
run: |
4243
mkdir -p "$HOME"
44+
# The smoke test proves local CLI behavior, not npm reachability.
45+
# Seed a fresh empty drift cache so an offline Windows runner does
46+
# not pay four sequential 20s `npm view` timeouts inside status.
47+
node -e 'const fs=require("node:fs"),p=require("node:path"),base=process.platform==="win32"?process.env.APPDATA:process.env.XDG_CONFIG_HOME,dir=p.join(base,"agentic-kit"),last=Date.now();fs.mkdirSync(dir,{recursive:true});fs.writeFileSync(p.join(dir,"kit.json"),JSON.stringify({versionCheck:{last,seen:{},self:{last,best:null}}}))'
4348
node bin/agentic-kit.mjs --version
4449
node bin/agentic-kit.mjs --help --all > /dev/null
4550
# status must emit valid JSON and exit deterministically even on a

‎tests/kit/dual-cli.test.mjs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ function sandbox({ dualRouting }) {
1515
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'kit-dual-home-'));
1616
const cfgDir = path.join(home, '.config', 'agentic-kit');
1717
fs.mkdirSync(cfgDir, { recursive: true });
18+
const last = Date.now();
1819
fs.writeFileSync(path.join(cfgDir, 'kit.json'),
19-
JSON.stringify({ providers: { hosts: { claude: true, codex: true }, dualRouting } }));
20+
JSON.stringify({
21+
providers: { hosts: { claude: true, codex: true }, dualRouting },
22+
// Real CLI spawns must not turn an isolated unit test into an npm network probe.
23+
versionCheck: { last, seen: {}, self: { last, best: null } },
24+
}));
2025
const project = fs.mkdtempSync(path.join(os.tmpdir(), 'kit-dual-proj-'));
2126
fs.mkdirSync(path.join(project, '.git'));
2227
return { home, project };

‎tests/kit/provider-cli.test.mjs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ function sandbox({ hosts }) {
2020
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'kit-prov-cli-home-'));
2121
const cfgDir = path.join(home, '.config', 'agentic-kit');
2222
fs.mkdirSync(cfgDir, { recursive: true });
23-
fs.writeFileSync(path.join(cfgDir, 'kit.json'), JSON.stringify({ providers: { hosts } }));
23+
const last = Date.now();
24+
fs.writeFileSync(path.join(cfgDir, 'kit.json'), JSON.stringify({
25+
providers: { hosts },
26+
// Real CLI spawns must not turn an isolated unit test into an npm network probe.
27+
versionCheck: { last, seen: {}, self: { last, best: null } },
28+
}));
2429
const project = fs.mkdtempSync(path.join(os.tmpdir(), 'kit-prov-cli-proj-'));
2530
fs.mkdirSync(path.join(project, '.git'));
2631
return { home, project };

‎tests/kit/provider-refresh-cli.test.mjs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@ function sandbox(providers) {
2727
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'kit-refresh-home-'));
2828
const cfgDir = path.join(home, '.config', 'agentic-kit');
2929
fs.mkdirSync(cfgDir, { recursive: true });
30-
fs.writeFileSync(path.join(cfgDir, 'kit.json'), JSON.stringify({ providers }));
30+
// These tests exercise provider output and persistence, not version egress.
31+
// A fresh sandbox otherwise makes every real CLI spawn run two sequential
32+
// `npm view` probes; an unreachable Windows runner pays both 20s timeouts
33+
// for every test in this file. Seed the same honest "checked, no answer"
34+
// cache shape a completed drift probe would persist.
35+
const last = Date.now();
36+
fs.writeFileSync(path.join(cfgDir, 'kit.json'), JSON.stringify({
37+
providers,
38+
versionCheck: { last, seen: {}, self: { last, best: null } },
39+
}));
3140
const project = fs.mkdtempSync(path.join(os.tmpdir(), 'kit-refresh-proj-'));
3241
fs.mkdirSync(path.join(project, '.git'));
3342
return { home, project };

0 commit comments

Comments
 (0)