CI with GitHub Actions
CI means continuous integration. Every push runs your type checker and your tests. If anything fails, the pull request is blocked. That is the whole loop. It sounds small. In practice, it is the single biggest quality upgrade a team can make with an hour of setup.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Type check
run: npx tsc --noEmit
- name: Run tests
run: npm testA minimal GitHub Actions workflow that runs lint, type-check, and tests on every push and PR.
npm ci installs exactly what is in package-lock.json with no resolution. npm install can upgrade dependencies within your declared ranges, which means your CI can run against slightly different versions than your laptop. In CI you want reproducibility above all else. npm ci is that reproducibility, in one command.
Quiz: Quiz
Loading practice…