Skip to content

Commit fb43b1c

Browse files
authored
Merge pull request #1982 from gitgitgadget/add-the-action
This PR is part 3 of addressing #609, and it is stacked on top of #1980 and #1981 (and therefore contains also the commits of those PRs), therefore I will leave this in draft mode until those PRs are merged. The grand idea is to bundle the `CIHelper` class together with all its direct and transitive dependencies into one big, honking `dist/index.js`, and then add a set of really minimal GitHub Actions that call into `CIHelper`. The Actions are added in sub-directories so that they can be called in GitHub workflows via e.g. `- uses: gitgitgadget/gitgitgadget/update-prs@1`. The component used for bundling `CIHelper` is [`@vercel/ncc` ](https://www.npmjs.com/package/@vercel/ncc). To support acting as a GitHub Action, [`@actions/core`](https://www.npmjs.com/package/@actions/core) is installed. To allow for really minimal GitHub Actions, the `CIHelper` class is augmented accordingly to re-implement more logic that is currently either in `misc-helper.ts` or in the (non-public 😞) Azure Pipelines definitions. The naming convention for specifying the necessary tokens as GitHub Actions inputs is: - `upstream-repo-token`: This is to comment on PRs in `git/git` - `pr-repo-token`: This is to comment on PRs in `gitgitgadget/git` (as well as to be able to push to that repository) - `test-repo-token`: This is to comment on PRs in `dscho/git` (used exclusively for testing) To clarify, here is a diagram: ```mermaid graph TD user["user (contributor)"] upstream-repo["upstream-repo (authoritative project repo)"] pr-repo["pr-repo (GitGitGadget-enabled GitHub repo)"] GitGitGadget["GitGitGadget"] mailing-list["mailing-list"] user -->|"opens PR"| pr-repo user -->|"opens PR (if GitHub App installed)"| upstream-repo upstream-repo -->|"GitGitGadget syncs branches to"| pr-repo pr-repo -->|"slash commands"| GitGitGadget upstream-repo -->|"slash commands (if App installed)"| GitGitGadget GitGitGadget -->|"sends patch series"| mailing-list ```
2 parents 6416a6b + a209ca3 commit fb43b1c

File tree

17 files changed

+542
-5
lines changed

17 files changed

+542
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/.env
33
/.test-dir/
44
/build/
5+
/dist/**/*.d.ts
56
/node_modules/
67
/npm-debug.log
78
/junit.xml

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
"CIsmtphost",
9797
"CIsmtppass",
9898
"CIsmtpopts",
99+
"GITGIT_(|DIR|GIT_REMOTE|MAIL_REMOTE|MAIL_EPOCH)",
100+
"mailrepo",
101+
"parsePRURLInput",
99102
"users\\.noreply\\.github\\.com",
100103
],
101104
"cSpell.language": "en-US",

handle-new-mails/action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Handle new mails'
2+
description: 'Processes new mails on the Git mailing list'
3+
author: 'Johannes Schindelin'
4+
inputs:
5+
pr-repo-token:
6+
description: 'The access token to work on the repository that holds PRs and state'
7+
required: true
8+
upstream-repo-token:
9+
description: 'The access token to work on PRs in the upstream repository'
10+
required: true
11+
test-repo-token:
12+
description: 'The access token to work on PRs in the test repository'
13+
required: true
14+
runs:
15+
using: 'node20'
16+
main: './index.js'
17+
branding:
18+
icon: 'git-commit'
19+
color: 'orange'

handle-new-mails/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
async function run() {
2+
const { CIHelper } = await import("../dist/index.js")
3+
4+
const ci = new CIHelper()
5+
6+
await ci.setupGitHubAction({
7+
needsMailingListMirror: true,
8+
})
9+
await ci.handleNewMails()
10+
}
11+
12+
run()

handle-pr-comment/action.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: 'Handle PR Comment'
2+
description: 'Handles slash commands such as /submit and /preview'
3+
author: 'Johannes Schindelin'
4+
inputs:
5+
pr-repo-token:
6+
description: 'The access token to work on the repository that holds PRs and state'
7+
required: true
8+
upstream-repo-token:
9+
description: 'The access token to work on PRs in the upstream repository'
10+
required: true
11+
test-repo-token:
12+
description: 'The access token to work on PRs in the test repository'
13+
required: true
14+
smtp-host:
15+
description: 'The SMTP host to use for sending emails'
16+
required: true
17+
smtp-user:
18+
description: 'The SMTP user when sending emails'
19+
required: true
20+
smtp-opts:
21+
description: 'Extra SMTP options in JSON format'
22+
required: false
23+
smtp-pass:
24+
description: 'The SMTP password to use for sending emails'
25+
required: true
26+
pr-comment-url:
27+
description: 'The URL of the PR comment to add a reaction to'
28+
required: true
29+
runs:
30+
using: 'node20'
31+
main: './index.js'
32+
branding:
33+
icon: 'git-commit'
34+
color: 'orange'

handle-pr-comment/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
async function run() {
2+
const { CIHelper } = await import("../dist/index.js")
3+
4+
const ci = new CIHelper()
5+
const { owner, commentId } = ci.parsePRCommentURLInput()
6+
7+
await ci.setupGitHubAction()
8+
await ci.handleComment(owner, commentId)
9+
}
10+
11+
run()

handle-pr-push/action.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Handle PR Pushes'
2+
description: 'Handles when a PR was pushed'
3+
author: 'Johannes Schindelin'
4+
inputs:
5+
pr-repo-token:
6+
description: 'The access token to work on the repository that holds PRs and state'
7+
required: true
8+
upstream-repo-token:
9+
description: 'The access token to work on PRs in the upstream repository'
10+
required: true
11+
test-repo-token:
12+
description: 'The access token to work on PRs in the test repository'
13+
required: true
14+
pr-url:
15+
description: 'The URL of the PR that was pushed'
16+
required: true
17+
runs:
18+
using: 'node20'
19+
main: './index.js'
20+
branding:
21+
icon: 'git-commit'
22+
color: 'orange'

handle-pr-push/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
async function run() {
2+
const { CIHelper } = await import("../dist/index.js")
3+
4+
const ci = new CIHelper()
5+
const { owner, prNumber } = ci.parsePRURLInput()
6+
7+
await ci.setupGitHubAction()
8+
await ci.handlePush(owner, prNumber)
9+
}
10+
11+
run()

0 commit comments

Comments
 (0)