ci: add pyperformance benchmarking scripts and workflow (#8691) · RustPython/RustPython@8bdcebb · GitHub
Skip to content

Commit 8bdcebb

Browse files
morealclaude
andauthored
ci: add pyperformance benchmarking scripts and workflow (#8691)
* Add script to run upstream pyperformance against RustPython pyperformance can't be installed as-is on RustPython since pyperf hard-depends on psutil, a C extension RustPython cannot build or load (no CPython C-API / extension-module support). Since pyperf already disables psutil usage on interpreters reporting Py_GIL_DISABLED=1 (which RustPython does, having no GIL), a functionality-free pure-Python psutil stub is enough to satisfy pip's dependency resolution and unblock any pure-Python benchmark. scripts/pyperformance/run_all.py drives pyperformance (under a host CPython venv) with RustPython as the --python target, installs the stub via PIP_FIND_LINKS + --inherit-environ, and catalogs pass/fail/timeout per benchmark with an automatic failure classifier (C-extension build blocked vs. a genuine exception raised by the benchmark itself). Assisted-by: Claude Code:claude-sonnet-5 * pyperformance: support targeting any Python and comparing catalogs Generalize run_all.py from a RustPython-only runner to a --python/--label pair, so the same script can catalog a real CPython (with --no-psutil-stub, since it has a genuine psutil) alongside RustPython. Each label gets its own results/<label>/ subdirectory. Add compare.py, which loads two labels' catalogs and writes a per-benchmark Markdown table with both targets' status/mean and the candidate/baseline time ratio, plus the median slowdown across benchmarks both targets passed. Assisted-by: Claude Code:claude-sonnet-5 * ci: compare base, head and CPython with pyperformance on one runner A ratio between two pyperformance runs measured on different machines can move further than the change under review did, so a PR's numbers are only worth reading when base, head and CPython were measured back to back on the same runner. This adds a job that does exactly that -- two release builds kept side by side with the stdlib of their own commit, then three runs with nothing in between -- and posts the table as a PR comment. `pr_diff.py` renders the three catalogs `run_all.py` writes: per benchmark the CPython time, both RustPython times, both ratios against CPython, and the head/base change, with anything under 3% shown as `~` because a shared runner is not quiet enough to say more. The comment is handed to a `workflow_run` companion the same way `codspeed-comment.yaml` does it, since a `pull_request` run from a fork gets a read-only token however the workflow is configured. The job is opt-in behind a `run:pyperformance` label: it runs 28 benchmarks three times over and costs well over an hour, which most PRs do not need. `run_all.py` now forwards RUSTPYTHONPATH through pyperf, which a binary copied away from its checkout needs in order to find the stdlib at all; the two names go in one comma-separated `--inherit-environ`, because repeating the flag keeps only the last. Assisted-by: Claude Code:claude-fable-5-1 * ci: comment from the pyperformance run itself when the PR allows it The `workflow_run` companion only starts firing once it is on the default branch, so a pull request that introduces it -- this one -- would upload the table and never show it. A pull request opened from this repo carries a token that may write comments, so post it from the run that measured it and leave the companion to the forks that genuinely cannot. Both paths upsert on the same marker, so a fork PR that reaches the companion after this step was skipped still lands one comment. Assisted-by: Claude Code:claude-fable-5-1 * ci: address zizmor findings and fall back to head vs. CPython - Pin `actions/github-script` to the commit the rest of the repo pins it to; the hash carried over from an in-flight branch pointed elsewhere than the `v9.0.0` comment claimed (ref-version-mismatch). - Read the PR number, the CPython path and version, and the two commit shas from `env` rather than expanding them into the shell (template-injection). - Record the `workflow_run` trigger in `.github/zizmor.yml` next to the existing `pull_request_target` entry, with the same justification: the workflow reads one artifact and writes a comment, and never checks out or runs pull request code (dangerous-triggers). Building or measuring the base commit is now non-fatal, and `pr_diff.py` renders head against CPython alone when the base column has nothing in it -- a base that will not build should still leave a usable table rather than failing the job. The time and ratio columns are also named apart, since `| base | head | base | head |` gave no clue which pair was which. Assisted-by: Claude Code:claude-fable-5-1 * ci: derive pyperformance comment target from trusted workflow_run metadata pr_number.txt came from the artifact a `pull_request` run uploads, which a fork could tamper with to make this privileged `workflow_run` comment on an arbitrary PR/issue. Resolve the PR from context.payload.workflow_run instead (falling back to a commit-associated open PR lookup for workflow_dispatch runs), and escape any HTML comments already present in diff.md so they can't be mistaken for the marker. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * ci: grant actions:read to the pyperformance comment workflow download-artifact needs actions:read to fetch another run's artifact by run-id. Specifying a permissions block sets every unlisted scope to none, so without this the cross-run download silently failed for fork PRs -- the scenario this workflow exists for -- continue-on-error masked it, and the comment step found no diff.md and returned without posting. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: kill the whole process group on a benchmark timeout subprocess.run's own timeout only terminates the direct pyperformance process; pyperf re-execs the target interpreter as a child, which can survive the timeout and keep burning CPU into the next benchmark's measurement. Run each benchmark in its own session/process group instead, and on timeout SIGKILL the whole group via os.killpg. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: compute the head-vs-base cell from head_vs_base directly The cell was derived from base_vs_cpython and head_vs_cpython, both of which are None when a benchmark has no CPython time -- so it rendered "-" even though base and head both had valid times and head_vs_base was already computed. Use that precomputed ratio instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: invalidate the resumed catalog when the target executable changes catalog.json records results without any fingerprint of target_python, and resume skips benchmarks by name alone, so a local rebuild (or swapping the target) under the same --label could silently reuse stale measurements. Store a sha256 of the executable's contents alongside the catalog and, when it no longer matches, ignore the existing catalog and re-run everything. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * ci: fall back to github.sha for the head checkout on workflow_dispatch github.event.pull_request.head.sha is empty on a workflow_dispatch run (no pull_request payload), so `git checkout --quiet "" --` failed with "fatal: invalid reference" on this non-optional step, aborting every manual run before it could measure or render results. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: resolve --out/--cache-dir to absolute paths Every benchmark subprocess runs with cwd=work_dir (under --cache-dir), so a relative --out or --cache-dir passed on the command line resolved against that directory instead of the one run_all.py was invoked from, breaking catalog output, the pyperformance binary path, and PIP_FIND_LINKS. Both default to absolute paths already; resolve them up front so a relative override behaves the same way. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: persist catalog invalidation before the new fingerprint The fingerprint file was rewritten before the invalidated catalog was ever written back to disk. An interruption between the two (e.g. a crash during the first benchmark of the re-run) left a fingerprint matching the new executable pointing at a catalog.json still full of results measured against the old one, so the next run would trust it as fresh. Write the reset (empty) catalog first, then record the fingerprint. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: show benchmarks that fail on both base and head Rows were dropped whenever neither side had a mean, which also hid a benchmark that failed or timed out identically on base and head -- e.g. a C-extension gap unrelated to the PR under review. Only skip a benchmark never attempted on either commit; keep rows with a fail/timeout status so they still show up in the table. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: write catalog.json atomically write_catalog runs after every single benchmark, and Path.write_text truncates the file before writing the replacement. An interruption mid-write left catalog.json both missing every earlier result and invalid JSON, so the next run's resume logic failed outright at json.loads(). Write to a temporary sibling file and rename it into place instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: fix passed count and median population in the summary table "Benchmarks passed" counted len(base_ratios)/len(head_ratios), which require a *CPython* ratio too -- a CPython-only failure hid an otherwise-passing benchmark from both sides' counts. Count actual "ok" status per side instead. The two medians were also computed over independently-filtered populations: whichever benchmarks had a valid ratio on that side alone. A benchmark that regressed to failure on only one side dropped out of only that side's median, which could shift it well beyond what any surviving benchmark's timing actually changed by. Restrict both medians to benchmarks with a valid ratio on both sides, and label the population size. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: include RUSTPYTHONPATH's stdlib in the executable fingerprint The catalog-invalidation fingerprint hashed only the executable's bytes, but a RustPython binary copied away from its checkout finds its stdlib through RUSTPYTHONPATH -- pyperf re-execs the target interpreter into a venv and forwards that variable so it can still find Lib/. Changing that path, or editing the files under it, without rebuilding the binary left resume trusting results measured against a now-different stdlib. Fold its contents into the fingerprint too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: require an explicit ok/fail status for pass/fail transitions only_head/only_base flagged a benchmark as newly passing or no longer passing based only on whether the other side had a mean, so a benchmark never attempted on one side (e.g. a partial --benchmarks run) was reported as a regression or fix it never was. Require the other side's status to be an actual fail/timeout, not just missing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: don't gate the head/base geometric mean on a CPython ratio The summary panel -- pass counts and the head/base geometric mean, neither of which need a CPython comparison -- only rendered when at least one benchmark also had a valid ratio against CPython on both sides. A build with a perfectly good head-vs-base comparison but no common CPython result lost the whole panel, including the one aggregate that didn't depend on CPython at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: normalize RUSTPYTHONPATH and extract main() into named steps Fix: a relative RUSTPYTHONPATH was fingerprinted relative to this script's invocation directory but resolved by pyperf's subprocess relative to work_dir (its cwd), so a relative value could be hashed against the wrong directory entirely, or fail to resolve at runtime. Resolve it to an absolute path up front, alongside --out and --cache-dir. Refactor: main() had accumulated argparse setup, executable resolution, and the fingerprint/resume block inline, each wrapped in an explanatory comment -- a sign the function was doing too much rather than that it needed more narration. Extracted parse_args(), resolve_target_python(), and load_resumable_catalog() so main() reads as a short sequence of named steps and each comment sits next to the one function it actually explains. No behavior change; verified with unit tests against the extracted functions (fingerprint reacting to RUSTPYTHONPATH, resume picking up a prior catalog, invalidation on an executable change). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: split pr_diff.py's main() and fix a status-transition gap Fix: only_head was still gated on have_base, which only asks whether *any* base benchmark produced a timing -- so a benchmark that flipped from failing to passing went unreported whenever every other base benchmark also happened to fail. Status transitions don't need that gate; they already require an explicit ok/fail/timeout status on both sides. Refactor: main() had grown into one long function mixing argument parsing, catalog loading, row computation, and three separate rendering concerns. Split it into parse_args(), load_base_catalog(), build_rows(), render_intro(), render_summary_panel(), render_table(), and find_transitions(), each documenting the one thing it decides. No behavior change beyond the fix above; re-verified against every scenario exercised in the last several fixes (dual-fail rows, geo mean without a CPython ratio, unattempted benchmarks, and the have_base gap) plus the existing manual smoke tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * pyperformance: don't resolve an empty RUSTPYTHONPATH to the cwd The normalization only checked "RUSTPYTHONPATH" in os.environ, so a set-but- empty value (RUSTPYTHONPATH="") resolved to the current directory via Path("").resolve(). executable_fingerprint() would then recursively hash every file under wherever run_all.py was invoked from -- including its own results directory while writing to it -- causing spurious catalog invalidation and a lot of pointless hashing. Check for a nonempty value instead, matching the truthiness check already used everywhere else this variable is read. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv * docs(pyperformance): distinguish the host runner from the benchmarked target A reviewer read "pyperformance cannot be installed as-is on RustPython" and reasonably asked why RustPython would need to support pyperformance's CLI at all, since it's normally run as a command under any Python (see #8691 (comment)). It doesn't: the pyperformance CLI (the host process) always runs under a real CPython regardless of --python. What actually needs psutil/pyperf importable is the *benchmark* subprocess -- pyperf re-execs the --python target and that subprocess itself does `import pyperf`. Spell out that host/worker split up front instead of leading with "cannot be installed". Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy8J7LpmdYjesTDonNoYkv --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 7f0e797 commit 8bdcebb

10 files changed

Lines changed: 1437 additions & 1 deletion

File tree

Lines changed: 81 additions & 0 deletions
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
on:
2+
pull_request:
3+
types: [labeled, opened, synchronize, reopened]
4+
workflow_dispatch:
5+
6+
name: pyperformance
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
13+
cancel-in-progress: true
14+
15+
env:
16+
CARGO_INCREMENTAL: 0
17+
CARGO_TERM_COLOR: always
18+
CI: true
19+
# Pure-Python benchmarks only: anything whose workload needs a real C
20+
# extension cannot install under RustPython at all, and the async/SSL ones
21+
# are far too slow here to be worth a runner's time. Keep this list short --
22+
# every entry is paid for three times (CPython, base, head) in one job.
23+
BENCHMARKS: >-
24+
chaos,comprehensions,coroutines,deepcopy,deltablue,fannkuch,float,
25+
generators,go,hexiom,json_dumps,json_loads,logging,mdp,nbody,nqueens,
26+
pickle_pure_python,raytrace,regex_compile,regex_v8,richards,scimark,
27+
spectral_norm,telco,typing_runtime_protocols,unpack_sequence,
28+
unpickle_pure_python,xml_etree
29+
# A benchmark that needs longer than this on the base commit is one this
30+
# comparison cannot afford to wait for; it shows up as a failure in the
31+
# table, which is itself the interesting signal.
32+
BENCH_TIMEOUT: 300
33+
34+
jobs:
35+
compare:
36+
# `skip:ci` mirrors the other workflows; `run:pyperformance` opts a PR in,
37+
# because the job costs well over an hour and most PRs do not need it.
38+
if: >-
39+
github.event_name == 'workflow_dispatch' ||
40+
(!contains(github.event.pull_request.labels.*.name, 'skip:ci') &&
41+
contains(github.event.pull_request.labels.*.name, 'run:pyperformance'))
42+
name: base vs. head vs. CPython
43+
runs-on: ubuntu-latest
44+
timeout-minutes: 300
45+
permissions:
46+
contents: read
47+
# Honoured for a pull request opened from this repo, which is then
48+
# commented on directly by the last step; a fork's run is handed
49+
# read-only whatever is asked for here and goes the artifact route.
50+
pull-requests: write
51+
steps:
52+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
53+
with:
54+
ref: ${{ github.event.pull_request.head.sha }}
55+
fetch-depth: 0
56+
persist-credentials: false
57+
58+
- uses: dtolnay/rust-toolchain@stable
59+
60+
# Both the third interpreter under test and the host pyperformance
61+
# itself runs on (it only runs under a real CPython; RustPython is just
62+
# the `--python` target it drives).
63+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
64+
id: cpython
65+
with:
66+
python-version: "3.14"
67+
68+
- name: Restore cache
69+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
70+
with:
71+
path: |
72+
~/.cargo/registry/index/
73+
~/.cargo/registry/cache/
74+
~/.cargo/git/db/
75+
target/
76+
key: pyperformance-${{ hashFiles('**/Cargo.lock') }}
77+
restore-keys: pyperformance-
78+
continue-on-error: true
79+
80+
# The base commit may predate these scripts, and `git checkout <base>`
81+
# below would then delete them; run them from a copy outside the tree.
82+
- name: Copy the benchmark scripts out of the checkout
83+
run: cp -r scripts/pyperformance "${RUNNER_TEMP}/pyperformance-scripts"
84+
85+
# Each build is copied aside with the stdlib of its own commit, so the
86+
# second does not overwrite the first and a PR that touches `Lib/` is
87+
# still compared against the base commit's `Lib/`. A binary moved away
88+
# from its checkout finds the stdlib only through RUSTPYTHONPATH, which
89+
# `run_all.py` forwards through pyperf into the venv it builds.
90+
- name: Build head
91+
run: |
92+
cargo build --release --locked
93+
mkdir -p "${RUNNER_TEMP}/head"
94+
cp target/release/rustpython "${RUNNER_TEMP}/head/rustpython"
95+
cp -r Lib "${RUNNER_TEMP}/head/Lib"
96+
97+
- name: Build base
98+
continue-on-error: true # a base that cannot build leaves head vs. CPython
99+
env:
100+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
101+
run: |
102+
git checkout --quiet "${BASE_SHA}" --
103+
cargo build --release --locked
104+
mkdir -p "${RUNNER_TEMP}/base"
105+
cp target/release/rustpython "${RUNNER_TEMP}/base/rustpython"
106+
cp -r Lib "${RUNNER_TEMP}/base/Lib"
107+
108+
- name: Restore head checkout
109+
env:
110+
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
111+
run: git checkout --quiet "${HEAD_SHA}" --
112+
113+
- name: Save cache
114+
if: always()
115+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
116+
with:
117+
path: |
118+
~/.cargo/registry/index/
119+
~/.cargo/registry/cache/
120+
~/.cargo/git/db/
121+
target/
122+
key: pyperformance-${{ hashFiles('**/Cargo.lock') }}
123+
continue-on-error: true
124+
125+
# The three runs are deliberately adjacent, with no build between them,
126+
# so nothing but the interpreter differs across the comparison.
127+
- name: Measure CPython
128+
env:
129+
CPYTHON: ${{ steps.cpython.outputs.python-path }}
130+
run: |
131+
python3 "${RUNNER_TEMP}/pyperformance-scripts/run_all.py" \
132+
--python "${CPYTHON}" \
133+
--label cpython --no-psutil-stub \
134+
--benchmarks "${BENCHMARKS//[$'\n' ]/}" \
135+
--timeout "${BENCH_TIMEOUT}" --out "${RUNNER_TEMP}/pyperf-results"
136+
137+
- name: Measure base
138+
continue-on-error: true # as above: the table falls back to head alone
139+
env:
140+
RUSTPYTHONPATH: ${{ runner.temp }}/base/Lib
141+
run: |
142+
python3 "${RUNNER_TEMP}/pyperformance-scripts/run_all.py" \
143+
--python "${RUNNER_TEMP}/base/rustpython" \
144+
--label base \
145+
--benchmarks "${BENCHMARKS//[$'\n' ]/}" \
146+
--timeout "${BENCH_TIMEOUT}" --out "${RUNNER_TEMP}/pyperf-results"
147+
148+
- name: Measure head
149+
env:
150+
RUSTPYTHONPATH: ${{ runner.temp }}/head/Lib
151+
run: |
152+
python3 "${RUNNER_TEMP}/pyperformance-scripts/run_all.py" \
153+
--python "${RUNNER_TEMP}/head/rustpython" \
154+
--label head \
155+
--benchmarks "${BENCHMARKS//[$'\n' ]/}" \
156+
--timeout "${BENCH_TIMEOUT}" --out "${RUNNER_TEMP}/pyperf-results"
157+
158+
- name: Render the comparison
159+
env:
160+
CPYTHON_VERSION: ${{ steps.cpython.outputs.python-version }}
161+
PR_NUMBER: ${{ github.event.pull_request.number }}
162+
run: |
163+
python3 "${RUNNER_TEMP}/pyperformance-scripts/pr_diff.py" \
164+
--results-dir "${RUNNER_TEMP}/pyperf-results" \
165+
--cpython-version "CPython ${CPYTHON_VERSION}" \
166+
--md diff.md --json diff.json
167+
echo "${PR_NUMBER}" > pr_number.txt
168+
169+
# A `pull_request` run triggered from a fork carries a read-only token no
170+
# matter what this workflow grants, so the comment is posted from
171+
# `pyperformance-comment.yaml`, which `workflow_run` runs in the base
172+
# repo's context. This artifact is the hand-off.
173+
- name: Upload the comparison
174+
if: always()
175+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
176+
with:
177+
name: pyperformance-diff
178+
path: |
179+
diff.md
180+
diff.json
181+
pr_number.txt
182+
retention-days: 14
183+
if-no-files-found: ignore
184+
185+
# A pull request opened from this repo can be commented on from here,
186+
# which puts the table on the PR in the same run instead of waiting for
187+
# the companion workflow. Forks fall through to that workflow instead.
188+
- name: Post or update the PR comment
189+
if: >-
190+
github.event_name == 'pull_request' &&
191+
github.event.pull_request.head.repo.full_name == github.repository
192+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
193+
with:
194+
script: |
195+
const fs = require('fs');
196+
const body = fs.readFileSync('diff.md', 'utf8');
197+
const marker = '<!-- pyperformance-local-diff -->';
198+
199+
const comments = await github.paginate(github.rest.issues.listComments, {
200+
owner: context.repo.owner,
201+
repo: context.repo.repo,
202+
issue_number: context.payload.pull_request.number,
203+
});
204+
const existing = comments.find((c) => c.body && c.body.includes(marker));
205+
206+
if (existing) {
207+
await github.rest.issues.updateComment({
208+
owner: context.repo.owner,
209+
repo: context.repo.repo,
210+
comment_id: existing.id,
211+
body,
212+
});
213+
} else {
214+
await github.rest.issues.createComment({
215+
owner: context.repo.owner,
216+
repo: context.repo.repo,
217+
issue_number: context.payload.pull_request.number,
218+
body,
219+
});
220+
}

.github/zizmor.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ rules:
44
# pull_request_target is needed to label and assign PRs from forks with issues: write.
55
# The workflow does not check out or execute pull request code.
66
- oscca-pr.yml:3
7+
# workflow_run is needed to post a PR comment from a fork's run, which is
8+
# handed a read-only token however the triggering workflow is configured.
9+
# The workflow does not check out or execute pull request code: it reads
10+
# one artifact and writes a comment.
11+
- pyperformance-comment.yaml:1
712
excessive-permissions:
813
ignore:
914
# pull_request_target is needed to post PR comments with pull-requests: write.

.gitignore

Lines changed: 5 additions & 1 deletion

0 commit comments

Comments
 (0)