Job Dependencies and Concurrency
Build a dependency graph
A release should not proceed if its prerequisite tests fail. needs establishes a directed dependency: the job waits for its prerequisite jobs and normally runs only after success. Independent jobs can run concurrently. A skipped or failed dependency normally skips its dependents unless their conditions change the default. A cycle has no valid execution order.
Read the graph
This inactive YAML uses placeholders rather than actual build or test logic. Build precedes test; report can examine outcomes even after failure via always(). Do not use an unconditional report as a deployment gate; it is diagnostic. always() can run even during cancellation and is not a guarantee that a runner will be available. Use bounded timeouts for real jobs.
name: Garden verificationon: [workflow_dispatch]permissions: {}concurrency: group: garden-ci-${{ github.ref }} cancel-in-progress: truejobs: build: runs-on: ubuntu-latest steps: - run: echo 'Build placeholder' test: needs: build runs-on: ubuntu-latest steps: - run: echo 'Test placeholder' report: needs: [build, test] if: ${{ always() }} runs-on: ubuntu-latest steps: - env: BUILD: ${{ needs.build.result }} TEST: ${{ needs.test.result }} run: printf '%s %s\n' "$BUILD" "$TEST"Concurrency is not a dependency
The group name scopes competing runs by ref. The default concurrency policy allows at most one running and one pending run in the group; a new pending run replaces the previous pending one. With cancel-in-progress: true, a new run can also cancel the active run. Group names are case-insensitive. This example is for disposable CI, not production. Default ordering is not guaranteed; newer queue options are outside this lesson.
Avoid unsafe cancellation
Cancellation does not roll back side effects. A release may already have uploaded an asset, or a deployment may have partly changed its target. Use target-specific serialization, idempotent operations and reconciliation; a concurrency group alone is not a distributed lock or durable queue. Predict: if build fails, test is skipped and report can observe the failure. Offline model tests this graph and pending replacement, not the real scheduler.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Job Dependencies and Concurrency — knowledge check
Reason about reliable delivery and trust boundaries.
If build fails, what happens to an ordinary job needing build?
What does needs establish?
With default one-pending policy, a new pending run arrives. What happens to the older pending run?
What does cancel-in-progress permit?
Why use always() for a report?