Skip to content

Commit a02db2e

Browse files
committed
chore: bump probot to v14
1 parent 3bffc59 commit a02db2e

16 files changed

+1166
-3400
lines changed

package-lock.json

Lines changed: 788 additions & 3102 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525
},
2626
"homepage": "https://github.com/electron/cation#readme",
2727
"devDependencies": {
28+
"@types/ioredis": "^4.28.10",
2829
"@types/node": "^22.9.0",
2930
"@vitest/coverage-v8": "^3.0.5",
3031
"husky": "^9.1.6",
3132
"lint-staged": "^15.2.10",
32-
"nock": "^13.5.5",
33+
"nock": "^14.0.10",
3334
"prettier": "^3.3.3",
3435
"smee-client": "^2.0.4",
35-
"typescript": "^5.6.3",
36+
"typescript": "^5.8.3",
3637
"vitest": "^3.0.5"
3738
},
3839
"dependencies": {
39-
"@octokit/rest": "^20.1.1",
4040
"@sentry/node": "^7.119.2",
41-
"probot": "^12.4.0",
41+
"probot": "^14.2.1",
4242
"semver": "^7.5.2"
4343
},
4444
"lint-staged": {

spec/24-hour-rule.spec.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Context, Probot } from 'probot';
1+
import { Probot, ProbotOctokit } from 'probot';
22
import nock from 'nock';
33
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
44

@@ -21,6 +21,8 @@ import {
2121
} from '../src/constants';
2222
import { loadFixture } from './utils';
2323

24+
const GH_API = 'https://api.github.com';
25+
2426
const handler = async (app: Probot) => {
2527
setUp24HourRule(app, true);
2628
};
@@ -35,21 +37,29 @@ describe('pr open time', () => {
3537

3638
robot = new Probot({
3739
githubToken: 'test',
38-
secret: 'secret',
39-
privateKey: 'private key',
40-
appId: 690857,
40+
Octokit: ProbotOctokit.defaults({
41+
retry: { enabled: false },
42+
throttle: { enabled: false },
43+
}),
4144
});
4245

4346
moctokit = {
44-
issues: {
45-
listEventsForTimeline: vi.fn().mockReturnValue({ data: [] }),
47+
rest: {
48+
issues: {
49+
listEventsForTimeline: vi.fn().mockReturnValue({ data: [] }),
50+
},
4651
},
47-
} as any as Context['octokit'];
52+
} as any as ProbotOctokit;
4853

4954
robot.load(handler);
5055
});
5156

5257
afterEach(() => {
58+
if (!nock.isDone()) {
59+
// Output pending mocks to aid debugging when test fails.
60+
// eslint-disable-next-line no-console
61+
console.log('Pending nock mocks:', nock.pendingMocks());
62+
}
5363
expect(nock.isDone()).toEqual(true);
5464
nock.cleanAll();
5565
});
@@ -227,20 +237,21 @@ describe('pr open time', () => {
227237
// Set created_at to yesterday.
228238
payload.pull_request.created_at = new Date(+new Date() - 1000 * 60 * 60 * 24 * 2);
229239

230-
nock('https://api.github.com')
240+
// Timeline events (none) used by getPROpenedTime
241+
nock(GH_API)
231242
.get(`/repos/electron/electron/issues/${payload.number}/timeline`)
232243
.reply(200, []);
233244

234-
nock('https://api.github.com')
245+
nock(GH_API)
235246
.get(`/repos/electron/electron/issues/${payload.number}/labels?per_page=100&page=1`)
236247
.reply(200, [{ name: 'one' }, { name: 'two' }]);
237248

238-
nock('https://api.github.com')
249+
nock(GH_API)
239250
.post(`/repos/electron/electron/issues/${payload.number}/labels`, (body) => {
240-
expect(body).toEqual([NEW_PR_LABEL]);
251+
expect(body).toEqual({ labels: [NEW_PR_LABEL] });
241252
return true;
242253
})
243-
.reply(200);
254+
.reply(200, { labels: [{ name: NEW_PR_LABEL }] });
244255

245256
await robot.receive({
246257
id: '123-456',
@@ -256,7 +267,7 @@ describe('pr open time', () => {
256267
const msInADay = 1638370929101;
257268
payload.pull_request.created_at = new Date(+new Date() - msInADay * 5);
258269

259-
nock('https://api.github.com')
270+
nock(GH_API)
260271
.get(`/repos/electron/electron/issues/${payload.number}/timeline`)
261272
.reply(200, [
262273
{
@@ -266,7 +277,7 @@ describe('pr open time', () => {
266277
},
267278
]);
268279

269-
nock('https://api.github.com')
280+
nock(GH_API)
270281
.get(`/repos/electron/electron/issues/${payload.number}/labels?per_page=100&page=1`)
271282
.reply(200, [{ name: 'one' }, { name: 'two' }]);
272283

spec/add-triage-labels.spec.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { Probot } from 'probot';
1+
import { Probot , ProbotOctokit } from 'probot';
22
import nock from 'nock';
33
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
44

55
import { addBasicPRLabels } from '../src/add-triage-labels';
66
import { DOCUMENTATION_LABEL, SEMVER_LABELS, SEMVER_NONE_LABEL } from '../src/constants';
77
import { loadFixture } from './utils';
88

9+
const GH_API = 'https://api.github.com';
10+
911
const handler = async (app: Probot) => {
1012
addBasicPRLabels(app);
1113
};
@@ -19,9 +21,10 @@ describe('add-triage-labels', () => {
1921

2022
robot = new Probot({
2123
githubToken: 'test',
22-
secret: 'secret',
23-
privateKey: 'private key',
24-
appId: 690857,
24+
Octokit: ProbotOctokit.defaults({
25+
retry: { enabled: false },
26+
throttle: { enabled: false },
27+
}),
2528
});
2629

2730
robot.load(handler);
@@ -35,13 +38,13 @@ describe('add-triage-labels', () => {
3538
it('adds correct labels to documentation PRs', async () => {
3639
const payload = loadFixture('add-triage-labels/docs_pr_opened.json');
3740

38-
nock('https://api.github.com')
41+
nock(GH_API)
3942
.get(`/repos/electron/electron/issues/${payload.number}/labels?per_page=100&page=1`)
4043
.reply(200, []);
4144

42-
nock('https://api.github.com')
43-
.post(`/repos/electron/electron/issues/${payload.number}/labels`, (body) => {
44-
expect(body).toEqual([SEMVER_LABELS.PATCH, DOCUMENTATION_LABEL]);
45+
nock(GH_API)
46+
.post(`/repos/electron/electron/issues/${payload.number}/labels`, ({ labels }) => {
47+
expect(labels).toEqual([SEMVER_LABELS.PATCH, DOCUMENTATION_LABEL]);
4548
return true;
4649
})
4750
.reply(200);
@@ -56,13 +59,13 @@ describe('add-triage-labels', () => {
5659
it('adds correct labels to build PRs', async () => {
5760
const payload = loadFixture('add-triage-labels/build_pr_opened.json');
5861

59-
nock('https://api.github.com')
62+
nock(GH_API)
6063
.get(`/repos/electron/electron/issues/${payload.number}/labels?per_page=100&page=1`)
6164
.reply(200, []);
6265

63-
nock('https://api.github.com')
64-
.post(`/repos/electron/electron/issues/${payload.number}/labels`, (body) => {
65-
expect(body).toEqual([SEMVER_NONE_LABEL]);
66+
nock(GH_API)
67+
.post(`/repos/electron/electron/issues/${payload.number}/labels`, ({ labels }) => {
68+
expect(labels).toEqual([SEMVER_NONE_LABEL]);
6669
return true;
6770
})
6871
.reply(200);
@@ -77,13 +80,13 @@ describe('add-triage-labels', () => {
7780
it('adds correct labels to test PRs', async () => {
7881
const payload = loadFixture('add-triage-labels/test_pr_opened.json');
7982

80-
nock('https://api.github.com')
83+
nock(GH_API)
8184
.get(`/repos/electron/electron/issues/${payload.number}/labels?per_page=100&page=1`)
8285
.reply(200, []);
8386

84-
nock('https://api.github.com')
85-
.post(`/repos/electron/electron/issues/${payload.number}/labels`, (body) => {
86-
expect(body).toEqual([SEMVER_NONE_LABEL]);
87+
nock(GH_API)
88+
.post(`/repos/electron/electron/issues/${payload.number}/labels`, ({ labels }) => {
89+
expect(labels).toEqual([SEMVER_NONE_LABEL]);
8790
return true;
8891
})
8992
.reply(200);
@@ -98,13 +101,13 @@ describe('add-triage-labels', () => {
98101
it('adds correct labels to CI PRs', async () => {
99102
const payload = loadFixture('add-triage-labels/ci_pr_opened.json');
100103

101-
nock('https://api.github.com')
104+
nock(GH_API)
102105
.get(`/repos/electron/electron/issues/${payload.number}/labels?per_page=100&page=1`)
103106
.reply(200, []);
104107

105-
nock('https://api.github.com')
106-
.post(`/repos/electron/electron/issues/${payload.number}/labels`, (body) => {
107-
expect(body).toEqual([SEMVER_NONE_LABEL]);
108+
nock(GH_API)
109+
.post(`/repos/electron/electron/issues/${payload.number}/labels`, ({ labels }) => {
110+
expect(labels).toEqual([SEMVER_NONE_LABEL]);
108111
return true;
109112
})
110113
.reply(200);

0 commit comments

Comments
 (0)