Duplicated jobs without matrix strategy¶
Rule ID |
|
|---|---|
Category |
performance |
Severity |
low |
Multiple nearly-identical jobs differ only in a parameter (OS, Node version, etc.) but do not use a matrix strategy.
Detection¶
heuristic — Structural comparison across multiple jobs or steps.
Examples¶
Non-compliant:
jobs:
test-node-18:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with: {node-version: 18}
- run: npm test
test-node-20:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with: {node-version: 20}
- run: npm test
test-node-22:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with: {node-version: 22}
- run: npm test
Compliant:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm test
Fix: Replace duplicate jobs with a single job using strategy.matrix to iterate over the varying parameter.