GitHubivarvong
ply
main
1// Nightly deep fuzz, one fuzzer per call: node scripts/nightly-fuzz.mjs <seed> <fuzzer.mjs> [args...]
2// Runs test/fuzz/<fuzzer.mjs> --seed <seed> [args...], streams its output, and on failure prints the seed, the failing
3// cases and one `reproduce:` command per case (the lines the nightly issue quotes), plus a step summary on Actions.
4import { spawn } from 'node:child_process';
5import { appendFileSync } from 'node:fs';
6import { fileURLToPath } from 'node:url';
8const [seedArg, fuzzer, ...rest] = process.argv.slice(2);
9if (!/^\d+$/.test(seedArg ?? '') || !/^[a-z-]+\.mjs$/.test(fuzzer ?? '')) {
10 console.error('usage: node scripts/nightly-fuzz.mjs <seed> <fuzzer.mjs> [args...]');
11 process.exit(2);
12}
13const seed = seedArg;
14const argv = [`test/fuzz/${fuzzer}`, '--seed', seed, ...rest];
15const base = `node ${argv.join(' ')}`;
16const q = s => `'${String(s).replace(/'/g, `'\\''`)}'`;
17const n = (() => { const i = rest.indexOf('--n'); return i < 0 ? null : rest[i + 1]; })();
18const flags = rest.filter((a, i) => a !== '--n' && rest[i - 1] !== '--n');
19const withN = k => `node test/fuzz/${fuzzer} --seed ${seed} --n ${k} ${flags.join(' ')}`.trim();
21// one reproduce command per failing case, from the line the fuzzer prints for it
22const RULES = [
23 [/repro: (node test\/fuzz\/\S+ --case \d+)/, m => m[1]], // run, hostile, liar, protocol: the case seed alone
24 [/^FAIL #\s*(\d+)/, m => withN(+m[1] + 1)], // packs, packgen, codec: one stream from --seed, case i is the (i+1)th
25 // below-hash, git-semantic: a random case `kind#<seed>` is picked by its seed, a fixed case by its name
26 [/^(?:FAIL|DIVERGE)\s+(\S+?):?\s/, m => `${withN(n ?? 20)} --case ${/#(\d+)$/.test(m[1]) ? m[1].match(/#(\d+)$/)[1] : q(m[1])}`],
27 [/^WRONG case (\d+)/, m => `${withN(n ?? 2000)} --case ${m[1]}`], // linemerge
28 [/^case (\d+) \(seed/, m => `${withN(n ?? 200)} --case ${m[1]}`], // attributes
29 [/^case (\d+): n=/, m => withN(+m[1] + 1)], // diffscript: no --case; the (c+1)th diff of this seed
30];
32const out = [];
33// src/ keeps .js specifiers for .ts files; the hook resolves them under plain node (test/ts-resolve.mjs).
34const hook = fileURLToPath(new URL('../test/ts-resolve.mjs', import.meta.url));
35const child = spawn(process.execPath, ['--import', hook, ...argv], { stdio: ['ignore', 'pipe', 'pipe'] });
36let buf = '';
37const onData = (stream, d) => { stream.write(d); buf += d; let i; while ((i = buf.indexOf('\n')) >= 0) { out.push(buf.slice(0, i)); buf = buf.slice(i + 1); } };
38child.stdout.on('data', d => onData(process.stdout, d));
39child.stderr.on('data', d => onData(process.stderr, d));
40const code = await new Promise(r => child.on('close', (c, sig) => r(c ?? (sig ? 128 : 1))));
41if (buf) out.push(buf);
42if (code === 0) process.exit(0);
44const repro = [];
45for (const line of out) {
46 for (const [re, f] of RULES) { const m = line.trim().match(re); if (m) { repro.push(f(m)); break; } }
47}
48const uniq = [...new Set(repro)];
49if (!uniq.length) uniq.push(base); // a crash, or no per-case line: the whole run is deterministic from the seed
50const lines = [`NIGHTLY-FAIL ${fuzzer} seed=${seed} exit=${code} command: ${base}`, ...uniq.slice(0, 10).map(c => `NIGHTLY-FAIL ${fuzzer} seed=${seed} reproduce: ${c}`)];
51if (uniq.length > 10) lines.push(`NIGHTLY-FAIL ${fuzzer} seed=${seed} ... ${uniq.length - 10} more failing cases`);
52console.log('\n' + lines.join('\n'));
53for (const l of lines) console.log(`::error title=${fuzzer} seed ${seed}::${l}`);
54if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, `### ${fuzzer} failed (seed ${seed})\n\n\`\`\`\n${lines.join('\n')}\n\`\`\`\n`);
55process.exit(code);
Diagnostics6 git calls · 136 ms
CallStatusSizeTime0136 ms
discover200191 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=191 git.server.agent=git/github-9922ec520325-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=191 git.pkt.payload.max=36
ls-refs20012 KiB103 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=95 git.response.bytes=11990 git.response.cache=EXPIRED git.response.duration_ms=103 git.protocol.version=2 git.pkt.frames=152 git.pkt.data=151 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=11990 git.pkt.payload.max=122 git.ls_refs.count=151 git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 102004.2 KiB · hit4 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=4 git.response.bytes=4347 git.response.cache=HIT git.response.duration_ms=4 git.fetch.filter=tree:0 git.fetch.wants=19912563f540228593df0c489082e5e2508e21e4 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=4347 git.pkt.payload.max=4247 git.sideband.band1.bytes=4247 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=10 git.pack.bytes=4247 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=a6caf8e129bea82c9bae4cbc7c130c9205add400 git.pack.full=10Open pack map
fetchtree:0200919 B · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=919 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=800d30ba8923860bfc460ca884b7f9ba22083588 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=919 git.pkt.payload.max=892 git.sideband.band1.bytes=892 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=892 git.pack.trailer=5323b9266eea5ded637285d1c5320699f12be76eOpen pack map
fetchtree:0200831 B · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=831 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=b9290e370bd091fd3272931655a175dd1a7af82d git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=831 git.pkt.payload.max=804 git.sideband.band1.bytes=804 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=804 git.pack.trailer=81ddc1f73214935b4ee953ad84f959db955ce0d1Open pack map
fetch2001.7 KiB · hit24 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=23 git.response.bytes=1747 git.response.cache=HIT git.response.duration_ms=24 git.fetch.wants=743149c0e04dfa97388a5f13c9b96b66356267c5 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1747 git.pkt.payload.max=1720 git.sideband.band1.bytes=1720 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://github.com/ivarvong/ply
- Ref
- refs/heads/main
- Commit
- 19912563f540228593df0c489082e5e2508e21e4
- cf-ray
- a5e1c6dd3849c6f8
- Request
- 378da325…
- Protocol
- v2 · sha1
- Agent
- git/github-9922ec520325-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format