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
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"private": true,
"description": "Electron's PR monitoring bot",
"main": "lib/index.js",
"main": "index.js",
"scripts": {
"build": "tsc",
"lint": "prettier --list-different \"{src,spec}/**/*.ts\"",
Expand Down Expand Up @@ -31,11 +31,12 @@
"lint-staged": "^15.2.10",
"nock": "^14.0.10",
"prettier": "^3.3.3",
"typescript": "^5.8.3",
"typescript": "^5.9.3",
"vitest": "^3.0.5"
},
"dependencies": {
"@sentry/node": "^7.119.2",
"@tsconfig/node24": "^24.0.4",
"probot": "^14.2.1",
"semver": "^7.5.2"
},
Expand Down
4 changes: 2 additions & 2 deletions src/24-hour-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const labelShouldBeChecked = (label: Label) => {
export async function setUp24HourRule(probot: Probot, disableCronForTesting = false) {
probot.on(
['pull_request.opened', 'pull_request.unlabeled', 'pull_request.labeled'],
async (context: Context<'pull_request'>) => {
async (context) => {
const { action, pull_request: pr, repository } = context.payload;

// We only care about user labels adds for new-pr and semver labels.
Expand Down Expand Up @@ -209,7 +209,7 @@ export async function setUp24HourRule(probot: Probot, disableCronForTesting = fa
state: 'open',
page,
})
).data as PullRequest[]),
).data as unknown as PullRequest[]),
);
page++;
} while (lastPRCount < prs.length);
Expand Down
32 changes: 13 additions & 19 deletions src/api-review-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,32 +405,26 @@ export function setupAPIReviewStateManagement(probot: Probot) {
* If a PR is opened or synchronized, we want to ensure the
* API review check is up-to-date.
*/
probot.on(
['pull_request.synchronize', 'pull_request.opened'],
async (context: Context<'pull_request'>) => {
const pr = context.payload.pull_request as PullRequest;
await addOrUpdateAPIReviewCheck(context.octokit, pr);
},
);
probot.on(['pull_request.synchronize', 'pull_request.opened'], async (context) => {
const pr = context.payload.pull_request as PullRequest;
await addOrUpdateAPIReviewCheck(context.octokit, pr);
});

/**
* If a PR review is submitted, we want to ensure the API
* review check is up-to-date.
*/
probot.on(
'pull_request_review.submitted',
async (context: Context<'pull_request_review.submitted'>) => {
const pr = context.payload.pull_request as PullRequest;
const state = await addOrUpdateAPIReviewCheck(context.octokit, pr);
await checkPRReadyForMerge(context.octokit, pr, state);
},
);
probot.on('pull_request_review.submitted', async (context) => {
const pr = context.payload.pull_request as PullRequest;
const state = await addOrUpdateAPIReviewCheck(context.octokit, pr);
await checkPRReadyForMerge(context.octokit, pr, state);
});

/**
* If a PR with API review requirements is marked ready for review,
* we want to add the 'api-review/requested 🗳' label.
*/
probot.on('pull_request.ready_for_review', async (context: Context<'pull_request'>) => {
probot.on('pull_request.ready_for_review', async (context) => {
const { repository } = context.payload;
const pr = context.payload.pull_request as PullRequest;

Expand All @@ -454,7 +448,7 @@ export function setupAPIReviewStateManagement(probot: Probot) {
* If a PR with existing API review requirements is converted to draft status,
* we want to remove the 'api-review/requested 🗳' label.
*/
probot.on('pull_request.converted_to_draft', async (context: Context<'pull_request'>) => {
probot.on('pull_request.converted_to_draft', async (context) => {
const { repository } = context.payload;
const pr = context.payload.pull_request as PullRequest;

Expand Down Expand Up @@ -490,7 +484,7 @@ export function setupAPIReviewStateManagement(probot: Probot) {
* - If any api-review-{state} label besides api-review-requested is added, remove it.
* API approval is controlled solely by cation.
*/
probot.on('pull_request.labeled', async (context: Context<'pull_request.labeled'>) => {
probot.on('pull_request.labeled', async (context) => {
const {
label,
repository,
Expand Down Expand Up @@ -568,7 +562,7 @@ export function setupAPIReviewStateManagement(probot: Probot) {
* label.
*
*/
probot.on('pull_request.unlabeled', async (context: Context<'pull_request.unlabeled'>) => {
probot.on('pull_request.unlabeled', async (context) => {
const {
label,
sender: { login: initiator },
Expand Down
17 changes: 7 additions & 10 deletions src/deprecation-review-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,16 @@ export async function maybeAddChecklistComment(octokit: ProbotOctokit, pr: PullR
}

export function setupDeprecationReviewStateManagement(probot: Probot) {
probot.on(
['pull_request.synchronize', 'pull_request.opened'],
async (context: Context<'pull_request'>) => {
const pr = context.payload.pull_request as PullRequest;
await addOrUpdateDeprecationReviewCheck(context.octokit, pr);
},
);
probot.on(['pull_request.synchronize', 'pull_request.opened'], async (context) => {
const pr = context.payload.pull_request as PullRequest;
await addOrUpdateDeprecationReviewCheck(context.octokit, pr);
});

/**
* The deprecation-review/requested label initiates deprecation review,
* but the deprecation-review/complete label is solely controlled by cation
*/
probot.on('pull_request.labeled', async (context: Context<'pull_request.labeled'>) => {
probot.on('pull_request.labeled', async (context) => {
const {
label,
sender: { login: initiator },
Expand Down Expand Up @@ -242,7 +239,7 @@ export function setupDeprecationReviewStateManagement(probot: Probot) {
* did not remove a deprecation-review state label other than
* deprecation-review-requested.
*/
probot.on('pull_request.unlabeled', async (context: Context<'pull_request.unlabeled'>) => {
probot.on('pull_request.unlabeled', async (context) => {
const {
label,
sender: { login: initiator },
Expand Down Expand Up @@ -285,7 +282,7 @@ export function setupDeprecationReviewStateManagement(probot: Probot) {
}
});

probot.on('issue_comment.edited', async (context: Context<'issue_comment.edited'>) => {
probot.on('issue_comment.edited', async (context) => {
const {
comment,
issue: { labels, number: prNumber, pull_request: pr },
Expand Down
2 changes: 1 addition & 1 deletion src/enforce-semver-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function setupSemverLabelEnforcement(probot: Probot) {
'pull_request.labeled',
'pull_request.synchronize',
],
async (context: Context<'pull_request'>) => {
async (context) => {
const { pull_request: pr } = context.payload;

log('setupSemverLabelEnforcement', LogLevel.INFO, `Checking #${pr.number} for semver label`);
Expand Down
32 changes: 13 additions & 19 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2024",
"outDir": "lib",
"sourceMap": true,
"rootDir": "src",
"experimentalDecorators": true,
"allowJs": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"exclude": [
"node_modules",
"spec",
"lib",
"coverage",
"vitest.config.ts"
]
"extends": "@tsconfig/node24/tsconfig.json",
"compilerOptions": {
"sourceMap": true,
"strict": false,
"outDir": "lib",
"types": [
"node"
],
"declaration": true
},
"include": [
"src"
]
}
14 changes: 11 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,13 @@ __metadata:
languageName: node
linkType: hard

"@tsconfig/node24@npm:^24.0.4":
version: 24.0.4
resolution: "@tsconfig/node24@npm:24.0.4"
checksum: 10c0/9c5d4173204c6935c45d3ff0584fd423bd7d8bc3f6b246e646320ae584e4226b34ea1c66ec67cd16769c73e7e80f4cc562287b0acaa4ec81aa482463972ff83f
languageName: node
linkType: hard

"@types/chai@npm:^5.2.2":
version: 5.2.3
resolution: "@types/chai@npm:5.2.3"
Expand Down Expand Up @@ -1219,6 +1226,7 @@ __metadata:
resolution: "cation@workspace:."
dependencies:
"@sentry/node": "npm:^7.119.2"
"@tsconfig/node24": "npm:^24.0.4"
"@types/ioredis": "npm:^4.28.10"
"@types/node": "npm:^22.9.0"
"@vitest/coverage-v8": "npm:^3.0.5"
Expand All @@ -1228,7 +1236,7 @@ __metadata:
prettier: "npm:^3.3.3"
probot: "npm:^14.2.1"
semver: "npm:^7.5.2"
typescript: "npm:^5.8.3"
typescript: "npm:^5.9.3"
vitest: "npm:^3.0.5"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -3131,7 +3139,7 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.8.3":
"typescript@npm:^5.9.3":
version: 5.9.3
resolution: "typescript@npm:5.9.3"
bin:
Expand All @@ -3141,7 +3149,7 @@ __metadata:
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A^5.8.3#optional!builtin<compat/typescript>":
"typescript@patch:typescript@npm%3A^5.9.3#optional!builtin<compat/typescript>":
version: 5.9.3
resolution: "typescript@patch:typescript@npm%3A5.9.3#optional!builtin<compat/typescript>::version=5.9.3&hash=5786d5"
bin:
Expand Down