Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions GitForWindowsHelper/cascading-runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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.`
}
Expand Down
17 changes: 16 additions & 1 deletion GitForWindowsHelper/finalize-g4w-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
}
11 changes: 7 additions & 4 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`)
})
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -994,7 +997,7 @@ test('the third completed `git-artifacts-<arch>` 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
})
Expand Down