Skip to content

Commit

Permalink
Add the /updpkgsums slash command
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho committed Dec 17, 2023
1 parent d0bc49c commit 1c812b1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
29 changes: 29 additions & 0 deletions GitForWindowsHelper/slash-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,35 @@ module.exports = async (context, req) => {
return `I edited the comment: ${commentURL}`
}

if (command == '/updpkgsums') {
if (owner !== 'git-for-windows'
|| !req.body.issue.pull_request
|| !['build-extra', 'MINGW-packages', 'MSYS2-packages'].includes(repo)) {
return `Ignoring ${command} in unexpected repo: ${commentURL}`
}

await checkPermissions()
await thumbsUp()

const triggerWorkflowDispatch = require('./trigger-workflow-dispatch')
const answer = await triggerWorkflowDispatch(
context,
await getToken(),
'git-for-windows',
'git-for-windows-automation',
'updpkgsums.yml',
'main', {
repo,
'pr-number': issueNumber,
actor: commenter
}
);
const { appendToIssueComment } = require('./issues');
({ html_url: commentURL } = await appendToIssueComment(context, await getToken(), owner, repo, commentId, `The workflow run [was started](${answer.html_url}).`))

return `I edited the comment: ${commentURL}`
}

const deployMatch = command.match(/^\/deploy(\s+(\S+)\s*)?$/)
if (deployMatch) {
if (owner !== 'git-for-windows'
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ For convenience, the command can be abbreviated as `/add relnote <type> <message

**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).

### `/updpkgsums`

**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.

**What does it do?** Meant to update the checksums in `PKGBUILD` files that need to be modified to pass the integrity checks of `makepkg`.

### `/deploy [<package>]`

**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.
Expand Down
35 changes: 35 additions & 0 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,41 @@ The MINGW workflow run [was started](dispatched-workflow-open-pr.yml)`
})
})

testIssueComment('/updpkgsums', {
issue: {
number: 104,
title: 'Make tig launchable from PowerShell/Command Prompt',
body: 'Add tig.exe to /cmd/',
pull_request: {
html_url: 'https://github.com/git-for-windows/MINGW-packages/pull/104'
}
},
repository: {
name: 'MINGW-packages'
}
}, async (context) => {
expect(await index(context, context.req)).toBeUndefined()
expect(context.res).toEqual({
body: `I edited the comment: appended-comment-body-existing comment body
The workflow run [was started](dispatched-workflow-updpkgsums.yml).`,
headers: undefined,
status: undefined
})
expect(mockGetInstallationAccessToken).toHaveBeenCalledTimes(1)
expect(mockGitHubApiRequestAsApp).not.toHaveBeenCalled()
expect(dispatchedWorkflows).toHaveLength(1)
expect(dispatchedWorkflows.map(e => e.payload.inputs['pr-number'])).toEqual([104])
expect(mockGitHubApiRequest).toHaveBeenCalled()
const comment = mockGitHubApiRequest.mock.calls[mockGitHubApiRequest.mock.calls.length - 1]
expect(comment[3]).toEqual('/repos/git-for-windows/MINGW-packages/issues/comments/0')
expect(comment[4]).toEqual({
body: `existing comment body
The workflow run [was started](dispatched-workflow-updpkgsums.yml).`
})
})

let mockQueueCheckRun = jest.fn(() => 'check-run-id')
let mockUpdateCheckRun = jest.fn()
let mockListCheckRunsForCommit = jest.fn((_context, _token, _owner, _repo, rev, checkRunName) => {
Expand Down

0 comments on commit 1c812b1

Please sign in to comment.