-
Notifications
You must be signed in to change notification settings - Fork 3k
95 lines (86 loc) · 3.36 KB
/
Copy pathreal-behavior-proof.yml
File metadata and controls
95 lines (86 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Real behavior proof
# Check that PRs from external contributors include a real problem
# description and validation evidence in the PR body. Maintainer and
# bot PRs are auto-skipped.
#
# Ported from openclaw's real-behavior-proof system. Complements
# pr-spam-gate (which filters by volume) with a quality filter.
on:
pull_request_target:
types: [opened, edited, synchronize, reopened, ready_for_review, labeled, unlabeled]
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
cancel-in-progress: true
jobs:
real-behavior-proof:
name: Real behavior proof
permissions:
contents: read
issues: write
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Use the workflow revision, not the PR head — never run
# untrusted PR code.
ref: ${{ github.workflow_sha }}
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Check real behavior proof
env:
GITHUB_TOKEN: ${{ github.token }}
run: python scripts/github/real_behavior_proof_check.py
- name: Add needs-context label on failure
# Fork PRs do not have permission to write labels on the target
# repository, so label manipulation is restricted to same-repo PRs.
# The proof check itself still runs for fork PRs.
if: |
failure() &&
github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
const labels = pr.labels.map(l => l.name);
if (!labels.includes("triage: needs-pr-context")) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["triage: needs-pr-context"],
});
}
- name: Remove needs-context label on success
# Same restriction as the add-label step above: fork PRs cannot
# write labels on the target repository.
if: |
success() &&
github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
const labels = pr.labels.map(l => l.name);
if (labels.includes("triage: needs-pr-context")) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: "triage: needs-pr-context",
});
}