Skip to content

Narrow Arm PR trunk CI to the shared Arm suite #22846

Narrow Arm PR trunk CI to the shared Arm suite

Narrow Arm PR trunk CI to the shared Arm suite #22846

Workflow file for this run

name: Labeler

Check warning on line 1 in .github/workflows/labeler.yml

View workflow run for this annotation

GitHub Actions / Labeler

Workflow execution policy warning (evaluate mode)

On December 2, 2026, GitHub will restrict `pull_request_target` on public repositories by default. To continue allowing the event trigger, configure an Actions policy. Learn more: https://gh.io/securely-using-pull_request_target#default-policy-for-pull_request_target
# Arm routing policy: .github/arm-ci.md.
on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review, edited]
permissions:
contents: read
pull-requests: write
jobs:
label:
if: github.event.action != 'edited' || github.event.changes.base
concurrency:
group: labeler-${{ github.event.pull_request.number }}
cancel-in-progress: false
runs-on: ubuntu-latest
steps:
- name: Select Arm CI
uses: actions/github-script@v7
with:
retries: 2
script: |
const FULL = 'ciflow/trunk';
const ARM = 'ciflow/trunk-arm';
const isArm = path => path.startsWith('backends/arm/') || path.startsWith('examples/arm/');
const pull = { ...context.repo, pull_number: context.issue.number };
const issue = { ...context.repo, issue_number: context.issue.number };
let pr = context.payload.pull_request;
let files = [];
let complete = false;
let observedArm = false;
let reason = 'PR head or base kept changing while reading its diff.';
try {
for (let attempt = 0; attempt < 3; attempt++) {
files = [];
const { data: before } = await github.rest.pulls.get(pull);
pr = before;
if (pr.state !== 'open') return;
files = await github.paginate(github.rest.pulls.listFiles, { ...pull, per_page: 100 });
observedArm ||= files.some(file =>
[file.filename, file.previous_filename].filter(Boolean).some(isArm));
({ data: pr } = await github.rest.pulls.get(pull));
if (before.head.sha !== pr.head.sha || before.base.sha !== pr.base.sha) continue;
complete = files.length === pr.changed_files &&
new Set(files.map(file => file.filename)).size === files.length &&
files.every(file => file.filename &&
(!['renamed', 'copied'].includes(file.status) || file.previous_filename));
reason = 'The PR file list is incomplete.';
break;
}
} catch (error) {
reason = `Could not read the PR diff: ${error.message}`;
}
if (pr.state !== 'open') return;
const paths = files.flatMap(file => [file.filename, file.previous_filename].filter(Boolean));
const touchesArm = paths.some(isArm);
const labels = pr.labels.map(label => label.name);
let selected = null;
if (!complete) {
if (!observedArm && !labels.includes(ARM) && !labels.includes(FULL)) {
core.setFailed(`${reason} No CI labels were changed; re-run Labeler or request full CI explicitly.`);
return;
}
core.warning(`${reason} Requesting full trunk CI for the existing CI request or observed Arm changes.`);
selected = FULL;
} else if (touchesArm) {
let armOnly = paths.every(isArm) && !labels.includes(FULL);
if (armOnly) {
try {
const workflows = await Promise.all(['arm.yml', '_arm-trunk.yml'].map(file =>
github.rest.repos.getContent({ ...context.repo,
path: `.github/workflows/${file}`, ref: pr.head.sha })));
armOnly = workflows.every(({ data }) => data.type === 'file');
} catch (error) {
armOnly = false;
}
}
selected = armOnly ? ARM : FULL;
}
if (selected && !labels.includes(selected)) {
await github.rest.issues.addLabels({ ...issue, labels: [selected] });
}
if (selected !== ARM && labels.includes(ARM)) {
try {
await github.rest.issues.removeLabel({ ...issue, name: ARM });
} catch (error) {
if (error.status !== 404) throw error;
}
}
- uses: actions/labeler@v5
if: ${{ !cancelled() }}