Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: change module exports and upgrade vercel to latest release #1005

Merged
merged 2 commits into from
Jul 26, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/request": "^2.48.4",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.17.0",
"@vercel/ncc": "0.27.0",
"@vercel/ncc": "^0.29.0",
"aws-sdk": "^2.888.0",
"eslint": "^7.24.0",
"jest": "^26.6.3",
Expand All @@ -33,4 +33,4 @@
"request": "^2.88.2",
"yn": "^4.0.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { handle } from './syncer/handler';

// eslint-disable-next-line
module.exports.handler = async (event: any, context: any, callback: any): Promise<any> => {
export const handler = async (event: any, context: any, callback: any): Promise<void> => {
await handle();
return callback();
callback();
};
Original file line number Diff line number Diff line change
Expand Up @@ -890,10 +890,10 @@
"@typescript-eslint/types" "4.28.0"
eslint-visitor-keys "^2.0.0"

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

abab@^2.0.3, abab@^2.0.5:
version "2.0.5"
Expand Down
4 changes: 2 additions & 2 deletions modules/runners/lambdas/runners/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@types/jest": "^26.0.20",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.22.0",
"@vercel/ncc": "0.27.0",
"@vercel/ncc": "^0.29.0",
"eslint": "^7.22.0",
"jest": "^26.6.3",
"jest-mock-extended": "^1.0.13",
Expand All @@ -41,4 +41,4 @@
"typescript": "^4.2.3",
"yn": "^4.0.0"
}
}
}
21 changes: 11 additions & 10 deletions modules/runners/lambdas/runners/src/lambda.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import { scaleUp } from './scale-runners/scale-up';
import { scaleDown } from './scale-runners/scale-down';
import { scaleUp as scaleUpAction } from './scale-runners/scale-up';
import { scaleDown as scaleDownAction } from './scale-runners/scale-down';
import { SQSEvent, ScheduledEvent, Context } from 'aws-lambda';

module.exports.scaleUp = async (event: SQSEvent, context: Context, callback: any) => {
export const scaleUp = async (event: SQSEvent, context: Context, callback: any): Promise<void> => {
console.dir(event, { depth: 5 });
try {
for (const e of event.Records) {
await scaleUp(e.eventSource, JSON.parse(e.body));
await scaleUpAction(e.eventSource, JSON.parse(e.body));
}
return callback(null);

callback(null);
} catch (e) {
console.error(e);
return callback('Failed handling SQS event');
callback('Failed handling SQS event');
}
};

module.exports.scaleDown = async (event: ScheduledEvent, context: Context, callback: any) => {
export const scaleDown = async (event: ScheduledEvent, context: Context, callback: any): Promise<void> => {
try {
scaleDown();
return callback(null);
scaleDownAction();
callback(null);
} catch (e) {
console.error(e);
return callback('Failed');
callback('Failed');
}
};
8 changes: 4 additions & 4 deletions modules/runners/lambdas/runners/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -983,10 +983,10 @@
"@typescript-eslint/types" "4.27.0"
eslint-visitor-keys "^2.0.0"

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

abab@^2.0.3, abab@^2.0.5:
version "2.0.5"
Expand Down
6 changes: 3 additions & 3 deletions modules/webhook/lambdas/webhook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/node": "^15.12.2",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@vercel/ncc": "0.27.0",
"@vercel/ncc": "0.29.0",
"aws-sdk": "^2.888.0",
"body-parser": "^1.19.0",
"eslint": "^7.29.0",
Expand All @@ -33,6 +33,6 @@
},
"dependencies": {
"@octokit/rest": "^18.3.5",
"@octokit/webhooks": "^8.5.4"
"@octokit/webhooks": "^9.10.0"
}
}
}
8 changes: 4 additions & 4 deletions modules/webhook/lambdas/webhook/src/lambda.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { handle as githubWebhook } from './webhook/handler';
import { handle } from './webhook/handler';

module.exports.githubWebhook = async (event: any, context: any, callback: any) => {
const statusCode = await githubWebhook(event.headers, event.body);
return callback(null, {
export const githubWebhook = async (event: any, context: any, callback: any): Promise<void> => {
const statusCode = await handle(event.headers, event.body);
callback(null, {
statusCode: statusCode,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,4 @@ describe('handler', () => {
expect(resp).toBe(200);
expect(sendActionRequest).toBeCalled();
});

});
6 changes: 3 additions & 3 deletions modules/webhook/lambdas/webhook/src/webhook/handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IncomingHttpHeaders } from 'http';
import { Webhooks } from '@octokit/webhooks';
import { sendActionRequest } from '../sqs';
import { CheckRunEvent } from '@octokit/webhooks-definitions/schema';
import { CheckRunEvent } from '@octokit/webhooks-types';
import { decrypt } from '../kms';

export const handle = async (headers: IncomingHttpHeaders, payload: any): Promise<number> => {
Expand Down Expand Up @@ -29,7 +29,7 @@ export const handle = async (headers: IncomingHttpHeaders, payload: any): Promis
const webhooks = new Webhooks({
secret: secret,
});
if (!webhooks.verify(payload, signature)) {
if (!(await webhooks.verify(payload, signature))) {
console.error('Unable to verify signature!');
return 401;
}
Expand All @@ -41,7 +41,7 @@ export const handle = async (headers: IncomingHttpHeaders, payload: any): Promis
if (githubEvent === 'check_run') {
const body = JSON.parse(payload) as CheckRunEvent;

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

if (repositoryWhiteList.length > 0) {
Expand Down
34 changes: 22 additions & 12 deletions modules/webhook/lambdas/webhook/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -634,20 +634,30 @@
dependencies:
"@octokit/openapi-types" "^7.3.2"

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

"@octokit/webhooks@^8.5.4":
version "8.12.3"
resolved "https://registry.yarnpkg.com/@octokit/webhooks/-/webhooks-8.12.3.tgz#8e30ac3534bbc65be39995664ee25ca6922f9e44"
integrity sha512-rbzBG0XmzYtaLoeXZ2F4wyY3AaBbvnHT5OkSXxaF+OJTJLEdAKE6dtJsNYzB2mr2XYpe9pb198SrTeutKQeiQA==
"@octokit/webhooks-methods@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@octokit/webhooks-methods/-/webhooks-methods-2.0.0.tgz#1108b9ea661ca6c81e4a8bfa63a09eb27d5bc2db"
integrity sha512-35cfQ4YWlnZnmZKmIxlGPUPLtbkF8lr/A/1Sk1eC0ddLMwQN06dOuLc+dI3YLQS+T+MoNt3DIQ0NynwgKPilig==

"@octokit/[email protected]":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@octokit/webhooks-types/-/webhooks-types-4.2.0.tgz#7c3798fe2c469eb62c5fc3440301e34bf288e6b7"
integrity sha512-BbWkXK0ZLE2BXF7OKlrK5B7nCqgawEiZ7orzLls5rLZlepHy1LtFlh2DSe3McqJznlBh0JRk+/eUowgXfmKmIw==

"@octokit/webhooks@^9.10.0":
version "9.11.0"
resolved "https://registry.yarnpkg.com/@octokit/webhooks/-/webhooks-9.11.0.tgz#e2f491243dd2d0091a4aa24f683ac0958aa040e5"
integrity sha512-0pgBcPtpSIfvJX4COVQbbAL2kndKYLC0kHxnqOEschoVUClLaU7f8xkNX9royJF4vg9dc2AVHVvd9QC8yVrdVw==
dependencies:
"@octokit/request-error" "^2.0.2"
"@octokit/webhooks-definitions" "3.67.3"
"@octokit/webhooks-methods" "^2.0.0"
"@octokit/webhooks-types" "4.2.0"
aggregate-error "^3.1.0"
debug "^4.0.0"

"@sinonjs/commons@^1.7.0":
version "1.8.3"
Expand Down Expand Up @@ -909,10 +919,10 @@
"@typescript-eslint/types" "4.27.0"
eslint-visitor-keys "^2.0.0"

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

abab@^2.0.3, abab@^2.0.5:
version "2.0.5"
Expand Down Expand Up @@ -1606,7 +1616,7 @@ [email protected], debug@^2.2.0, debug@^2.3.3:
dependencies:
ms "2.0.0"

debug@4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1:
debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee"
integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==
Expand Down