diff --git a/GitForWindowsHelper/cascading-runs.js b/GitForWindowsHelper/cascading-runs.js index 961578d..35118b1 100644 --- a/GitForWindowsHelper/cascading-runs.js +++ b/GitForWindowsHelper/cascading-runs.js @@ -166,14 +166,15 @@ const cascadingRuns = async (context, req) => { // Next, check that the commit is on the `main` branch const gitToken = await getToken(context, checkRunOwner, checkRunRepo) - const { behind_by } = await githubApiRequest( + const { ahead_by, behind_by } = await githubApiRequest( context, gitToken, 'GET', `/repos/${checkRunOwner}/${checkRunRepo}/compare/HEAD...${commit}`, + // `/repos/dscho/git/compare/HEAD...${commit}`, ) - if (behind_by > 0) { - return `Ignoring ${name} check-run because its corresponding commit ${commit} is not on the main branch` + if (ahead_by > 0) { + return `Ignoring ${name} check-run because its corresponding commit ${commit} is not on the main branch (ahead by ${ahead_by}, behind by ${behind_by})` } const workFlowRunIDs = {} @@ -245,7 +246,7 @@ const cascadingRuns = async (context, req) => { } ) - return `The 'upload-snapshot' workflow run was started at ${answer.html_url}` + return `The 'upload-snapshot' workflow run was started at ${answer.html_url} (ahead by ${ahead_by}, behind by ${behind_by})` } return `Not a cascading run: ${name}; Doing nothing.` } diff --git a/GitForWindowsHelper/finalize-g4w-release.js b/GitForWindowsHelper/finalize-g4w-release.js index d07a26f..354a7b5 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 656763a..6fc9e44 100644 --- a/__tests__/index.test.js +++ b/__tests__/index.test.js @@ -175,7 +175,7 @@ The \`git-artifacts-aarch64\` workflow run [was started](dispatched-workflow-git } if (method === 'GET' && requestPath === '/repos/git-for-windows/git/compare/HEAD...0c796d3013a57e8cc894c152f0200107226e5dd1') { - return { behind_by: 0 } + return { ahead_by: 0, behind_by: 99 } } throw new Error(`Unhandled ${method}-${requestPath}-${JSON.stringify(payload)}`) }) @@ -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', @@ -994,7 +997,7 @@ test('the third completed `git-artifacts-` check-run triggers an `upload-s try { expect(await index(context, context.req)).toBeUndefined() expect(context.res).toEqual({ - body: `The 'upload-snapshot' workflow run was started at dispatched-workflow-upload-snapshot.yml`, + body: `The 'upload-snapshot' workflow run was started at dispatched-workflow-upload-snapshot.yml (ahead by 0, behind by 99)`, headers: undefined, status: undefined })