snippetyamlModeratependingCanonical
GitHub Actions CI -- Node.js test and lint workflow
Viewed 0 times
GitHub ActionsCIworkflowmatrixcacheartifacts
ci-cdgithub
Problem
Need a CI pipeline that runs tests and linting on every push and PR.
Solution
GitHub Actions workflow with dependency caching, parallel jobs, and matrix strategy.
Code Snippets
GitHub Actions with lint and test matrix
name: CI
on:
push: { branches: [main] }
pull_request: { branches: [main] }
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npm run lint
test:
runs-on: ubuntu-latest
strategy:
matrix: { node: [18, 20, 22] }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '${{ matrix.node }}', cache: npm }
- run: npm ci
- run: npm test -- --coverageRevisions (0)
No revisions yet.