name: ci on: pull_request: push: branches: [main] permissions: {} # A new push to a pull request cancels the run it supersedes (it holds up to 7 runners against the account's # concurrent-job limit); runs on main are grouped by commit, so none is ever cancelled. Mutation testing is not here: # mutate.yml runs it beside this workflow, out of band (it took about an hour on main and held this run open). concurrency: group: ci-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: # The suite (vitest), split across 4 runners by measured per-file duration: vitest.config.ts's sequencer partitions # `--shard i/N` longest-first over test/durations.json instead of vitest's count-based split. # One job was 6-15 min; a shard is one file's worth (the slowest file bounds it). i and N come from the matrix itself, # so the partition cannot disagree with the number of shards, and the plan covers every file listed here exactly once. test-shard: name: test-shard (${{ matrix.shard }}) runs-on: ubuntu-latest permissions: contents: read actions: write # setup-node persists the npm cache strategy: fail-fast: false matrix: shard: [1, 2, 3, 4] env: GIT_AUTHOR_NAME: ply GIT_AUTHOR_EMAIL: ply@example.com GIT_COMMITTER_NAME: ply GIT_COMMITTER_EMAIL: ply@example.com steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 22 cache: npm - name: git identity run: git config --global user.name ply && git config --global user.email ply@example.com - run: npm ci - name: vitest env: INDEX: ${{ strategy.job-index }} TOTAL: ${{ strategy.job-total }} # gate c (test/space): every test process records the src/ fail sites it reaches; the `test` job judges them PLY_FAILSITES: .failsites NODE_OPTIONS: --import ${{ github.workspace }}/test/space/failsite-hook.mjs run: npx vitest run --shard "$((INDEX + 1))/${TOTAL}" --reporter=default --reporter=json --outputFile.json="reports/vitest/shard-$((INDEX + 1)).json" # Per-file test counts and durations from a real runner (test/durations.json is refreshed from these). - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 if: success() || failure() with: name: vitest-shard-${{ matrix.shard }} path: reports/vitest/ if-no-files-found: ignore retention-days: 14 - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 if: success() || failure() with: name: failsites-${{ matrix.shard }} path: .failsites include-hidden-files: true if-no-files-found: error retention-days: 14 # Types (tsc, isolated declarations, the TS ratchet against the PR base, the absence ratchet), lint, the dist build consumers import, and # three fuzzers. The fuzzers run src/*.ts under node's type stripping; --import ./test/ts-resolve.mjs maps the .js # specifiers to .ts (GitHub refuses NODE_OPTIONS through $GITHUB_ENV, so each command names the hook). lint-fuzz: name: lint + fuzz runs-on: ubuntu-latest permissions: contents: read actions: write # setup-node persists the npm cache env: GIT_AUTHOR_NAME: ply GIT_AUTHOR_EMAIL: ply@example.com GIT_COMMITTER_NAME: ply GIT_COMMITTER_EMAIL: ply@example.com steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: fetch-depth: 0 persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 22 cache: npm - name: git identity run: git config --global user.name ply && git config --global user.email ply@example.com - run: npm ci - name: typecheck (tsc, isolated declarations, TS ratchet, absence ratchet) env: RATCHET_BASE: ${{ github.event.pull_request.base.sha || github.event.before }} run: npm run typecheck # Each ratchet compares the tree with its baseline, so a change that edits both passes it. This compares the # baselines with the base commit's: one that moved the unsafe way needs `Ratchet-Change: : `. - name: ratchet baselines loosen only with a Ratchet-Change line env: RATCHET_BASE: ${{ github.event.pull_request.base.sha || github.event.before }} run: node scripts/ratchet-guard.mjs # lint ends with the regex gate (scripts/regex-gate.mjs): every regex in src/ has an inventory row and no refused # shape. The rows' ratio test is test/regex-linear.test.js, which runs in the test shards. - run: npm run lint # The full mutation run fits its job: the heaviest planned shard, on a runner twice as slow as the reference # (RUNNER_WORST), at most 2/3 of mutate.yml's mutate-shard timeout-minutes, 60 of 90 (scripts/mutate.mjs --budget, # #313). The instrumenter only, about 2 s. - name: mutation plan fits the shard job limit run: node scripts/mutate.mjs --budget # The same command as the last step of `npm run check` (test/workflows.test.js holds the two equal). It builds # into a scratch directory, imports `ply` there (Tracer and RETRY exported), then compiles the built d.ts as a # consumer of every subpath, skipLibCheck false: lib ES2022 + @types/node 20, 22 and 24, lib DOM, and # @cloudflare/workers-types. The type packages are pinned devDependencies that npm ci installs; a missing one # fails this step, none is skipped (scripts/dist-check.mjs; test/dist-types.test.js runs it in the suite too) - name: dist is what consumers import run: node scripts/dist-check.mjs - name: below-hash fuzzer run: node --import ./test/ts-resolve.mjs test/fuzz/below-hash.mjs --n 20 --seed 1 && node --import ./test/ts-resolve.mjs test/fuzz/below-hash.mjs --seed 20261030 --n 100 --case 1730047880 - name: git-semantic fuzzer run: node --import ./test/ts-resolve.mjs test/fuzz/git-semantic.mjs --n 20 --seed 1 - name: liar merge-base fuzzer run: node --import ./test/ts-resolve.mjs test/fuzz/liar.mjs --op mergebase --n 40 --seed 1 fuzz: # Deterministic fuzz, fixed seeds and sizes, in parallel with the shards and gated by `test`; it finishes before the # slowest shard (154-305 s against 653-760 s on main, Nov 2026), so gating it adds no PR wall time. The deep, # date-seeded runs are in nightly.yml. hostile --case 2366521731 is the pinned case npm test also runs. # Each command names the .js -> .ts resolve hook (see lint-fuzz). name: fuzz runs-on: ubuntu-latest timeout-minutes: 20 permissions: contents: read actions: write # setup-node persists the npm cache env: GIT_AUTHOR_NAME: ply GIT_AUTHOR_EMAIL: ply@example.com GIT_COMMITTER_NAME: ply GIT_COMMITTER_EMAIL: ply@example.com steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 22 cache: npm - name: git identity run: git config --global user.name ply && git config --global user.email ply@example.com - run: npm ci - name: hostile fuzzer run: node --import ./test/ts-resolve.mjs test/fuzz/hostile.mjs --n 180 --seed 1 && node --import ./test/ts-resolve.mjs test/fuzz/hostile.mjs --case 2366521731 - name: liar fuzzer run: node --import ./test/ts-resolve.mjs test/fuzz/liar.mjs --n 120 --seed 1 - name: protocol fuzzer run: node --import ./test/ts-resolve.mjs test/fuzz/protocol.mjs --n 300 --seed 1 - name: packs fuzzer run: node --import ./test/ts-resolve.mjs test/fuzz/packs.mjs --n 36 --seed 1 - name: codec fuzzer run: node --import ./test/ts-resolve.mjs test/fuzz/codec.mjs --n 15000 --seed 1 - name: attributes fuzzer run: node --import ./test/ts-resolve.mjs test/fuzz/attributes.mjs --n 120 --seed 1 # Cells at or under 16 MiB and 65_536 entries, each in its own process on the default heap and at 128 MiB (workerd # cells once, in their own workerd process: workerd is a devDependency). # The full matrix (past those sizes, and the long delta chains) is the nightly job. `test` gates on it (the vitest # shards do not run this file); it finishes before the slowest shard (160-250 s on main, Nov 2026). sweep: name: limit sweep runs-on: ubuntu-latest timeout-minutes: 40 permissions: contents: read actions: write # setup-node persists the npm cache env: GIT_AUTHOR_NAME: ply GIT_AUTHOR_EMAIL: ply@example.com GIT_COMMITTER_NAME: ply GIT_COMMITTER_EMAIL: ply@example.com steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 22 cache: npm - name: git identity run: git config --global user.name ply && git config --global user.email ply@example.com - run: npm ci - name: sweep (small cells) run: node --import ./test/ts-resolve.mjs test/sweep/run.mjs --ci # What a consumer installs: the npm pack tarball, built from a fresh export of the tracked files, installed with # --ignore-scripts into an empty project (one package, no registry), the root and every subpath imported, and # require('ply') compared with README Install, under Node 22 and then the same tarball under Node 20 and 24 # (scripts/pack-check.mjs). On Node 22 it also runs the setup command examples/README.md documents in a fresh export # and starts each example. The tarball is uploaded as the artifact `ply-tarball`. # It runs on every pull request and every push to main, and `test` gates on it: a tarball that misses a file, breaks a # subpath export or fails under Node 20 or 24 fails `test`. pack: name: pack + install runs-on: ubuntu-latest timeout-minutes: 15 permissions: contents: read steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 22 - run: npm ci - name: pack, install --ignore-scripts, import every subpath, examples from a fresh export (Node 22) run: node scripts/pack-check.mjs --out pack-out - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 20 - name: the same tarball under Node 20 run: node scripts/pack-check.mjs --tarball pack-out/ply-*.tgz - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 24 - name: the same tarball under Node 24 run: node scripts/pack-check.mjs --tarball pack-out/ply-*.tgz - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: ply-tarball path: pack-out/ply-*.tgz if-no-files-found: error # The gate. Its name stays `test` so anything waiting on that check still works. It runs even when a shard fails or # is cancelled (a skipped check would count as passing), and fails unless every shard, lint + fuzz, fuzz, limit sweep # and pack + install succeeded. test: name: test needs: [test-shard, lint-fuzz, fuzz, sweep, pack] if: always() runs-on: ubuntu-latest permissions: contents: read actions: read # the shards' fail-site records steps: - name: every needed job succeeded env: SHARDS: ${{ needs.test-shard.result }} LINT_FUZZ: ${{ needs.lint-fuzz.result }} FUZZ: ${{ needs.fuzz.result }} SWEEP: ${{ needs.sweep.result }} PACK: ${{ needs.pack.result }} run: | echo "test-shard: $SHARDS, lint-fuzz: $LINT_FUZZ, fuzz: $FUZZ, sweep: $SWEEP, pack: $PACK" for r in "$SHARDS" "$LINT_FUZZ" "$FUZZ" "$SWEEP" "$PACK"; do if [ "$r" != success ]; then exit 1; fi done # gate c over every shard's records: each fail site reached by a cell, each merged space's claims reached by it, and # every merged CI space's runners recorded on Linux (test/space/failsites.test.js) - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 22 - run: npm ci - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: pattern: failsites-* path: .failsites merge-multiple: true - name: gate c (fail sites) env: PLY_FAILSITES: .failsites PLY_FAILSITES_GATE: 1 run: npx vitest run test/space/failsites.test.js supply-chain: name: actionlint runs-on: ubuntu-latest permissions: contents: read steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: persist-credentials: false - name: actionlint env: ACTIONLINT_VERSION: 1.7.12 ACTIONLINT_SHA256: 8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8 run: | set -euo pipefail curl -fsSL -o actionlint.tar.gz "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" echo "${ACTIONLINT_SHA256} actionlint.tar.gz" | sha256sum -c tar -xzf actionlint.tar.gz actionlint ./actionlint -color - uses: zizmorcore/zizmor-action@53290badfa369cb0bf7ad16342cb62c2fa47ac7b # v0.8.0 with: inputs: .github/workflows version: "1.31.1" online-audits: false advanced-security: false persona: regular