Skip to content

Commit 0c1f7a4

Browse files
authored
[cadence] Run the Xtensa jobs on fork PRs from existing contributors
Fork PRs that are not Meta exports currently get no Cadence Xtensa signal. This adds a self-contained workflow, cadence-fork-pr.yml, that runs the hifi4 build, hifi4 op tests and vision build on fork PRs touching Cadence paths when the author has contributed to the repo before (CONTRIBUTOR or above). First-time contributors and unassociated authors get nothing, and no existing workflow changes. The docker image is resolved from the base branch so the fork cannot pick it, and nothing is uploaded as an artifact. Test plan: actionlint is clean, and the job gate was checked against sample events (CONTRIBUTOR/COLLABORATOR/MEMBER run; FIRST_TIME_CONTRIBUTOR/FIRST_TIMER/NONE, same-repo PRs and Meta exports do not). pull_request_target always runs the default branch's workflow, so this can only be exercised end to end after it lands; I'll verify with a draft fork PR touching backends/cadence and revert if it misbehaves. Authored with Claude Code. cc @mcremon-meta Differential Revision: D122233926 Pull Request resolved: #23197
1 parent ffb13bf commit 0c1f7a4

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Cadence Fork PR
2+
3+
# Xtensa build and op tests for fork PRs that are not Meta exports (those run
4+
# from build-cadence-runner.yml). The jobs need the licensed toolchain, so they
5+
# run the fork's code with the Cadence artifacts role. That is limited to authors
6+
# who have contributed to the repository before (CONTRIBUTOR or above);
7+
# first-time contributors and unassociated authors get nothing.
8+
#
9+
# Self-contained on purpose: the shared reusable workflows check out the PR head
10+
# on pull_request_target, which actions/checkout refuses for fork code, and they
11+
# are used well beyond Cadence.
12+
on:
13+
pull_request_target:
14+
types: [opened, synchronize, reopened]
15+
paths:
16+
- backends/cadence/**
17+
- examples/cadence/**
18+
- .ci/scripts/setup-xtensa-tools.sh
19+
- .ci/scripts/build-cadence-xtensa.sh
20+
- .ci/scripts/test-cadence-xtensa.sh
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
# The image comes from the base branch rather than the fork, so the fork
28+
# cannot pick which image its code runs in.
29+
docker-image:
30+
if: >-
31+
github.event.pull_request.head.repo.full_name != github.repository &&
32+
!startsWith(github.event.pull_request.head.ref, 'export-D') &&
33+
!contains(github.event.pull_request.labels.*.name, 'meta-exported') &&
34+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.pull_request.author_association)
35+
runs-on: ubuntu-latest
36+
permissions:
37+
contents: read
38+
outputs:
39+
image: ${{ steps.hash.outputs.image }}
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
persist-credentials: false
44+
- id: hash
45+
run: |
46+
set -eu
47+
CI_DOCKER_HASH="$(git rev-parse HEAD:.ci/docker)"
48+
echo "image=308535385114.dkr.ecr.us-east-1.amazonaws.com/executorch/ci-image:executorch-ubuntu-22.04-clang12-${CI_DOCKER_HASH}" >> "$GITHUB_OUTPUT"
49+
50+
xtensa:
51+
name: ${{ matrix.name }}
52+
needs: docker-image
53+
# Same gate as docker-image, so the job that holds the role does not depend
54+
# on needs-skip propagation alone.
55+
if: >-
56+
github.event.pull_request.head.repo.full_name != github.repository &&
57+
!startsWith(github.event.pull_request.head.ref, 'export-D') &&
58+
!contains(github.event.pull_request.labels.*.name, 'meta-exported') &&
59+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.pull_request.author_association)
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
include:
64+
- name: hifi4
65+
backend: hifi4
66+
script: .ci/scripts/build-cadence-xtensa.sh --no-run
67+
- name: hifi4 op tests
68+
backend: hifi4
69+
script: .ci/scripts/test-cadence-xtensa.sh
70+
- name: vision
71+
backend: vision
72+
script: .ci/scripts/build-cadence-xtensa.sh --no-run
73+
# Same runner as build-cadence-runner.yml: RJ-2025.5 xt-clang (vision) needs
74+
# a pod hostname of 46 characters or fewer, i.e. a label of 18 or fewer.
75+
runs-on: mt-l-x86iamx-8-64
76+
container:
77+
image: ${{ needs.docker-image.outputs.image }}
78+
environment: cadence
79+
permissions:
80+
id-token: write
81+
contents: read
82+
steps:
83+
- name: Fix workspace permissions
84+
shell: bash
85+
run: sudo chmod -R 777 "${GITHUB_WORKSPACE}" 2>/dev/null || true
86+
87+
- name: Check out the fork's head
88+
uses: actions/checkout@v4
89+
with:
90+
ref: ${{ github.event.pull_request.head.sha }}
91+
submodules: recursive
92+
persist-credentials: false
93+
allow-unsafe-pr-checkout: true
94+
95+
- name: Assume Cadence artifacts role
96+
uses: aws-actions/configure-aws-credentials@v4
97+
with:
98+
role-to-assume: ${{ vars.CADENCE_CI_AWS_ROLE }}
99+
aws-region: ${{ vars.CADENCE_CI_AWS_REGION }}
100+
101+
- name: Build and test
102+
env:
103+
BACKEND: ${{ matrix.backend }}
104+
XTENSA_S3_BUCKET: ${{ vars.CADENCE_CI_S3_BUCKET }}
105+
shell: bash
106+
run: |
107+
set -exo pipefail
108+
eval "$(/opt/conda/bin/conda shell.bash hook)"
109+
conda activate "$(conda env list --json | jq -r ".envs | .[-1]")"
110+
./install_requirements.sh > /dev/null
111+
pip install --quiet awscli
112+
if [ "${BACKEND}" != "vision" ]; then
113+
backends/cadence/install_requirements.sh
114+
fi
115+
source .ci/scripts/setup-xtensa-tools.sh "${BACKEND}"
116+
${{ matrix.script }}

0 commit comments

Comments
 (0)