Skip to content

Commit 69d272c

Browse files
committed
test-pr-comment-delivery.js: avoid messing with Check Runs
In 64b47fb (test-pr-comment-delivery: have an explicit way to avoid triggering runs, 2025-02-13), I modified the script so that no workflow runs would be triggered accidentally. The idea was to avoid changing state on github.com while debugging webhook event deliveries on my local machine, even though information may need to be looked up on github.com using the GitHub App credentials. What I missed was that there are more ways to mess up said state, e.g. by queuing Check Runs. This actually happened to me, where an accidentally-incorrect `tag-git` label was used when queuing the Check Run for an `upload-snapshot` workflow run, and it overwrote the existing one, but the existing one was very much needed to figure out which `git-artifacts` runs to use, and it took me over an hour to reconstruct everything into a healthy shape. Let's prevent future mishaps like that. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent aebb662 commit 69d272c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

GitForWindowsHelper/check-runs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
const queueCheckRun = async (context, token, owner, repo, ref, checkRunName, title, summary) => {
2+
if ('true' === process.env.DO_NOT_TRIGGER_ANYTHING) {
3+
throw new Error(`Would have queued Check Run ${checkRunName} in ${owner}/${repo} with ref ${ref}`)
4+
}
25
const githubApiRequest = require('./github-api-request')
36
// is there an existing check-run we can re-use?
47
const { check_runs } = await githubApiRequest(
@@ -47,6 +50,9 @@ const queueCheckRun = async (context, token, owner, repo, ref, checkRunName, tit
4750
}
4851

4952
const updateCheckRun = async (context, token, owner, repo, checkRunId, parameters) => {
53+
if ('true' === process.env.DO_NOT_TRIGGER_ANYTHING) {
54+
throw new Error(`Would have updated Check Run ${checkRunId} in ${owner}/${repo} with parameters ${JSON.stringify(parameters)}`)
55+
}
5056
const githubApiRequest = require('./github-api-request')
5157

5258
await githubApiRequest(
@@ -59,6 +65,9 @@ const updateCheckRun = async (context, token, owner, repo, checkRunId, parameter
5965
}
6066

6167
const cancelWorkflowRun = async (context, token, owner, repo, workflowRunId) => {
68+
if ('true' === process.env.DO_NOT_TRIGGER_ANYTHING) {
69+
throw new Error(`Would have canceled workflow run ${workflowRunId} in ${owner}/${repo}`)
70+
}
6271
const githubApiRequest = require('./github-api-request')
6372

6473
const answer = await githubApiRequest(

0 commit comments

Comments
 (0)