Add a lint and test workflow to GitHub Actions
Run lint, type check and tests as parallel jobs in GitHub Actions, and cancel older runs on the same branch when a new commit arrives.
Separate jobs run side by side, so one failure does not hide the others, and the wall-clock time is the slowest job, not the sum.
name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 24, cache: npm }
- run: npm ci
- run: npm run lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 24, cache: npm }
- run: npm ci
- run: npm testThe concurrency block gives runs on the same ref one group, and cancel-in-progress stops the older run when a newer commit lands. That saves minutes on a branch you push to often. See the concurrency docs.
Each job installs dependencies again, which costs a few seconds with a cache. Do not cancel runs on main, where you want every commit checked, so scope the cancel to pull requests if that matters.