Skip to content

Commit 8789aa5

Browse files
authored
[cadence] Run one Cadence job tree for branch PRs and fork PRs
Folds Cadence CI's three PR paths into build-cadence-runner.yml with one condition for every job. Fork PRs that touch Cadence paths from a CONTRIBUTOR+ author (Meta exports from personal forks included) now get the same six jobs as branch PRs, on pull_request_target. The meta-exported label path and cadence-fork-pr.yml are removed. Only the Xtensa jobs hold credentials; the CPU jobs run with contents: read on every path. The image is resolved once, from the base branch on fork PRs. Test plan: actionlint is clean and the job condition was checked against each event type. This PR's pull_request run covers the same-repo path; the fork path gets verified after merge via pytorch#23219. Differential Revision: D123116687 Pull Request resolved: pytorch#23379
1 parent b1994b8 commit 8789aa5

5 files changed

Lines changed: 102 additions & 174 deletions

File tree

‎.github/workflows/_test_cadence.yml‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
name: Test Cadence
22

33
permissions:
4-
id-token: write
54
contents: read
65

76
on:
87
workflow_call:
98
inputs:
109
docker-image:
11-
description: 'Name of the docker image to use, without registry or tag suffix'
12-
required: false
10+
description: 'Fully qualified CI image (resolved by the caller)'
11+
required: true
1312
type: string
14-
default: ci-image:executorch-ubuntu-22.04-clang12
1513
runner:
1614
description: 'Runner type'
1715
required: false
@@ -29,20 +27,14 @@ on:
2927
default: 90
3028

3129
jobs:
32-
docker-image:
33-
name: Resolve CI docker image
34-
uses: ./.github/workflows/_docker-image.yml
35-
3630
test-aot:
37-
needs: docker-image
3831
uses: pytorch/test-infra/.github/workflows/linux_job_v3.yml@main
3932
permissions:
40-
id-token: write
4133
contents: read
4234
with:
4335
job-name: test-aot
4436
runner: ${{ inputs.runner }}
45-
docker-image: ${{ needs.docker-image.outputs.docker-registry }}/${{ inputs.docker-image }}-${{ needs.docker-image.outputs.ci-docker-hash }}
37+
docker-image: ${{ inputs.docker-image }}
4638
submodules: recursive
4739
ref: ${{ inputs.ref }}
4840
timeout: ${{ inputs.timeout }}
@@ -58,15 +50,13 @@ jobs:
5850
python -m pytest backends/cadence/aot/tests/ -v -n auto --reruns 2 --reruns-delay 1
5951
6052
test-ops:
61-
needs: docker-image
6253
uses: pytorch/test-infra/.github/workflows/linux_job_v3.yml@main
6354
permissions:
64-
id-token: write
6555
contents: read
6656
with:
6757
job-name: test-ops
6858
runner: ${{ inputs.runner }}
69-
docker-image: ${{ needs.docker-image.outputs.docker-registry }}/${{ inputs.docker-image }}-${{ needs.docker-image.outputs.ci-docker-hash }}
59+
docker-image: ${{ inputs.docker-image }}
7060
submodules: recursive
7161
ref: ${{ inputs.ref }}
7262
timeout: ${{ inputs.timeout }}

‎.github/workflows/_xtensa_build.yml‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,28 @@ on:
2020
required: false
2121
type: string
2222
default: ""
23+
docker-image:
24+
description: "Fully qualified CI image (resolved by the caller)"
25+
required: true
26+
type: string
27+
allow-fork-checkout:
28+
description: "Check out fork PR code on pull_request_target"
29+
required: false
30+
type: boolean
31+
default: false
2332

2433
jobs:
25-
# The runner pod pulls the container before any step runs, so the image has to
26-
# be a fully qualified reference resolved by a job this one depends on.
27-
docker-image:
28-
name: Resolve CI docker image
29-
uses: ./.github/workflows/_docker-image.yml
30-
3134
build:
3235
name: ${{ inputs.backend }}
33-
needs: docker-image
34-
# Intel, not the x86iavx512 (r7a/AMD) default: the Cadence licence key that
35-
# xt-clang computes for a core differs by CPU vendor, and only the Intel one
36-
# (XT_XCC_TIE_ED4D1230) is in the bundled licence. On an AMD runner the
37-
# vision core resolves to XT_XCC_TIE_ED4DB539 and the checkout fails with
38-
# "No such feature exists". hifi4's older RI-2022.10 toolchain does not care.
36+
# Keep this label at 18 characters or fewer. The pod hostname is the label plus
37+
# 28 characters, and RJ-2025.5 xt-clang (vision) derives the wrong licence key
38+
# once the hostname reaches 47: it asks for XT_XCC_TIE_ED4DB539 instead of the
39+
# bundled ED4D1230 and fails with "No such feature exists". The CPU vendor is
40+
# not the cause; mt-l-x86iavx512-8-64 (20 characters) fails on its hostname.
41+
# hifi4's RI-2022.9 toolchain is unaffected.
3942
runs-on: mt-l-x86iamx-8-64
4043
container:
41-
image: ${{ needs.docker-image.outputs.docker-registry }}/ci-image:executorch-ubuntu-22.04-clang12-${{ needs.docker-image.outputs.ci-docker-hash }}
44+
image: ${{ inputs.docker-image }}
4245
environment: cadence
4346
permissions:
4447
id-token: write
@@ -63,6 +66,8 @@ jobs:
6366
with:
6467
submodules: recursive
6568
ref: ${{ inputs.ref }}
69+
persist-credentials: ${{ !inputs.allow-fork-checkout }}
70+
allow-unsafe-pr-checkout: ${{ inputs.allow-fork-checkout }}
6671

6772
- name: Assume Cadence artifacts role
6873
uses: aws-actions/configure-aws-credentials@v4
@@ -92,6 +97,7 @@ jobs:
9297
chmod -R a+rX cmake-out
9398
9499
- name: Upload runner
100+
if: ${{ !inputs.allow-fork-checkout }}
95101
uses: actions/upload-artifact@v4
96102
with:
97103
name: cadence-xtensa-build-${{ inputs.backend }}

‎.github/workflows/_xtensa_test.yml‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,28 @@ on:
1919
required: false
2020
type: string
2121
default: ""
22+
docker-image:
23+
description: "Fully qualified CI image (resolved by the caller)"
24+
required: true
25+
type: string
26+
allow-fork-checkout:
27+
description: "Check out fork PR code on pull_request_target"
28+
required: false
29+
type: boolean
30+
default: false
2231

2332
jobs:
24-
# The runner pod pulls the container before any step runs, so the image has to
25-
# be a fully qualified reference resolved by a job this one depends on.
26-
docker-image:
27-
name: Resolve CI docker image
28-
uses: ./.github/workflows/_docker-image.yml
29-
3033
test:
3134
name: ${{ inputs.backend }}
32-
needs: docker-image
33-
# Intel, not the x86iavx512 (r7a/AMD) default: the Cadence licence key that
34-
# xt-clang computes for a core differs by CPU vendor, and only the Intel one
35-
# (XT_XCC_TIE_ED4D1230) is in the bundled licence. On an AMD runner the
36-
# vision core resolves to XT_XCC_TIE_ED4DB539 and the checkout fails with
37-
# "No such feature exists". hifi4's older RI-2022.10 toolchain does not care.
35+
# Keep this label at 18 characters or fewer. The pod hostname is the label plus
36+
# 28 characters, and RJ-2025.5 xt-clang (vision) derives the wrong licence key
37+
# once the hostname reaches 47: it asks for XT_XCC_TIE_ED4DB539 instead of the
38+
# bundled ED4D1230 and fails with "No such feature exists". The CPU vendor is
39+
# not the cause; mt-l-x86iavx512-8-64 (20 characters) fails on its hostname.
40+
# hifi4's RI-2022.9 toolchain is unaffected.
3841
runs-on: mt-l-x86iamx-8-64
3942
container:
40-
image: ${{ needs.docker-image.outputs.docker-registry }}/ci-image:executorch-ubuntu-22.04-clang12-${{ needs.docker-image.outputs.ci-docker-hash }}
43+
image: ${{ inputs.docker-image }}
4144
environment: cadence
4245
permissions:
4346
id-token: write
@@ -62,6 +65,8 @@ jobs:
6265
with:
6366
submodules: recursive
6467
ref: ${{ inputs.ref }}
68+
persist-credentials: ${{ !inputs.allow-fork-checkout }}
69+
allow-unsafe-pr-checkout: ${{ inputs.allow-fork-checkout }}
6570

6671
- name: Assume Cadence artifacts role
6772
uses: aws-actions/configure-aws-credentials@v4

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

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,75 @@ on:
1010
tags:
1111
- ciflow/nightly/*
1212
pull_request:
13+
# Fork PRs, Meta exports from personal forks included. pull_request_target
14+
# always runs this file from the default branch, so the paths filter below only
15+
# affects fork PRs.
1316
pull_request_target:
14-
types: [labeled]
17+
types: [opened, synchronize, reopened]
18+
paths:
19+
- backends/cadence/**
20+
- examples/cadence/**
21+
- .ci/scripts/setup-xtensa-tools.sh
22+
- .ci/scripts/build-cadence-xtensa.sh
23+
- .ci/scripts/test-cadence-xtensa.sh
1524
workflow_dispatch:
1625

1726
concurrency:
1827
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}
1928
cancel-in-progress: true
2029

30+
# Every job runs on the same paths. Same-repo PRs use pull_request, which reads
31+
# the PR's own workflow AND code -- so CI changes, new test jobs, code, and tests
32+
# are all validated pre-merge. Fork PRs can't get credentials (OIDC) there, so
33+
# fork PRs whose author has contributed before (CONTRIBUTOR or above) run on
34+
# pull_request_target instead. The CPU jobs hold no AWS credentials on any path
35+
# (contents: read only), so linux_job_v3's role/arc never reaches fork code; only
36+
# the Xtensa jobs assume a role, the Cadence artifacts one. The run condition is
37+
# inlined per job (GitHub Actions has no YAML anchors and env is unavailable in
38+
# job-level if), so keep the copies in sync.
2139
jobs:
40+
# Resolves the image inline rather than through the shared _docker-image.yml,
41+
# which checks out the PR head: actions/checkout refuses that for fork code on
42+
# pull_request_target. There the image comes from the base branch (github.sha),
43+
# which also keeps a fork from picking the image it runs in. Same-repo PRs read
44+
# their own head, as _docker-image.yml does, so .ci/docker changes are tested.
2245
docker-image:
2346
name: Resolve CI docker image
24-
uses: ./.github/workflows/_docker-image.yml
47+
if: >-
48+
github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ||
49+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
50+
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository &&
51+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.pull_request.author_association))
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: read
55+
outputs:
56+
image: ${{ steps.hash.outputs.image }}
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
61+
persist-credentials: false
62+
- id: hash
63+
run: |
64+
set -eu
65+
CI_DOCKER_HASH="$(git rev-parse HEAD:.ci/docker)"
66+
echo "image=308535385114.dkr.ecr.us-east-1.amazonaws.com/executorch/ci-image:executorch-ubuntu-22.04-clang12-${CI_DOCKER_HASH}" >> "$GITHUB_OUTPUT"
2567
26-
# Same-repo PRs run on pull_request, which reads the PR's own workflow AND code
27-
# -- so CI changes, new test jobs, code, and tests are all validated pre-merge.
28-
# Fork PRs can't get credentials (OIDC) on pull_request, so Meta-exported forks
29-
# (labeled CLA Signed + meta-exported) run on pull_request_target instead. The
30-
# run condition is inlined per job (GitHub Actions has no YAML anchors and env
31-
# is unavailable in job-level if), so keep the copies in sync.
3268
cpu-build:
3369
needs: docker-image
3470
if: >-
3571
github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ||
3672
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
3773
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository &&
38-
contains(github.event.pull_request.labels.*.name, 'CLA Signed') && contains(github.event.pull_request.labels.*.name, 'meta-exported'))
74+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.pull_request.author_association))
3975
uses: pytorch/test-infra/.github/workflows/linux_job_v3.yml@main
4076
permissions:
41-
id-token: write
4277
contents: read
4378
with:
4479
job-name: build
4580
runner: mt-l-x86iavx512-8-64
46-
docker-image: ${{ needs.docker-image.outputs.docker-registry }}/ci-image:executorch-ubuntu-22.04-clang12-${{ needs.docker-image.outputs.ci-docker-hash }}
81+
docker-image: ${{ needs.docker-image.outputs.image }}
4782
submodules: recursive
4883
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.head.sha || github.sha }}
4984
timeout: 90
@@ -61,66 +96,74 @@ jobs:
6196
cp cmake-out/backends/cadence/cadence_runner "${RUNNER_ARTIFACT_DIR}/"
6297
6398
cpu-test:
64-
needs: cpu-build
99+
needs: [docker-image, cpu-build]
65100
if: >-
66101
github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ||
67102
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
68103
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository &&
69-
contains(github.event.pull_request.labels.*.name, 'CLA Signed') && contains(github.event.pull_request.labels.*.name, 'meta-exported'))
104+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.pull_request.author_association))
70105
permissions:
71-
id-token: write
72106
contents: read
73107
uses: ./.github/workflows/_test_cadence.yml
74108
with:
109+
docker-image: ${{ needs.docker-image.outputs.image }}
75110
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.head.sha || github.sha }}
76111

77112
# Cross-compile cadence_executor_runner for each Cadence Xtensa core, one job
78113
# per backend so they show as separate lines (no matrix grouping). Shared logic
79114
# lives in _xtensa_build.yml. fusion_g3 is omitted until the upstream fusion_g3
80115
# <-> nnlib-FusionG3 API skew is fixed (its runner does not link).
81116
hifi-build:
117+
needs: docker-image
82118
if: >-
83119
github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ||
84120
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
85121
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository &&
86-
contains(github.event.pull_request.labels.*.name, 'CLA Signed') && contains(github.event.pull_request.labels.*.name, 'meta-exported'))
122+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.pull_request.author_association))
87123
permissions:
88124
id-token: write
89125
contents: read
90126
uses: ./.github/workflows/_xtensa_build.yml
91127
with:
92128
backend: hifi4
93129
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.head.sha || github.sha }}
130+
docker-image: ${{ needs.docker-image.outputs.image }}
131+
allow-fork-checkout: ${{ github.event_name == 'pull_request_target' }}
94132

95133
# Op-level gtest tests on the Xtensa ISS, mirroring cpu-build -> cpu-test. The
96134
# op tests are a self-contained cross-compile (the gtests need exceptions and
97135
# RTTI that the runner build disables), so this does not consume hifi-build's
98136
# artifact; needs: hifi-build only to fail fast when the backend cannot build.
99137
hifi-op-test:
100-
needs: hifi-build
138+
needs: [docker-image, hifi-build]
101139
if: >-
102140
github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ||
103141
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
104142
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository &&
105-
contains(github.event.pull_request.labels.*.name, 'CLA Signed') && contains(github.event.pull_request.labels.*.name, 'meta-exported'))
143+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.pull_request.author_association))
106144
permissions:
107145
id-token: write
108146
contents: read
109147
uses: ./.github/workflows/_xtensa_test.yml
110148
with:
111149
backend: hifi4
112150
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.head.sha || github.sha }}
151+
docker-image: ${{ needs.docker-image.outputs.image }}
152+
allow-fork-checkout: ${{ github.event_name == 'pull_request_target' }}
113153

114154
vision-build:
155+
needs: docker-image
115156
if: >-
116157
github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ||
117158
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
118159
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository &&
119-
contains(github.event.pull_request.labels.*.name, 'CLA Signed') && contains(github.event.pull_request.labels.*.name, 'meta-exported'))
160+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.pull_request.author_association))
120161
permissions:
121162
id-token: write
122163
contents: read
123164
uses: ./.github/workflows/_xtensa_build.yml
124165
with:
125166
backend: vision
126167
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.pull_request.head.sha || github.sha }}
168+
docker-image: ${{ needs.docker-image.outputs.image }}
169+
allow-fork-checkout: ${{ github.event_name == 'pull_request_target' }}

0 commit comments

Comments
 (0)