|
| 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