Skip to content

Commit 1c812b1

Browse files
committed
Add the /updpkgsums slash command
As with most of the other slash commands, this triggers a GitHub workflow run in `git-for-windows-automation`, in this instance, unsurprisingly the `upkpkgsums.yml` one. The idea is to help contributors with their Pull Requests that fail CI builds solely due to mismatched checksums after modifying, adding or removing files from a package. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent d0bc49c commit 1c812b1

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

GitForWindowsHelper/slash-commands.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,35 @@ module.exports = async (context, req) => {
105105
return `I edited the comment: ${commentURL}`
106106
}
107107

108+
if (command == '/updpkgsums') {
109+
if (owner !== 'git-for-windows'
110+
|| !req.body.issue.pull_request
111+
|| !['build-extra', 'MINGW-packages', 'MSYS2-packages'].includes(repo)) {
112+
return `Ignoring ${command} in unexpected repo: ${commentURL}`
113+
}
114+
115+
await checkPermissions()
116+
await thumbsUp()
117+
118+
const triggerWorkflowDispatch = require('./trigger-workflow-dispatch')
119+
const answer = await triggerWorkflowDispatch(
120+
context,
121+
await getToken(),
122+
'git-for-windows',
123+
'git-for-windows-automation',
124+
'updpkgsums.yml',
125+
'main', {
126+
repo,
127+
'pr-number': issueNumber,
128+
actor: commenter
129+
}
130+
);
131+
const { appendToIssueComment } = require('./issues');
132+
({ html_url: commentURL } = await appendToIssueComment(context, await getToken(), owner, repo, commentId, `The workflow run [was started](${answer.html_url}).`))
133+
134+
return `I edited the comment: ${commentURL}`
135+
}
136+
108137
const deployMatch = command.match(/^\/deploy(\s+(\S+)\s*)?$/)
109138
if (deployMatch) {
110139
if (owner !== 'git-for-windows'

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ For convenience, the command can be abbreviated as `/add relnote <type> <message
3333

3434
**What does it do?** Meant to handle tickets labeled as `component-update` (typically created by [the `Monitor component updates` GitHub workflow](https://github.com/git-for-windows/git/actions/workflows/monitor-components.yml)) that notify the Git for Windows project when new versions are available of software that is shipped with Git for Windows, this command starts a [GitHub workflow run to open the corresponding Pull Request](https://github.com/git-for-windows/git-for-windows-automation/actions/workflows/open-pr.yml).
3535

36+
### `/updpkgsums`
37+
38+
**Where can it be called?** In Pull Requests of Git for Windows' [`build-extra`](https://github.com/git-for-windows/build-extra), [`MINGW-packages`](https://github.com/git-for-windows/MINGW-packages) and [`MSYS2-packages`](https://github.com/git-for-windows/MSYS2-packages) repositories.
39+
40+
**What does it do?** Meant to update the checksums in `PKGBUILD` files that need to be modified to pass the integrity checks of `makepkg`.
41+
3642
### `/deploy [<package>]`
3743

3844
**Where can it be called?** In Pull Requests of Git for Windows' [`build-extra`](https://github.com/git-for-windows/build-extra), [`MINGW-packages`](https://github.com/git-for-windows/MINGW-packages) and [`MSYS2-packages`](https://github.com/git-for-windows/MSYS2-packages) repositories.

__tests__/index.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,41 @@ The MINGW workflow run [was started](dispatched-workflow-open-pr.yml)`
307307
})
308308
})
309309

310+
testIssueComment('/updpkgsums', {
311+
issue: {
312+
number: 104,
313+
title: 'Make tig launchable from PowerShell/Command Prompt',
314+
body: 'Add tig.exe to /cmd/',
315+
pull_request: {
316+
html_url: 'https://github.com/git-for-windows/MINGW-packages/pull/104'
317+
}
318+
},
319+
repository: {
320+
name: 'MINGW-packages'
321+
}
322+
}, async (context) => {
323+
expect(await index(context, context.req)).toBeUndefined()
324+
expect(context.res).toEqual({
325+
body: `I edited the comment: appended-comment-body-existing comment body
326+
327+
The workflow run [was started](dispatched-workflow-updpkgsums.yml).`,
328+
headers: undefined,
329+
status: undefined
330+
})
331+
expect(mockGetInstallationAccessToken).toHaveBeenCalledTimes(1)
332+
expect(mockGitHubApiRequestAsApp).not.toHaveBeenCalled()
333+
expect(dispatchedWorkflows).toHaveLength(1)
334+
expect(dispatchedWorkflows.map(e => e.payload.inputs['pr-number'])).toEqual([104])
335+
expect(mockGitHubApiRequest).toHaveBeenCalled()
336+
const comment = mockGitHubApiRequest.mock.calls[mockGitHubApiRequest.mock.calls.length - 1]
337+
expect(comment[3]).toEqual('/repos/git-for-windows/MINGW-packages/issues/comments/0')
338+
expect(comment[4]).toEqual({
339+
body: `existing comment body
340+
341+
The workflow run [was started](dispatched-workflow-updpkgsums.yml).`
342+
})
343+
})
344+
310345
let mockQueueCheckRun = jest.fn(() => 'check-run-id')
311346
let mockUpdateCheckRun = jest.fn()
312347
let mockListCheckRunsForCommit = jest.fn((_context, _token, _owner, _repo, rev, checkRunName) => {

0 commit comments

Comments
 (0)