AI Hints
CI/CD with GitHub Actions · Lesson 43 of 138

Multiple Jobs

Parallel work.

⏱ 2 min read▶ Video at 49:29🎓 Free
Watch this lesson in the CI/CD with GitHub Actions courseWatch on YouTube ↗Full CI/CD with GitHub Actions course

As a project grows, one long job gets slow. Splitting the work into several jobs helps, because jobs run at the same time, on separate machines. Linting, testing, and checking the docs can all happen at once.

Multiple Jobs
From the video: Multiple Jobs
  • One long job is slow
  • Split the work
  • Jobs run in parallel

Three jobs

Lint, test, and docs are three separate jobs. None of them depends on another, so GitHub starts all three straight away, on three runners. The whole workflow takes as long as the slowest job, not the total of all three.

.github/workflows/ci.ymlyaml
name: CI
on: push
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - run: flake8 && echo "style ok"
  test:
    runs-on: ubuntu-latest
    steps:
      - run: pytest -q
  docs:
    runs-on: ubuntu-latest
    steps:
      - run: test -f README.md && echo "readme found"

Three results

Our helper runs the jobs one by one, but each gets its own section and its own result, just like on GitHub. Style is fine, the tests pass, and the readme is there. If one failed, the others would still finish, and show their own results.

Terminal
run-steps .github/workflows/ci.yml
Workflow: CI  (event: push, branch: main)
Job: lint
  ✓ Run flake8 && echo "style ok"
      style ok
  Job succeeded
Job: test
  ✓ Run pytest -q
      ...                                                                                [100%]
      3 passed in 0.01s
  Job succeeded
Job: docs
  ✓ Run test -f README.md && echo "readme found"
      readme found
  Job succeeded

Summary

Separate jobs run in parallel, on separate runners, so the workflow finishes sooner. Next, making jobs wait for each other.

Key takeaways
  • Several jobs
  • Run in parallel
  • Separate results
Next up: needs — jobs in order