Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit f8f8981

Browse files
PatrickMennennpalm
authored andcommitted
fix: change module exports and upgrade vercel to latest release (#1005)
* bugfix: change module exports and upgrade vercel to latest release * bugfix: webhook.verify is now asynchronous
1 parent 92a0d8a commit f8f8981

File tree

11 files changed

+57
-47
lines changed

11 files changed

+57
-47
lines changed

Diff for: modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@types/request": "^2.48.4",
2222
"@typescript-eslint/eslint-plugin": "^4.28.0",
2323
"@typescript-eslint/parser": "^4.17.0",
24-
"@vercel/ncc": "0.27.0",
24+
"@vercel/ncc": "^0.29.0",
2525
"aws-sdk": "^2.888.0",
2626
"eslint": "^7.24.0",
2727
"jest": "^26.6.3",
@@ -33,4 +33,4 @@
3333
"request": "^2.88.2",
3434
"yn": "^4.0.0"
3535
}
36-
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { handle } from './syncer/handler';
22

33
// eslint-disable-next-line
4-
module.exports.handler = async (event: any, context: any, callback: any): Promise<any> => {
4+
export const handler = async (event: any, context: any, callback: any): Promise<void> => {
55
await handle();
6-
return callback();
6+
callback();
77
};

Diff for: modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -890,10 +890,10 @@
890890
"@typescript-eslint/types" "4.28.0"
891891
eslint-visitor-keys "^2.0.0"
892892

893-
"@vercel/ncc@0.27.0":
894-
version "0.27.0"
895-
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.27.0.tgz#c0cfeebb0bebb56052719efa4a0ecc090a932c76"
896-
integrity sha512-DllIJQapnU2YwewIhh/4dYesmMQw3h2cFtabECc/zSJHqUbNa0eJuEkRa6DXbZvh1YPWBtYQoPV17NlDpBw1Vw==
893+
"@vercel/ncc@^0.29.0":
894+
version "0.29.0"
895+
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.29.0.tgz#ac23fc23f1593b05c72360108bcf6d849d2f317a"
896+
integrity sha512-p+sB835wOSDdgm2mgFgSOcXJF84AqZ+vBEnnGS0sm8veA92Hia7sqH0qEnqeFilPl+cXtxbdh2er+WdlfbVCZA==
897897

898898
abab@^2.0.3, abab@^2.0.5:
899899
version "2.0.5"

Diff for: modules/runners/lambdas/runners/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@types/jest": "^26.0.20",
2121
"@typescript-eslint/eslint-plugin": "^4.17.0",
2222
"@typescript-eslint/parser": "^4.22.0",
23-
"@vercel/ncc": "0.27.0",
23+
"@vercel/ncc": "^0.29.0",
2424
"eslint": "^7.22.0",
2525
"jest": "^26.6.3",
2626
"jest-mock-extended": "^1.0.13",
@@ -41,4 +41,4 @@
4141
"typescript": "^4.2.3",
4242
"yn": "^4.0.0"
4343
}
44-
}
44+
}

Diff for: modules/runners/lambdas/runners/src/lambda.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
import { scaleUp } from './scale-runners/scale-up';
2-
import { scaleDown } from './scale-runners/scale-down';
1+
import { scaleUp as scaleUpAction } from './scale-runners/scale-up';
2+
import { scaleDown as scaleDownAction } from './scale-runners/scale-down';
33
import { SQSEvent, ScheduledEvent, Context } from 'aws-lambda';
44

5-
module.exports.scaleUp = async (event: SQSEvent, context: Context, callback: any) => {
5+
export const scaleUp = async (event: SQSEvent, context: Context, callback: any): Promise<void> => {
66
console.dir(event, { depth: 5 });
77
try {
88
for (const e of event.Records) {
9-
await scaleUp(e.eventSource, JSON.parse(e.body));
9+
await scaleUpAction(e.eventSource, JSON.parse(e.body));
1010
}
11-
return callback(null);
11+
12+
callback(null);
1213
} catch (e) {
1314
console.error(e);
14-
return callback('Failed handling SQS event');
15+
callback('Failed handling SQS event');
1516
}
1617
};
1718

18-
module.exports.scaleDown = async (event: ScheduledEvent, context: Context, callback: any) => {
19+
export const scaleDown = async (event: ScheduledEvent, context: Context, callback: any): Promise<void> => {
1920
try {
20-
scaleDown();
21-
return callback(null);
21+
scaleDownAction();
22+
callback(null);
2223
} catch (e) {
2324
console.error(e);
24-
return callback('Failed');
25+
callback('Failed');
2526
}
2627
};

Diff for: modules/runners/lambdas/runners/yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -983,10 +983,10 @@
983983
"@typescript-eslint/types" "4.27.0"
984984
eslint-visitor-keys "^2.0.0"
985985

986-
"@vercel/ncc@0.27.0":
987-
version "0.27.0"
988-
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.27.0.tgz#c0cfeebb0bebb56052719efa4a0ecc090a932c76"
989-
integrity sha512-DllIJQapnU2YwewIhh/4dYesmMQw3h2cFtabECc/zSJHqUbNa0eJuEkRa6DXbZvh1YPWBtYQoPV17NlDpBw1Vw==
986+
"@vercel/ncc@^0.29.0":
987+
version "0.29.0"
988+
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.29.0.tgz#ac23fc23f1593b05c72360108bcf6d849d2f317a"
989+
integrity sha512-p+sB835wOSDdgm2mgFgSOcXJF84AqZ+vBEnnGS0sm8veA92Hia7sqH0qEnqeFilPl+cXtxbdh2er+WdlfbVCZA==
990990

991991
abab@^2.0.3, abab@^2.0.5:
992992
version "2.0.5"

Diff for: modules/webhook/lambdas/webhook/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@types/node": "^15.12.2",
2222
"@typescript-eslint/eslint-plugin": "^4.22.0",
2323
"@typescript-eslint/parser": "^4.22.0",
24-
"@vercel/ncc": "0.27.0",
24+
"@vercel/ncc": "0.29.0",
2525
"aws-sdk": "^2.888.0",
2626
"body-parser": "^1.19.0",
2727
"eslint": "^7.29.0",
@@ -33,6 +33,6 @@
3333
},
3434
"dependencies": {
3535
"@octokit/rest": "^18.3.5",
36-
"@octokit/webhooks": "^8.5.4"
36+
"@octokit/webhooks": "^9.10.0"
3737
}
38-
}
38+
}

Diff for: modules/webhook/lambdas/webhook/src/lambda.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { handle as githubWebhook } from './webhook/handler';
1+
import { handle } from './webhook/handler';
22

3-
module.exports.githubWebhook = async (event: any, context: any, callback: any) => {
4-
const statusCode = await githubWebhook(event.headers, event.body);
5-
return callback(null, {
3+
export const githubWebhook = async (event: any, context: any, callback: any): Promise<void> => {
4+
const statusCode = await handle(event.headers, event.body);
5+
callback(null, {
66
statusCode: statusCode,
77
});
88
};

Diff for: modules/webhook/lambdas/webhook/src/webhook/handler.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,4 @@ describe('handler', () => {
9292
expect(resp).toBe(200);
9393
expect(sendActionRequest).toBeCalled();
9494
});
95-
9695
});

Diff for: modules/webhook/lambdas/webhook/src/webhook/handler.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IncomingHttpHeaders } from 'http';
22
import { Webhooks } from '@octokit/webhooks';
33
import { sendActionRequest } from '../sqs';
4-
import { CheckRunEvent } from '@octokit/webhooks-definitions/schema';
4+
import { CheckRunEvent } from '@octokit/webhooks-types';
55
import { decrypt } from '../kms';
66

77
export const handle = async (headers: IncomingHttpHeaders, payload: any): Promise<number> => {
@@ -29,7 +29,7 @@ export const handle = async (headers: IncomingHttpHeaders, payload: any): Promis
2929
const webhooks = new Webhooks({
3030
secret: secret,
3131
});
32-
if (!webhooks.verify(payload, signature)) {
32+
if (!(await webhooks.verify(payload, signature))) {
3333
console.error('Unable to verify signature!');
3434
return 401;
3535
}
@@ -41,7 +41,7 @@ export const handle = async (headers: IncomingHttpHeaders, payload: any): Promis
4141
if (githubEvent === 'check_run') {
4242
const body = JSON.parse(payload) as CheckRunEvent;
4343

44-
const repositoryWhiteListEnv = process.env.REPOSITORY_WHITE_LIST as string || "[]";
44+
const repositoryWhiteListEnv = (process.env.REPOSITORY_WHITE_LIST as string) || '[]';
4545
const repositoryWhiteList = JSON.parse(repositoryWhiteListEnv) as Array<string>;
4646

4747
if (repositoryWhiteList.length > 0) {

Diff for: modules/webhook/lambdas/webhook/yarn.lock

+22-12
Original file line numberDiff line numberDiff line change
@@ -634,20 +634,30 @@
634634
dependencies:
635635
"@octokit/openapi-types" "^7.3.2"
636636

637-
"@octokit/webhooks-definitions@3.67.3", "@octokit/webhooks-definitions@^3.67.3":
637+
"@octokit/webhooks-definitions@^3.67.3":
638638
version "3.67.3"
639639
resolved "https://registry.yarnpkg.com/@octokit/webhooks-definitions/-/webhooks-definitions-3.67.3.tgz#d2a905a90b04af8111982d0c13658a49fc4eecb9"
640640
integrity sha512-do4Z1r2OVhuI0ihJhQ8Hg+yPWnBYEBNuFNCrvtPKoYT1w81jD7pBXgGe86lYuuNirkDHb0Nxt+zt4O5GiFJfgA==
641641

642-
"@octokit/webhooks@^8.5.4":
643-
version "8.12.3"
644-
resolved "https://registry.yarnpkg.com/@octokit/webhooks/-/webhooks-8.12.3.tgz#8e30ac3534bbc65be39995664ee25ca6922f9e44"
645-
integrity sha512-rbzBG0XmzYtaLoeXZ2F4wyY3AaBbvnHT5OkSXxaF+OJTJLEdAKE6dtJsNYzB2mr2XYpe9pb198SrTeutKQeiQA==
642+
"@octokit/webhooks-methods@^2.0.0":
643+
version "2.0.0"
644+
resolved "https://registry.yarnpkg.com/@octokit/webhooks-methods/-/webhooks-methods-2.0.0.tgz#1108b9ea661ca6c81e4a8bfa63a09eb27d5bc2db"
645+
integrity sha512-35cfQ4YWlnZnmZKmIxlGPUPLtbkF8lr/A/1Sk1eC0ddLMwQN06dOuLc+dI3YLQS+T+MoNt3DIQ0NynwgKPilig==
646+
647+
"@octokit/[email protected]":
648+
version "4.2.0"
649+
resolved "https://registry.yarnpkg.com/@octokit/webhooks-types/-/webhooks-types-4.2.0.tgz#7c3798fe2c469eb62c5fc3440301e34bf288e6b7"
650+
integrity sha512-BbWkXK0ZLE2BXF7OKlrK5B7nCqgawEiZ7orzLls5rLZlepHy1LtFlh2DSe3McqJznlBh0JRk+/eUowgXfmKmIw==
651+
652+
"@octokit/webhooks@^9.10.0":
653+
version "9.11.0"
654+
resolved "https://registry.yarnpkg.com/@octokit/webhooks/-/webhooks-9.11.0.tgz#e2f491243dd2d0091a4aa24f683ac0958aa040e5"
655+
integrity sha512-0pgBcPtpSIfvJX4COVQbbAL2kndKYLC0kHxnqOEschoVUClLaU7f8xkNX9royJF4vg9dc2AVHVvd9QC8yVrdVw==
646656
dependencies:
647657
"@octokit/request-error" "^2.0.2"
648-
"@octokit/webhooks-definitions" "3.67.3"
658+
"@octokit/webhooks-methods" "^2.0.0"
659+
"@octokit/webhooks-types" "4.2.0"
649660
aggregate-error "^3.1.0"
650-
debug "^4.0.0"
651661

652662
"@sinonjs/commons@^1.7.0":
653663
version "1.8.3"
@@ -909,10 +919,10 @@
909919
"@typescript-eslint/types" "4.27.0"
910920
eslint-visitor-keys "^2.0.0"
911921

912-
"@vercel/ncc@0.27.0":
913-
version "0.27.0"
914-
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.27.0.tgz#c0cfeebb0bebb56052719efa4a0ecc090a932c76"
915-
integrity sha512-DllIJQapnU2YwewIhh/4dYesmMQw3h2cFtabECc/zSJHqUbNa0eJuEkRa6DXbZvh1YPWBtYQoPV17NlDpBw1Vw==
922+
"@vercel/ncc@0.29.0":
923+
version "0.29.0"
924+
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.29.0.tgz#ac23fc23f1593b05c72360108bcf6d849d2f317a"
925+
integrity sha512-p+sB835wOSDdgm2mgFgSOcXJF84AqZ+vBEnnGS0sm8veA92Hia7sqH0qEnqeFilPl+cXtxbdh2er+WdlfbVCZA==
916926

917927
abab@^2.0.3, abab@^2.0.5:
918928
version "2.0.5"
@@ -1606,7 +1616,7 @@ [email protected], debug@^2.2.0, debug@^2.3.3:
16061616
dependencies:
16071617
ms "2.0.0"
16081618

1609-
debug@4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1:
1619+
debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1:
16101620
version "4.3.1"
16111621
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee"
16121622
integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==

0 commit comments

Comments
 (0)