main
1#!/bin/sh
2# Consumer check: run ply-web's gates against a ply commit without committing the pin.
3#
4# sh scripts/ply-main-check.sh <ply-sha> <out-dir>
5#
6# Sets dependencies.ply to github:ivarvong/ply#<sha> in the working tree (package.json and package-lock.json are
7# changed in place and never committed), installs, then runs `npm test`, `npm run lint` and `npm run typecheck`.
8# Writes <out-dir>/report.md (the issue body), <out-dir>/{install,test,lint,typecheck}.log and <out-dir>/summary.env
9# (PLY_SHA, PLY_SHORT, PLY_PREV, OUTCOME). Exit 0 when every gate passed (OUTCOME=pass); 1 when a gate failed or
10# `npm install` of the (valid) sha failed (OUTCOME=fail, report.md written: an install failure is a breakage too, e.g.
11# ply's `prepare: tsc` or an exports/engines change); 2 on a usage error (bad sha, no out-dir) or when the lockfile
12# resolved ply to a sha that does not start with the one asked for, with no report and no $GITHUB_OUTPUT outcome.
13# When $GITHUB_OUTPUT is set it also appends `outcome=pass|fail` there, so the workflow maps nothing itself.
14# Used by .github/workflows/ply-main.yml; runs the same on a laptop. Tested by test/ply-main-check.test.js.
15set -u
17sha=${1:-}
18out=${2:-}
19case "$sha" in
20 *[!0-9a-f]* | "") echo "ply-main-check: sha must be 7-40 lowercase hex, got '${sha}'" >&2; exit 2 ;;
21esac
22if [ "${#sha}" -lt 7 ] || [ "${#sha}" -gt 40 ]; then
23 echo "ply-main-check: sha must be 7-40 lowercase hex, got '${sha}'" >&2
24 exit 2
25fi
26if [ -z "$out" ]; then
27 echo "usage: sh scripts/ply-main-check.sh <ply-sha> <out-dir>" >&2
28 exit 2
29fi
30mkdir -p "$out"
32# The pin on this ply-web checkout: the lower end of the ply commit range under test.
33prev=$(node -p "(require('./package.json').dependencies.ply.split('#')[1] || '')")
35full=$sha
36failed=""
37npm pkg set "dependencies.ply=github:ivarvong/ply#${sha}"
38if ! npm install --no-audit --no-fund >"$out/install.log" 2>&1; then
39 tail -n 40 "$out/install.log" >&2
40 echo "ply-main-check: npm install of ply#${sha} failed" >&2
41 failed=" install"
42else
43 # The full sha npm resolved, from the lockfile (the dispatch may carry a short one).
44 full=$(node -p "((require('./package-lock.json').packages['node_modules/ply'] || {}).resolved || '').split('#')[1] || ''")
45 case "$full" in
46 "$sha"*) ;;
47 *) echo "ply-main-check: lockfile resolved ply to '${full}', not ${sha}" >&2; exit 2 ;;
48 esac
49 # vite.config.ts requires a 40-hex pin, so write the resolved full sha back before any gate runs.
50 if [ "$full" != "$sha" ]; then
51 npm pkg set "dependencies.ply=github:ivarvong/ply#${full}"
52 if ! npm install --no-audit --no-fund >>"$out/install.log" 2>&1; then
53 tail -n 40 "$out/install.log" >&2
54 echo "ply-main-check: npm install of ply#${full} failed" >&2
55 failed=" install"
56 fi
57 fi
58fi
59short=$(printf '%s' "$full" | cut -c1-7)
60echo "ply-main-check: ply ${prev} -> ${full}"
62for gate in test lint typecheck; do
63 if [ "$failed" = " install" ]; then break; fi
64 echo "::group::npm run ${gate}"
65 npm run "$gate" >"$out/${gate}.log" 2>&1
66 code=$?
67 cat "$out/${gate}.log"
68 echo "::endgroup::"
69 echo "ply-main-check: npm run ${gate} exit ${code}"
70 [ "$code" -eq 0 ] || failed="${failed} ${gate}"
71done
73outcome=pass
74[ -z "$failed" ] || outcome=fail
75{
76 echo "PLY_SHA=${full}"
77 echo "PLY_SHORT=${short}"
78 echo "PLY_PREV=${prev}"
79 echo "OUTCOME=${outcome}"
80} >"$out/summary.env"
82{
83 echo "ply main \`${full}\` fails ply-web's gates (ply-web at \`$(git rev-parse HEAD 2>/dev/null || echo unknown)\`)."
84 echo
85 echo "ply commit range: https://github.com/ivarvong/ply/compare/${prev}...${full}"
86 echo
87 echo "Failed gates:${failed:- none}"
88 for gate in $failed; do
89 echo
90 if [ "$gate" = install ]; then echo "### npm install"; else echo "### npm run ${gate}"; fi
91 echo
92 echo '```'
93 if [ "$gate" = test ]; then
94 # node:test's spec reporter prints `✖ name (ms)` per failing test (TAP: `not ok N - name`); vitest prints FAIL / ×.
95 echo "Failing tests:"
96 grep -E '^[[:space:]]*(✖|not ok|FAIL|×) ' "$out/test.log" | grep -v 'failing tests:' | sed 's/^[[:space:]]*//' | sort -u | head -n 60
97 echo
98 fi
99 tail -n 30 "$out/${gate}.log" 2>/dev/null
100 echo '```'
101 done
102} >"$out/report.md"
104if [ -n "${GITHUB_OUTPUT:-}" ]; then echo "outcome=${outcome}" >>"$GITHUB_OUTPUT"; fi
105echo "ply-main-check: ${outcome}${failed:+ (${failed# })}"
106[ "$outcome" = pass ]
Diagnostics4 git calls · 266 ms
CallStatusSizeTime0266 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 B3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=145 git.response.cache=UPDATING git.response.duration_ms=3 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 · 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=41349 git.response.cache=HIT git.response.duration_ms=2 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=61Open pack map
fetch2001.9 KiB261 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=261 git.response.bytes=1926 git.response.cache=MISS git.response.duration_ms=261 git.fetch.wants=776443537bf360da5beaa488eafe7a5380b71864 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=1926 git.pkt.payload.max=1905 git.sideband.band1.bytes=1904 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
- a5e363ffcaa7b23b
- Request
- 5a3b1440…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format