Skip to content

Commit 2295665

Browse files
author
Takashi Matsuo
authored
deps(bot-config-utils)!: use gcf-utils 14 (#4143)
* deps(bot-config-utils)!: use gcf-utils 14 * build: drop node 12 support * deps(datastore-lock)!: use gcf-utils 14 * deps(issue-utils)!: use gcf-utils 14 * deps(object-selector)!: use gcf-utils 14 * build: install lru-cache as a dev dependency
1 parent 0717a6c commit 2295665

10 files changed

Lines changed: 18539 additions & 5203 deletions

File tree

packages/bot-config-utils/package-lock.json

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

packages/bot-config-utils/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@
1919
"dependencies": {
2020
"ajv": "^8.11.0",
2121
"js-yaml": "^4.1.0",
22-
"gcf-utils": "^13.8.1"
22+
"gcf-utils": "^14.0.0"
2323
},
2424
"devDependencies": {
25-
"@octokit/types": "^6.35.0",
25+
"@octokit/types": "^6.41.0",
2626
"@types/mocha": "^9.1.1",
27-
"@types/node": "^18.0.0",
28-
"@types/sinon": "^10.0.11",
29-
"c8": "^7.11.3",
27+
"@types/node": "^18.7.2",
28+
"@types/sinon": "^10.0.13",
29+
"c8": "^7.12.0",
3030
"cross-env": "^7.0.3",
3131
"dotenv": "^16.0.1",
3232
"gts": "^3.1.0",
3333
"mocha": "^10.0.0",
34-
"nock": "^13.2.7",
34+
"nock": "^13.2.9",
3535
"sinon": "^14.0.0",
3636
"snap-shot-it": "^7.9.6",
3737
"typescript": "~4.7.4"
3838
},
3939
"engines": {
40-
"node": ">= 12.18.2"
40+
"node": ">= 14"
4141
},
4242
"keywords": [
4343
"Bot config",

packages/bot-config-utils/test/bot-config-utils.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import {describe, it, beforeEach} from 'mocha';
2222
import {Probot, ProbotOctokit} from 'probot';
2323
// eslint-disable-next-line node/no-extraneous-import
2424
import {Octokit} from '@octokit/rest';
25+
import {getAuthenticatedOctokit} from 'gcf-utils';
26+
import * as gcfUtilsModule from 'gcf-utils';
27+
import * as sinon from 'sinon';
2528

2629
import {
2730
getConfig,
@@ -64,7 +67,7 @@ const app = (app: Probot) => {
6467
CONFIG_FILENAME
6568
);
6669
await configChecker.validateConfigChanges(
67-
context.octokit,
70+
await getAuthenticatedOctokit(context.payload.installation!.id),
6871
context.payload.pull_request.head.user.login,
6972
context.payload.repository.name,
7073
context.payload.pull_request.head.sha,
@@ -90,7 +93,7 @@ const app2 = (app: Probot) => {
9093
CONFIG_FILENAME_YML
9194
);
9295
await configChecker.validateConfigChanges(
93-
context.octokit,
96+
await getAuthenticatedOctokit(context.payload.installation!.id),
9497
context.payload.pull_request.head.user.login,
9598
context.payload.repository.name,
9699
context.payload.pull_request.head.sha,
@@ -116,7 +119,7 @@ const app3 = (app: Probot) => {
116119
[schema]
117120
);
118121
await configChecker.validateConfigChanges(
119-
context.octokit,
122+
await getAuthenticatedOctokit(context.payload.installation!.id),
120123
context.payload.pull_request.head.user.login,
121124
context.payload.repository.name,
122125
context.payload.pull_request.head.sha,
@@ -173,8 +176,11 @@ function fetchFilesInPR(configFile: string, fileName: string) {
173176
.reply(200, createConfigResponse(configFile));
174177
}
175178

179+
let getAuthenticatedOctokitStub: sinon.SinonStub;
180+
176181
describe('config test app with config.yml', () => {
177182
let probot: Probot;
183+
const sandbox = sinon.createSandbox();
178184
beforeEach(() => {
179185
probot = new Probot({
180186
githubToken: 'abc123',
@@ -184,12 +190,16 @@ describe('config test app with config.yml', () => {
184190
}),
185191
});
186192
probot.load(app2);
187-
});
188-
beforeEach(() => {
189193
nock.disableNetConnect();
194+
getAuthenticatedOctokitStub = sandbox.stub(
195+
gcfUtilsModule,
196+
'getAuthenticatedOctokit'
197+
);
198+
getAuthenticatedOctokitStub.resolves(new Octokit());
190199
});
191200
afterEach(() => {
192201
nock.cleanAll();
202+
sandbox.restore();
193203
});
194204
describe('responds to PR', () => {
195205
it('creates a failing status check for a wrong file name', async () => {
@@ -211,6 +221,7 @@ describe('config test app with config.yml', () => {
211221

212222
describe('config test app', () => {
213223
let probot: Probot;
224+
const sandbox = sinon.createSandbox();
214225
beforeEach(() => {
215226
probot = new Probot({
216227
githubToken: 'abc123',
@@ -223,9 +234,15 @@ describe('config test app', () => {
223234
// It always start from null.
224235
configFromConfigChecker = null;
225236
nock.disableNetConnect();
237+
getAuthenticatedOctokitStub = sandbox.stub(
238+
gcfUtilsModule,
239+
'getAuthenticatedOctokit'
240+
);
241+
getAuthenticatedOctokitStub.resolves(new Octokit());
226242
});
227243
afterEach(() => {
228244
nock.cleanAll();
245+
sandbox.restore();
229246
});
230247
describe('responds to PR', () => {
231248
it('does not die upon 404 github api responses', async () => {
@@ -311,6 +328,7 @@ describe('config test app', () => {
311328

312329
describe('config test app with multiple schema files', () => {
313330
let probot: Probot;
331+
const sandbox = sinon.createSandbox();
314332
beforeEach(() => {
315333
probot = new Probot({
316334
githubToken: 'abc123',
@@ -323,9 +341,15 @@ describe('config test app with multiple schema files', () => {
323341
// It always start from null.
324342
listConfigFromConfigChecker = null;
325343
nock.disableNetConnect();
344+
getAuthenticatedOctokitStub = sandbox.stub(
345+
gcfUtilsModule,
346+
'getAuthenticatedOctokit'
347+
);
348+
getAuthenticatedOctokitStub.resolves(new Octokit());
326349
});
327350
afterEach(() => {
328351
nock.cleanAll();
352+
sandbox.restore();
329353
});
330354
describe('responds to PR', () => {
331355
it('does not creates a failing status check for a correct config', async () => {

packages/datastore-lock/.mocharc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
const config = {
1515
"enable-source-maps": true,
1616
"throw-deprecation": true,
17-
"timeout": 20000
17+
"timeout": 120000
1818
}
1919
if (process.env.MOCHA_THROW_DEPRECATION === 'false') {
2020
delete config['throw-deprecation'];

0 commit comments

Comments
 (0)