1. Test job
The test job runs first and gates everything after it.
test:
runs-on: ubuntu-latestTyporithm · medium
Step 1 of 8 · intro card
CI/CD
Stage a pipeline so deploy only runs after tests pass (needs: test) and only on the right branch (if:). This gates releases, fails fast on a bad commit, and keeps broken code from shipping. Jobs run in parallel unless a needs dependency orders them.
A pipeline is staged: build, then test, then deploy. Each stage is a job, and a later stage should only proceed when the earlier one succeeds.
needs: test makes the deploy job wait for the test job and run only if it passed. This fails fast — a broken commit stops at the test stage and never reaches deploy.
The if: condition narrows deploy further to a single branch (github.ref == 'refs/heads/main'), so feature branches run tests but only main ships. Jobs run in parallel unless a needs dependency orders them.
needs: test makes deploy wait for tests to pass.
if: gates a job on a condition like the branch.
Jobs are parallel unless needs creates an order.
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: npm test
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- run: ./deploy.shConnect each part of the code to the concept before you type.
The test job runs first and gates everything after it.
test:
runs-on: ubuntu-latestThe test stage runs the suite; a failure stops the deploy.
- run: npm testThe deploy job ships the app once it is allowed to run.
deploy:needs makes deploy wait for test to finish successfully.
needs: testif restricts deploy to runs on the main branch.
if: github.ref == 'refs/heads/main'Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.