From 6cfd34ea1f9dec5231feb36b32de202d0c4db185 Mon Sep 17 00:00:00 2001 From: Harry Xie Date: Sat, 9 May 2026 11:42:41 -0700 Subject: [PATCH] Add CI test workflow for PRs Runs on every pull_request and on push to main, in a Node 20/22 matrix. Three steps: npm ci, npm run build:harness (which is the harness's typecheck-and-compile), npm test. The new test script wraps node --test test/*.mjs so contributors and CI use the same entry point. concurrency: cancel-in-progress keeps stale runs from blocking new pushes on a PR. Pair this with branch protection on main to gate merges on a green run. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/test.yml | 36 ++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a8ad23c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +name: Test + +on: + pull_request: + push: + branches: [main] + +# Cancel in-flight runs for the same ref when a new commit lands. +concurrency: + group: test-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + node-version: ['20', '22'] + steps: + - uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - run: npm ci + + - name: Build harness + run: npm run build:harness + + - name: Run tests + run: npm test diff --git a/package.json b/package.json index 7067049..74e56e1 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "build:harness": "tsc -p tsconfig.json", "harness": "npm run build:harness --silent && node ./dist/cli.js", "typecheck": "tsc -p tsconfig.app.json --noEmit", + "test": "node --test test/*.mjs", "parse-gtfs": "node scripts/parse-gtfs.mjs" }, "engines": {