What is the `needs` + `strategy.matrix` pattern for fan-out and fan-in?
AdvancedConceptGitHub Actions
Answer
A planning job computes a list (changed services, test shards) and outputs it as JSON; a matrix job fans out over fromJSON(...); a final gate job with needs: [matrix-job] fans in, so one required check represents all shards. The gate must use if: always() and fail explicitly if the matrix result is not success, otherwise a skipped matrix would show as green.
gate:
needs: test
if: always()
runs-on: ubuntu-latest
steps:
- run: test "${{ needs.test.result }}" = "success"
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate