This PR switches four lightweight workflows from `pull_request` to `pull_request_target` to stop GitHub from requiring manual approval when the `mathlib-lean-pr-testing[bot]` app triggers label events (e.g. adding `builds-mathlib`). Since the bot never lands commits on master, it is perpetually treated as a "first-time contributor" and every `pull_request` event it triggers requires approval. `pull_request_target` events always run without approval because they execute trusted code from the base branch. This is safe for all four workflows because none check out or execute code from the PR branch — they only read labels, PR body, and file lists from the event payload and API: - `awaiting-mathlib.yml` — checks label combinations - `awaiting-manual.yml` — checks label combinations - `pr-body.yml` — checks PR body formatting - `check-stdlib-flags.yml` — checks if stdlib_flags.h was modified via API Also adds explicit `permissions: pull-requests: read` to each workflow as a least-privilege hardening measure, since `pull_request_target` has access to secrets. Addresses the issue reported by Sebastian: https://lean-fro.zulipchat.com/#narrow/channel/398861-general/topic/mathlib.20pr-testing.20breakage.3F/near/575084348 🤖 Prepared with Claude Code --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1.8 KiB
YAML
41 lines
1.8 KiB
YAML
name: Check awaiting-mathlib label
|
|
|
|
on:
|
|
merge_group:
|
|
pull_request_target:
|
|
types: [opened, synchronize, reopened, labeled, unlabeled]
|
|
|
|
permissions:
|
|
pull-requests: read
|
|
|
|
jobs:
|
|
check-awaiting-mathlib:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check awaiting-mathlib label
|
|
id: check-awaiting-mathlib-label
|
|
if: github.event_name == 'pull_request_target'
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
const { labels, number: prNumber } = context.payload.pull_request;
|
|
const hasAwaiting = labels.some(label => label.name == "awaiting-mathlib");
|
|
const hasBreaks = labels.some(label => label.name == "breaks-mathlib");
|
|
const hasBuilds = labels.some(label => label.name == "builds-mathlib");
|
|
|
|
if (hasAwaiting && hasBreaks) {
|
|
core.setFailed('PR has both "awaiting-mathlib" and "breaks-mathlib" labels.');
|
|
} else if (hasAwaiting && !hasBreaks && !hasBuilds) {
|
|
core.info('PR is marked "awaiting-mathlib" but neither "breaks-mathlib" nor "builds-mathlib" labels are present.');
|
|
core.setOutput('awaiting', 'true');
|
|
}
|
|
|
|
- name: Wait for mathlib compatibility
|
|
if: github.event_name == 'pull_request_target' && steps.check-awaiting-mathlib-label.outputs.awaiting == 'true'
|
|
run: |
|
|
echo "::notice title=Awaiting mathlib::PR is marked 'awaiting-mathlib' but neither 'breaks-mathlib' nor 'builds-mathlib' labels are present."
|
|
echo "This check will remain in progress until the PR is updated with appropriate mathlib compatibility labels."
|
|
# Keep the job running indefinitely to show "in progress" status
|
|
while true; do
|
|
sleep 3600 # Sleep for 1 hour at a time
|
|
done
|