From c2b466e9ff3ba292b6773e4edff7405802515453 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 13 Feb 2025 17:18:00 +0100 Subject: [PATCH] snapshot uploading: do upload the regular Git for Windows versions A regular Git for Windows version is branch-deployed in a Pull Request: It is built via the `/git-artifacts` slash command and then published via the `/release` slash command. Crucially, this build needs to be validated manually between the time when the `git-artifacts` workflows are done and the time when they are uploaded, and during that time window, the artifacts should _not_ be published as snapshots because if validation fails, they need to be rebuilt. The preceding two commits fixed the bug where the `upload-snapshot` workflow was run in that time window by mistake. However, when _do_ we want to upload the freshly-built official version as a new snapshot? Why, of course when the `main` branch is pushed. Except that we do not push at all, the `/release` slash command just updates the `main` ref, knowing fully well that no objects need to be pushed because `main` must fast-forward to the the PR branch when releasing a new Git for Windows version; This is enforced. And updating the ref via the REST API does not trigger the `push` event at all. Therefore we need to manually pretend that a `push` happened, and then all will be good again. Signed-off-by: Johannes Schindelin --- GitForWindowsHelper/finalize-g4w-release.js | 17 ++++++++++++++++- __tests__/index.test.js | 7 +++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/GitForWindowsHelper/finalize-g4w-release.js b/GitForWindowsHelper/finalize-g4w-release.js index d07a26fa..354a7b54 100644 --- a/GitForWindowsHelper/finalize-g4w-release.js +++ b/GitForWindowsHelper/finalize-g4w-release.js @@ -58,5 +58,20 @@ module.exports = async (context, req) => { force: false // require fast-forward }) - return `Took care of pushing the \`main\` branch to close PR ${prNumber}` + // trigger "upload artifacts" workflow + const { handlePush } = require('./cascading-runs') + const uploadSnapshotAnswer = await handlePush(context, { + body: { + repository: { + owner: { + login: owner, + }, + name: repo, + }, + ref: 'refs/heads/main', + after: sha, + } + }) + + return `Took care of pushing the \`main\` branch to close PR ${prNumber}\n${uploadSnapshotAnswer}` } \ No newline at end of file diff --git a/__tests__/index.test.js b/__tests__/index.test.js index 710f73d8..6fc9e44a 100644 --- a/__tests__/index.test.js +++ b/__tests__/index.test.js @@ -943,11 +943,14 @@ test('a completed `release-git` run updates the `main` branch in git-for-windows try { expect(await index(context, context.req)).toBeUndefined() expect(context.res).toEqual({ - body: `Took care of pushing the \`main\` branch to close PR 765`, + body: [ + 'Took care of pushing the `main` branch to close PR 765', + `The 'tag-git' workflow run was started at dispatched-workflow-tag-git.yml`, + ].join('\n'), headers: undefined, status: undefined }) - expect(mockGitHubApiRequest).toHaveBeenCalledTimes(4) + expect(mockGitHubApiRequest).toHaveBeenCalledTimes(7) expect(mockGitHubApiRequest.mock.calls[3].slice(1)).toEqual([ 'installation-access-token', 'PATCH',