|
| 1 | +name: _decide |
| 2 | + |
| 3 | +# Resolve the lane + backend from the triggering event. Shared by the |
| 4 | +# per-platform entry workflows (ci-linux-x86_64 / ci-windows / ci-sbsa) so the |
| 5 | +# rules live in exactly one place. `github.*` here refers to the caller's event. |
| 6 | +# |
| 7 | +# lane: fast (PR push) | full (approval / `ci: full` / main push) | |
| 8 | +# nightly (schedule) | skip (non-approval review) |
| 9 | +# backend: standard | rtx | both — from the `backend: TensorRT[-RTX]` labels |
| 10 | +# (or the workflow_dispatch `backend` input) |
| 11 | + |
| 12 | +on: |
| 13 | + workflow_call: |
| 14 | + outputs: |
| 15 | + lane: |
| 16 | + description: "fast | full | nightly | skip" |
| 17 | + value: ${{ jobs.decide.outputs.lane }} |
| 18 | + backend: |
| 19 | + description: "standard | rtx | both" |
| 20 | + value: ${{ jobs.decide.outputs.backend }} |
| 21 | + |
| 22 | +jobs: |
| 23 | + decide: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + lane: ${{ steps.pick.outputs.lane }} |
| 27 | + backend: ${{ steps.pick.outputs.backend }} |
| 28 | + steps: |
| 29 | + - id: pick |
| 30 | + env: |
| 31 | + EVENT: ${{ github.event_name }} |
| 32 | + REVIEW_STATE: ${{ github.event.review.state }} |
| 33 | + HAS_FULL_LABEL: "${{ contains(github.event.pull_request.labels.*.name, 'ci: full') }}" |
| 34 | + # Exact array-element match: 'backend: TensorRT' != 'backend: TensorRT-RTX'. |
| 35 | + HAS_RTX_LABEL: "${{ contains(github.event.pull_request.labels.*.name, 'backend: TensorRT-RTX') }}" |
| 36 | + HAS_STD_LABEL: "${{ contains(github.event.pull_request.labels.*.name, 'backend: TensorRT') }}" |
| 37 | + DISPATCH_LANE: ${{ github.event.inputs.lane }} |
| 38 | + DISPATCH_BACKEND: ${{ github.event.inputs.backend }} |
| 39 | + run: | |
| 40 | + set -euo pipefail |
| 41 | + case "$EVENT" in |
| 42 | + schedule) lane=nightly ;; |
| 43 | + workflow_dispatch) lane="${DISPATCH_LANE:-full}" ;; |
| 44 | + push) lane=full ;; # main canary |
| 45 | + pull_request_review) |
| 46 | + [ "$REVIEW_STATE" = "approved" ] && lane=full || lane=skip ;; |
| 47 | + pull_request) |
| 48 | + [ "$HAS_FULL_LABEL" = "true" ] && lane=full || lane=fast ;; |
| 49 | + *) lane=fast ;; |
| 50 | + esac |
| 51 | + echo "lane=$lane" >> "$GITHUB_OUTPUT" |
| 52 | + case "$EVENT" in |
| 53 | + workflow_dispatch) backend="${DISPATCH_BACKEND:-both}" ;; |
| 54 | + pull_request) |
| 55 | + if [ "$HAS_RTX_LABEL" = "true" ] && [ "$HAS_STD_LABEL" = "true" ]; then backend=both |
| 56 | + elif [ "$HAS_RTX_LABEL" = "true" ]; then backend=rtx |
| 57 | + elif [ "$HAS_STD_LABEL" = "true" ]; then backend=standard |
| 58 | + else backend=standard; fi ;; |
| 59 | + *) backend=both ;; # push / approval / schedule |
| 60 | + esac |
| 61 | + echo "backend=$backend" >> "$GITHUB_OUTPUT" |
| 62 | + echo "Resolved lane='$lane' backend='$backend' (event=$EVENT)." |
0 commit comments