From d6f88bb25fe0926e409008189e763431ef75432a Mon Sep 17 00:00:00 2001 From: Teodor Calin Date: Tue, 9 Jun 2026 09:40:05 +0300 Subject: [PATCH] fix(ci): smoke test type-checks the README quickstart against the built dist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The smoke test was failing for two unrelated reasons that the misleading \`no quickstart code block found\` error message hid: 1. \`/tmp/quickstart.ts\` ran \`new Driver()\`, which dials a daemon socket. CI has no daemon — the constructor throws \`Cannot find module 'pilotprotocol'\` when run from /tmp because the package isn't installed there either. 2. The intent ("did we break the user's copy-paste?") doesn't actually need execution; type-checking the snippet against the built \`dist/index.d.ts\` catches the renames-and-signature-drifts that the smoke is really there to guard. Replaces the \`npx tsx /tmp/quickstart.ts\` run with a type-check inside the repo: extract the same block to smoke-tmp/quickstart.ts, drop a tsconfig with \`paths.pilotprotocol → ../dist/index.d.ts\`, run \`tsc -p\`. No daemon, no global install. Runs in ~3s. Verified locally: \`tsc\` exits 0 against the current README. --- .github/workflows/sdk-examples-smoke-test.yml | 40 +++++++++++++++---- .gitignore | 1 + 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sdk-examples-smoke-test.yml b/.github/workflows/sdk-examples-smoke-test.yml index 4103ca1..0c7d571 100644 --- a/.github/workflows/sdk-examples-smoke-test.yml +++ b/.github/workflows/sdk-examples-smoke-test.yml @@ -27,15 +27,41 @@ jobs: - run: npm ci - run: npm run build - - name: Run quickstart from README + - name: Type-check quickstart from README against built package run: | # PILOT-197: extract the first ```ts / ```javascript fenced - # block from README.md and run it; this is the same block - # users copy-paste. - awk '/^```(ts|typescript|javascript|js)$/{flag=1;next}/^```$/{flag=0}flag' README.md > /tmp/quickstart.ts - if [ ! -s /tmp/quickstart.ts ]; then + # block from README.md and confirm it type-checks against the + # built package — this catches the most common breakage + # (README drifts from public API after a rename / signature + # change). We TYPE-check, not execute: the quickstart calls + # `new Driver()` which dials a daemon socket, and CI has no + # daemon. Type-checking against the built dist/index.d.ts is + # a strong enough "did we break user copy-paste" signal. + mkdir -p smoke-tmp + awk '/^```(ts|typescript|javascript|js)$/{flag=1;next}/^```$/{flag=0}flag' README.md > smoke-tmp/quickstart.ts + if [ ! -s smoke-tmp/quickstart.ts ]; then echo "::error::no quickstart code block found in README.md" exit 1 fi - # Compile and run as a one-shot. Loopback-only — no registry needed. - npx tsx /tmp/quickstart.ts + # Run tsc inside the repo so `import 'pilotprotocol'` + # resolves via paths→dist (set up below). The repo already + # has typescript installed from `npm ci`. + cat > smoke-tmp/tsconfig.json <<'EOF' + { + "compilerOptions": { + "noEmit": true, + "esModuleInterop": true, + "module": "nodenext", + "moduleResolution": "nodenext", + "target": "es2022", + "skipLibCheck": true, + "strict": true, + "paths": { + "pilotprotocol": ["../dist/index.d.ts"] + }, + "baseUrl": "." + }, + "include": ["quickstart.ts"] + } + EOF + npx tsc -p smoke-tmp/tsconfig.json diff --git a/.gitignore b/.gitignore index 487b82d..2175ed4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ bin/ *.tgz coverage/ .nyc_output/ +smoke-tmp/