Reputation: 361
In GitHub Actions, imagine I have a build configuration like this, which builds my program on 3 different OSes and tests it on Ubuntu:
name: build-and-test
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
test:
runs-on: ubuntu-latest
needs: build
I would like the test
job to depend on the Ubuntu run from the build
job. However, now it depends on all three. How can I specify that the test
job only needs the ubuntu run from the build
job to finish before it starts running, and not all three?
TL;DR: I would like the test
job to run as soon as the Ubuntu build job is finished, and not wait on the macOS and Windows ones.
Upvotes: 10
Views: 3116
Reputation: 4318
This is not possible based on the current implementation of GitHub Actions. My suggestion would be to pull out ubuntu into its own job, this way its execution is independent of the others.
name: build-and-test
jobs:
build-slow:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
build-ubuntu:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
test:
runs-on: ubuntu-latest
needs: build-ubuntu
Reference: https://github.com/orgs/community/discussions/25364#discussioncomment-4107131 https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#handling-failures
Upvotes: 9