Skip to content

Commit c1385bb

Browse files
committed
upload-snapshot: fix discovery of the git-artifacts runs
When a `push` wants to trigger a new snapshot to be uploaded using already-built Git artifacts (which is the case when Git for Windows' "Rebase to <git-version>" PRs are "merged" by updating the `main` ref), after verifying that there is a valid `tag-git` Check Run, GitForWindowsHelper wants to find the associated `git-artifacts` workflow runs. They can be identified using the `tag-git` _workflow_ run, though, i.e. the ID of the workflow as run in `git-for-windows-automation`, not the mirrored _Check Run_ in `git-for-windows/git`. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 1924f55 commit c1385bb

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

GitForWindowsHelper/cascading-runs.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ const handlePush = async (context, req) => {
344344
if (!match[2] === commit) throw new Error(`Unexpected revision ${match[2]} '${latest.output.summary}' of tag-git run: ${latest.html_url}`)
345345
const ver = match[1]
346346

347+
const match2 = latest.output.text.match(/^For details, see \[this run\]\(https:\/\/github.com\/([^/]+)\/([^/]+)\/actions\/runs\/(\d+)\)/)
348+
if (!match2) throw new Error(`Unexpected summary '${latest.output.summary}' of tag-git run: ${latest.html_url}`)
349+
const [, , , tagGitWorkflowRunId] = match2
350+
347351
// There is already a `tag-git` workflow run; Is there already an `upload-snapshot` run?
348352
const latestUploadSnapshotRun = (await listCheckRunsForCommit(
349353
context,
@@ -381,7 +385,7 @@ const handlePush = async (context, req) => {
381385
workflowName
382386
)
383387
const needle =
384-
`Build Git ${ver} artifacts from commit ${commit} (tag-git run #${latest.id})`
388+
`Build Git ${ver} artifacts from commit ${commit} (tag-git run #${tagGitWorkflowRunId})`
385389
const latest2 = runs
386390
.filter(run => run.output.summary === needle)
387391
.sort((a, b) => a.id - b.id)

__tests__/index.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,10 @@ let mockListCheckRunsForCommit = jest.fn((_context, _token, _owner, _repo, rev,
465465
conclusion: 'success',
466466
status: 'completed',
467467
output: {
468-
summary: 'Tag Git already-tagged @88811'
468+
summary: 'Tag Git already-tagged @88811',
469+
text: 'For details, see [this run](https://github.com/x/y/actions/runs/123).\nTagged already-tagged\nDone!.'
469470
},
470-
id: 123
471+
id: 123456789
471472
}]
472473
if (checkRunName.startsWith('git-artifacts')) {
473474
const id = {

0 commit comments

Comments
 (0)