main
ply4 git calls35 ms42 KiB2 cachedprotocol v2
88 lines5.7 KiBRaw
1import assert from 'node:assert/strict'
2import { test } from 'node:test'
3import { noBumpSha, parseArgs } from '../scripts/cd/main.ts'
4import { nextPhase, pipelineStart, type PhaseOutcome, type PipelineState } from '../scripts/cd/pipeline-plan.ts'
6function run(state: PipelineState, outcome: PhaseOutcome) {
7 return nextPhase(state, outcome).phase
8}
10test('a pinned smoke failure halts and leaves the canary at 0%', () => {
11 const smoke = nextPhase(pipelineStart(), 'pass')
12 const deployed = nextPhase(smoke, 'pass')
13 assert.equal(deployed.phase, 'smoke-canary')
14 const stopped = nextPhase(deployed, 'fail')
15 assert.equal(stopped.phase, 'halt')
16 assert.equal(stopped.smoke, 'fail')
17})
19test('telemetry does not ramp when the pinned smoke failed', () => {
20 const state: PipelineState = { phase: 'telemetry-canary', smoke: 'fail' }
21 assert.equal(run(state, 'pass'), 'halt')
22 assert.equal(run({ phase: 'telemetry-canary', smoke: 'pass' }, 'pass'), 'ramp')
23 assert.equal(run({ phase: 'telemetry-canary', smoke: 'pass' }, 'fail'), 'halt')
24})
26test('a ramp rollback does not roll back again, and a live failure does', () => {
27 assert.equal(run({ phase: 'ramp', smoke: 'pass' }, 'rolled-back'), 'halt')
28 assert.equal(run({ phase: 'ramp', smoke: 'pass' }, 'fail'), 'halt')
29 assert.equal(run({ phase: 'ramp', smoke: 'pass' }, 'pass'), 'smoke-live')
30 assert.equal(run({ phase: 'smoke-live', smoke: 'pass' }, 'fail'), 'rollback')
31 assert.equal(run({ phase: 'telemetry-live', smoke: 'pass' }, 'fail'), 'rollback')
32 assert.equal(run({ phase: 'telemetry-live', smoke: 'pass' }, 'pass'), 'done')
33 assert.equal(run({ phase: 'rollback', smoke: 'pass' }, 'pass'), 'halt')
34 assert.equal(run({ phase: 'rollback', smoke: 'pass' }, 'fail'), 'halt')
35})
37test('a harness fault or a state conflict holds the split', () => {
38 assert.equal(run({ phase: 'smoke-live', smoke: 'pass' }, 'harness-stop'), 'halt')
39 assert.equal(run({ phase: 'smoke-canary', smoke: null }, 'harness-stop'), 'halt')
40 assert.equal(run({ phase: 'telemetry-canary', smoke: 'pass' }, 'harness-stop'), 'halt')
41 assert.equal(run({ phase: 'telemetry-live', smoke: 'pass' }, 'harness-stop'), 'halt')
42 assert.equal(run({ phase: 'ramp', smoke: 'pass' }, 'state-conflict'), 'halt')
43 assert.equal(run({ phase: 'telemetry-live', smoke: 'pass' }, 'state-conflict'), 'halt')
44})
46test('usage and a bad version exit as argument errors', () => {
47 assert.equal(parseArgs(['help']).kind, 'usage')
48 assert.equal(parseArgs(['cd', '--sha', 'abc']).kind, 'error')
49 assert.equal(parseArgs(['--sha', 'abc']).kind, 'error')
50 const sha = '1274f2dd05b83d70f8d421cdcc79628692d848df'
51 assert.deepEqual(parseArgs(['cd', '--sha', sha]), { kind: 'cd', sha, noBump: false, rampFlag: false, replaceCanary: null })
52 assert.deepEqual(parseArgs(['--sha', sha]), { kind: 'cd', sha, noBump: false, rampFlag: false, replaceCanary: null })
53 assert.deepEqual(parseArgs(['--no-bump']), { kind: 'cd', sha: null, noBump: true, rampFlag: false, replaceCanary: null })
54 assert.deepEqual(parseArgs(['cd', '--no-bump']), { kind: 'cd', sha: null, noBump: true, rampFlag: false, replaceCanary: null })
55 assert.deepEqual(parseArgs(['--no-bump', '--sha', sha], sha), { kind: 'cd', sha, noBump: true, rampFlag: false, replaceCanary: null })
56 assert.deepEqual(parseArgs(['--sha', sha, '--no-bump'], sha), { kind: 'cd', sha, noBump: true, rampFlag: false, replaceCanary: null })
57 assert.deepEqual(parseArgs(['--ramp']), { kind: 'cd', sha: null, noBump: false, rampFlag: true, replaceCanary: null })
58 assert.deepEqual(parseArgs(['cd', '--no-bump', '--ramp']), { kind: 'cd', sha: null, noBump: true, rampFlag: true, replaceCanary: null })
59 // --ramp is accepted and ignored (the ramp is the only path); --replace-canary names a uuid.
60 const zero = '0f0e0d0c-0b0a-4908-8706-050403020100'
61 assert.deepEqual(parseArgs(['--no-bump', '--replace-canary', zero]), { kind: 'cd', sha: null, noBump: true, rampFlag: false, replaceCanary: zero })
62 assert.equal(parseArgs(['--no-bump', '--replace-canary']).kind, 'error')
63 assert.equal(parseArgs(['--no-bump', '--replace-canary', 'b494b751']).kind, 'error')
64 assert.deepEqual(parseArgs(['deploy-canary']), { kind: 'deploy-canary', replaceCanary: null })
65 assert.deepEqual(parseArgs(['deploy-canary', '--replace-canary', zero]), { kind: 'deploy-canary', replaceCanary: zero })
66 assert.equal(parseArgs(['deploy-canary', '--force']).kind, 'error')
67 assert.equal(parseArgs(['cd', '--sha', sha, '--no-bump'], sha).kind, 'cd')
68 const other = 'a'.repeat(40)
69 assert.equal(parseArgs(['--no-bump', '--sha', sha]).kind, 'error')
70 assert.equal(parseArgs(['--no-bump', '--sha', sha], other).kind, 'error')
71 assert.equal(noBumpSha(sha, other), '--no-bump deploys the checkout; --sha must equal the current pin')
72 assert.equal(noBumpSha(sha, sha), null)
73 assert.equal(parseArgs(['smoke']).kind, 'error')
74 const version = '8c1af0e2-7b3d-4c1a-9e20-6f0a1b2c3d4e'
75 assert.deepEqual(parseArgs(['smoke', '--version', version]), { kind: 'smoke', version, expectVersion: null })
76 assert.equal(parseArgs(['telemetry', '--version', version, '--since', '2026-10-31T21:05:00Z']).kind, 'telemetry')
77 const runId = '2026-11-01T00-10-02-620Z'
78 assert.deepEqual(parseArgs(['annotate', runId, '--false-positive', '5% ramp Mann-Whitney flagged a sub-millisecond wall-time shift']), {
79 kind: 'annotate',
80 runId,
81 reason: '5% ramp Mann-Whitney flagged a sub-millisecond wall-time shift',
82 })
83 assert.equal(parseArgs(['annotate']).kind, 'error')
84 assert.equal(parseArgs(['annotate', 'not-a-run', '--false-positive', 'reason']).kind, 'error')
85 assert.equal(parseArgs(['annotate', runId]).kind, 'error')
86 assert.deepEqual(parseArgs(['sweep']), { kind: 'sweep' })
87 assert.equal(parseArgs(['sweep', '--force']).kind, 'error')
88})
Diagnostics4 git calls · 35 ms
CallStatusSizeTime035 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200145 B2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=145
git.response.cache=UPDATING
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=145
git.pkt.payload.max=76
git.ls_refs.count=2
git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020040 KiB · hit14 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=10
git.response.bytes=41349
git.response.cache=HIT
git.response.duration_ms=14
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=526b305930b8ef382f2d7a1f9c0238730a585921
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=6
git.pkt.data=4
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=41349
git.pkt.payload.max=41254
git.sideband.band1.bytes=41253
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=61
git.pack.bytes=41253
git.pack.ofs_delta=0
git.pack.ref_delta=0
git.pack.chain.max=0
git.pack.trailer=ab60efef4b7243678c75de64a4386986ee885c1c
git.pack.full=61
Open pack map
fetch2001.3 KiB · hit19 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=19
git.response.bytes=1360
git.response.cache=HIT
git.response.duration_ms=19
git.fetch.wants=2b2a76bd6c08c6b327f04fedaf36a41050f61800
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=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1360
git.pkt.payload.max=1339
git.sideband.band1.bytes=1338
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://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply-web.git
Ref
refs/heads/main
Commit
526b305930b8ef382f2d7a1f9c0238730a585921
cf-ray
a5e31d49a8458682
Request
299af7d1…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format