Skip to content

Commit d73b4e7

Browse files
authored
Gate cadence build CI to run on labeled fork exports (#20350)
Summary: Let the Cadence Xtensa build jobs (hifi-build, vision-build) run on internal- export fork PRs, and skip cleanly on every other fork PR instead of failing red. pull_request_target only takes effect once this is on main. Differential Revision: D108915137
1 parent 03ed98b commit d73b4e7

1 file changed

Lines changed: 39 additions & 3 deletions

File tree

.github/workflows/build-cadence-runner.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,45 @@ on:
1010
tags:
1111
- ciflow/nightly/*
1212
pull_request:
13+
pull_request_target:
14+
types: [labeled]
1315
workflow_dispatch:
1416

1517
concurrency:
16-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
18+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.sha }}
1719
cancel-in-progress: true
1820

1921
jobs:
22+
gate:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
run-cadence: ${{ steps.decide.outputs.run }}
26+
steps:
27+
- id: decide
28+
env:
29+
EVENT: ${{ github.event_name }}
30+
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
31+
HAS_CLA: ${{ contains(github.event.pull_request.labels.*.name, 'CLA Signed') }}
32+
HAS_EXPORT: ${{ contains(github.event.pull_request.labels.*.name, 'meta-exported') }}
33+
run: |
34+
run=false
35+
case "${EVENT}" in
36+
push|schedule|workflow_dispatch)
37+
run=true
38+
;;
39+
pull_request)
40+
[ "${IS_FORK}" = "false" ] && run=true
41+
;;
42+
pull_request_target)
43+
if [ "${IS_FORK}" = "true" ] && [ "${HAS_CLA}" = "true" ] && [ "${HAS_EXPORT}" = "true" ]; then
44+
run=true
45+
fi
46+
;;
47+
esac
48+
echo "run=${run}" >> "${GITHUB_OUTPUT}"
49+
2050
cpu-build:
51+
if: github.event_name != 'pull_request_target'
2152
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
2253
permissions:
2354
id-token: write
@@ -44,6 +75,7 @@ jobs:
4475
4576
cpu-test:
4677
needs: cpu-build
78+
if: github.event_name != 'pull_request_target'
4779
permissions:
4880
id-token: write
4981
contents: read
@@ -56,19 +88,23 @@ jobs:
5688
# lives in _xtensa_build.yml. fusion_g3 is omitted until the upstream fusion_g3
5789
# <-> nnlib-FusionG3 API skew is fixed (its runner does not link).
5890
hifi-build:
91+
needs: gate
92+
if: needs.gate.outputs.run-cadence == 'true'
5993
permissions:
6094
id-token: write
6195
contents: read
6296
uses: ./.github/workflows/_xtensa_build.yml
6397
with:
6498
backend: hifi4
65-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
99+
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.head.sha || github.sha }}
66100

67101
vision-build:
102+
needs: gate
103+
if: needs.gate.outputs.run-cadence == 'true'
68104
permissions:
69105
id-token: write
70106
contents: read
71107
uses: ./.github/workflows/_xtensa_build.yml
72108
with:
73109
backend: vision
74-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
110+
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.head.sha || github.sha }}

0 commit comments

Comments
 (0)