From d093a22c28a5adb29373eb200a710d1cf335d5ce Mon Sep 17 00:00:00 2001 From: Denis Isaev Date: Sun, 17 May 2020 18:05:37 +0300 Subject: [PATCH] dev: fix peril --- .github/peril/README.md | 7 +++++++ .github/peril/rules/invite-collaborator.ts | 9 ++++++--- .github/peril/tests/invite-collaborator.test.ts | 6 +++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/peril/README.md b/.github/peril/README.md index d59d5f9a..49251431 100644 --- a/.github/peril/README.md +++ b/.github/peril/README.md @@ -1 +1,8 @@ Based on https://github.com/gatsbyjs/gatsby/tree/master/peril. + +## Update a code + +```bash +heroku ps:restart web --app golangci-peril +heroku logs --app golangci-peril -t +``` diff --git a/.github/peril/rules/invite-collaborator.ts b/.github/peril/rules/invite-collaborator.ts index 0a7948b9..731622a6 100644 --- a/.github/peril/rules/invite-collaborator.ts +++ b/.github/peril/rules/invite-collaborator.ts @@ -28,7 +28,7 @@ export const inviteCollaborator = async () => { // Check whether or not we’ve already invited this contributor. try { - const inviteCheck = (await api.orgs.getTeamMembership({ + const inviteCheck = (await api.teams.getMembership({ team_id: teamId, username, } as any)) as any; @@ -41,12 +41,15 @@ export const inviteCollaborator = async () => { ); return; } - } catch (_) { + } catch (err) { + console.info( + `Error checking membership of ${username} in team ${teamId}: ${err.stack}` + ); // If the user hasn’t been invited, the invite check throws an error. } try { - const invite = await api.orgs.addTeamMembership({ + const invite = await api.teams.addOrUpdateMembership({ team_id: teamId, username, } as any); diff --git a/.github/peril/tests/invite-collaborator.test.ts b/.github/peril/tests/invite-collaborator.test.ts index ff82e699..6421598b 100644 --- a/.github/peril/tests/invite-collaborator.test.ts +++ b/.github/peril/tests/invite-collaborator.test.ts @@ -19,9 +19,9 @@ beforeEach(() => { }, }, api: { - orgs: { - getTeamMembership: () => Promise.resolve({ meta: { status: "404" } }), - addTeamMembership: jest.fn(() => + teams: { + getMembership: () => Promise.resolve({ meta: { status: "404" } }), + addOrUpdateMembership: jest.fn(() => Promise.resolve({ data: { state: "pending" } }) ), },