How to Run Lint and Tests in Parallel Jobs in GitHub Actions
Jobs without a needs dependency start at the same time on separate runners.
Define lint and test as sibling jobs with no needs between them; the runner schedules both immediately.
Steps
- Split lint and test into two top-level jobs.
- Do not add
needsbetween them so they run concurrently. - Let a downstream job depend on both with
needs: [lint, test].
Workflow
.github/workflows/ci.yml
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm testGotchas
- Each job runs on its own runner, so they share no filesystem.
- Latchkey runs parallel jobs on cheaper managed runners, so fanning out costs less.
Related guides
How to Run Jobs in Parallel in GitHub ActionsRun independent GitHub Actions jobs in parallel by simply not declaring needs, so lint, test, and build all s…
How to Upload Coverage to Codecov in GitHub ActionsUpload test coverage to Codecov from GitHub Actions with codecov/codecov-action, using a token so coverage re…