Repository navigation
77 lines (73 loc) · 3.53 KB
/
Copy pathagent-audience.yml
File metadata and controls
77 lines (73 loc) · 3.53 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
name: Agent audience
# A pull request names its owner and its reviewer in the body, and the review round calls that
# reviewer. A round that calls somebody else — or a body that names nobody — leaves the pull request
# waiting for a verdict while it looks like review is in flight (#911: #907 sat that way for four
# tips, and every call went to a member who was not the declared reviewer).
#
# This is a report, not a gate: `continue-on-error` keeps the check green whatever it finds, it only
# reads, and it writes the findings into the job summary. It never comments and never labels.
# Silence itself is not detectable (the repository has no "who read this" field); only a call to the
# wrong member, or a missing declaration, is.
#
# The one way this check can lie is by passing without reading anything: `continue-on-error` turns a
# crash into a green check, so the script must always be found. It is therefore checked out from the
# BASE commit -- a pull request must not be able to change the checker that audits it -- with the
# first-run fallback review-gate.yml uses: the pull request that introduces the script has no copy on
# the base yet, so that one run reads the copy in the pull request, under the same read-only token.
on:
pull_request:
types: [opened, edited, synchronize, reopened, ready_for_review]
issue_comment:
types: [created]
workflow_dispatch:
concurrency:
group: agent-audience-${{ github.event.pull_request.number || github.event.issue.number || 'all' }}
cancel-in-progress: true
permissions:
contents: read
issues: read
pull-requests: read
jobs:
audience:
name: agent-audience
# A comment on a plain issue is not a pull request.
if: github.event_name != 'issue_comment' || github.event.issue.pull_request != null
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha || github.event.repository.default_branch }}
path: base
persist-credentials: false
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: hashFiles('base/.github/scripts/agent-audience.mjs') == ''
with:
ref: ${{ github.event.pull_request.head.sha || github.event.repository.default_branch }}
path: pr
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
- name: Read the declared audience against the calls written this round
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
PR: ${{ github.event.pull_request.number || github.event.issue.number }}
run: |
dir="base"
if [ ! -f base/.github/scripts/agent-audience.mjs ]; then
echo "::notice::The base commit has no agent-audience script yet; using the copy in this pull request."
dir="pr"
fi
if [ ! -f "$dir/.github/scripts/agent-audience.mjs" ]; then
# Loud on purpose: a green check that read nothing is the failure this job exists to catch.
echo "::error::agent-audience: the checker is on neither the base commit nor this pull request; nothing was read."
exit 1
fi
if [ -n "$PR" ]; then
node "$dir/.github/scripts/agent-audience.mjs" --pr "$PR"
else
node "$dir/.github/scripts/agent-audience.mjs"
fi