Dependent Jobs
Episode
Dependent Jobs
Teaching 5 min
Exercises 5 min
Estimated 10 min
Questions
- How do you make some jobs run after other jobs?
Objectives
- Run some jobs in serial.
Defining dependencies
From the last session, we’re starting with
jobs:
greeting:
runs-on: ubuntu-latest
steps:
- run: echo hello world
build_skim:
runs-on: ubuntu-latest
container: rootproject/root:${{ matrix.version }}
strategy:
matrix:
version: [6.26.10-conda, latest]
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: build
run: |
COMPILER=$(root-config --cxx)
FLAGS=$(root-config --cflags --libs)
$COMPILER -g -O3 -Wall -Wextra -Wpedantic -o skim skim.cxx $FLAGSWe’re going to talk about another useful parameter needs.
Specify dependencies between jobs
The key-value needs: job or list of jobs allows you to specify dependencies between jobs in the order you define.
Example:
job2:
needs: job1job2 waits until job1 completes successfully. Further reading.
Challenge
Dependent jobs
How to make build_skim job run after greeting?
Solution
jobs:
greeting:
runs-on: ubuntu-latest
steps:
- run: echo hello world
build_skim:
needs: greeting
runs-on: ubuntu-latest
container: rootproject/root:${{ matrix.version }}
strategy:
matrix:
version: [6.26.10-conda, latest]
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: build
run: |
COMPILER=$(root-config --cxx)
FLAGS=$(root-config --cflags --libs)
$COMPILER -g -O3 -Wall -Wextra -Wpedantic -o skim skim.cxx $FLAGSLet’s go ahead and add those changes and look at GitHub.
git add .github/workflows/main.yml
git commit -m "add dependent jobs"
git push -u origin feature/add-actions
Key Points
- We can specify dependencies between jobs running in a series using the needs value.
