Skip to content

CICD-046 · Keep the required result after sharding ​

Encyclopedia · Matrices and sharding · All snippets

Previous · CICD-045 · Next · CICD-047

1. Where it fits ​

  • Placement .github/workflows/ci.yml, inside the relevant job.
  • Prerequisites workspace whose runtime dependencies match the chosen target combinations.
  • Platforms github-actions, gitea-actions.
  • Parameters RESULT.

2. Copy the snippet ​

yaml
needs: [shards]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
  - env:
      RESULT: ${{ needs.shards.result }}
    run: test "$RESULT" = success

3. How it works ​

needs makes the shard result available to the final job and the status guard allows it to inspect an upstream failure. The named gate translates that state into a required check.

A named gate evaluates the combined shard result.

flowchart TD
  N1["Test shards"]
  N2["Aggregate job result"]
  N1 --> N2
  N3{"All shards succeeded"}
  N2 --> N3
  N4["Required check passes"]
  N3 -->|Yes| N4
  N5["Required check fails"]
  N3 -->|No| N5
  classDef trigger fill:#EFF6FF,stroke:#0540F2,color:#0A0A0A
  classDef build fill:#CCFBF1,stroke:#0D9488,color:#0A0A0A
  classDef test fill:#EEF2FF,stroke:#4F46E5,color:#0A0A0A
  classDef gate fill:#FEF3C7,stroke:#D97706,color:#0A0A0A
  classDef security fill:#EDE9FE,stroke:#7C3AED,color:#0A0A0A
  classDef deploy fill:#D1FAE5,stroke:#059669,color:#0A0A0A
  classDef fail fill:#FEE2E2,stroke:#DC2626,color:#0A0A0A
  class N1 test
  class N2,N3 gate
  class N4 deploy
  class N5 fail

4. Verify the result ​

Protect this named check and prove a failed shard fails the aggregate.

Validation syntax-validated (YAML parse). Status definitions.