CARD-22 / D20. api-extractor 7.59.4 is now a dev dependency.
scripts/api-report.mjs reads the declarations that tsup emits for each
export-map entry (".", "./deno", "./bun", "./edge") and writes
api/<entry>.api.md.
`npm run api` regenerates the reports. `npm run api:check` runs in the
CI build job and fails when a report differs from the build, so a
public type change has to arrive with its regenerated report in the
same PR.
The check also fails on ae-forgotten-export: a public signature that
names a type its entry does not export. In the adapter entries, a root
type such as App or Logger is accepted, because it is importable from
@green-tea/core; any other unexported type still fails. Both failure
paths were verified locally, by adding a field to TlsOptions and by
un-exporting DenoServeOptions.
The reports are not published: npm ships dist/ and JSR ships src/.
CONTRIBUTING documents the check and the additions-only rule.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
110 lines
5.1 KiB
YAML
110 lines
5.1 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
branches: [develop, main, contrib]
|
|
pull_request:
|
|
branches: [develop, main, contrib]
|
|
jobs:
|
|
# Separate job so a missing sign-off reports on its own and doesn't hide behind the code
|
|
# gates, and so it costs nothing on push. Checks that the trailer is present, not that it
|
|
# matches the author — a mismatch is a judgement call for a reviewer, an absent trailer
|
|
# is not, and telling a contributor on their first push beats telling them on review.
|
|
dco:
|
|
if: github.event_name == 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Every commit needs a Signed-off-by
|
|
env:
|
|
RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
|
|
run: |
|
|
missing=0
|
|
for sha in $(git rev-list --no-merges "$RANGE"); do
|
|
if ! git show -s --format='%(trailers:key=Signed-off-by,valueonly)' "$sha" | grep -q '[^[:space:]]'; then
|
|
echo "::error::no Signed-off-by: $(git show -s --format='%h %s' "$sha")"
|
|
missing=1
|
|
fi
|
|
done
|
|
if [ "$missing" = 1 ]; then
|
|
echo "We use the DCO instead of a CLA. See CONTRIBUTING.md."
|
|
echo "Fix the whole branch with: git rebase --signoff ${{ github.event.pull_request.base.sha }}"
|
|
echo "Then: git push --force-with-lease"
|
|
exit 1
|
|
fi
|
|
echo "All commits signed off."
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: actions/setup-node@v5
|
|
with:
|
|
node-version: '22'
|
|
- run: npm ci
|
|
- run: npm run lint
|
|
- run: npm run format:check
|
|
- run: npm run complexity:check
|
|
- run: npm run typecheck
|
|
- run: npm test
|
|
- run: npm run build
|
|
# The committed reports in api/ are the frozen surface (CARD-22, D20). A PR that changes a
|
|
# public type fails here until it regenerates them with `npm run api`, so the change shows up
|
|
# in the diff a reviewer reads instead of only in the published declarations.
|
|
- run: npm run api:check
|
|
# Supply chain, deliberately after the code gates: an advisory published by a third party
|
|
# must never decide whether a contributor gets to see their own lint and typecheck output.
|
|
# Only what we ship blocks — with `reflect-metadata` as the sole runtime dependency, a
|
|
# production advisory is rare and genuinely reaches users. Build tooling only reports.
|
|
- run: npm audit --omit=dev
|
|
- run: npm audit
|
|
continue-on-error: true
|
|
|
|
# Runs everywhere is the headline claim, so it gets tested rather than asserted. `npm test` is
|
|
# Node only: a change to shared code can pass it and still be broken on Deno or Bun, which is
|
|
# exactly why these suites exist separately. Leaving them out of CI meant the claim rested on
|
|
# whoever remembered to run them locally.
|
|
#
|
|
# Its own job, not more steps on `build`, for the reason the audit sits where it does: a Bun
|
|
# failure should read as a Bun failure instead of burying the Node lint output.
|
|
runtimes:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
# One runtime breaking must not cancel the others — which one else broke is the useful part
|
|
# of the answer, and a cancelled job reports as if it had never been asked.
|
|
fail-fast: false
|
|
matrix:
|
|
runtime: [deno, bun, edge]
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: actions/setup-node@v5
|
|
with:
|
|
node-version: '22'
|
|
# All three need the dependency tree: the edge suite drives workerd from a Node process, and
|
|
# Deno and Bun resolve `reflect-metadata` out of node_modules like any other import.
|
|
- run: npm ci
|
|
- if: matrix.runtime == 'deno'
|
|
uses: denoland/setup-deno@v2
|
|
with:
|
|
deno-version: v2.x
|
|
- if: matrix.runtime == 'bun'
|
|
uses: oven-sh/setup-bun@v2
|
|
- run: npm run test:${{ matrix.runtime }}
|
|
# JSR's gate, moved off the release tag. `release.yml` runs this too and keeps doing so —
|
|
# that copy protects an immutable JSR version and is the last thing standing between a tag
|
|
# and a version number that can never be replaced. This copy exists because that one runs
|
|
# too late to be useful as feedback: a slow type or a Deno type error would otherwise land
|
|
# on `main` in silence and surface while cutting a release, which is the same "least time
|
|
# to judge a fix" the audit steps above are ordered to avoid.
|
|
#
|
|
# It is a second compiler over the same source, not a formality. `npm run typecheck` is tsc
|
|
# with this repo's tsconfig; this is Deno's checker with Deno's lib, and it is what found
|
|
# the `BodyInit` hole on the fetch path that tsc accepted. JSR serves `src/` directly, so
|
|
# anything it rejects is something a JSR consumer would have received.
|
|
#
|
|
# 0.68s against 2.0s for the whole vitest suite. No `--allow-dirty`: a checkout is clean,
|
|
# and if it somehow is not, that is worth failing on.
|
|
- if: matrix.runtime == 'deno'
|
|
run: deno publish --dry-run
|