diff --git a/src/solidarity.test.ts b/src/solidarity.test.ts index a3db80a..1a10f94 100644 --- a/src/solidarity.test.ts +++ b/src/solidarity.test.ts @@ -149,3 +149,13 @@ test("update should chunk annotations", async () => { expect(update.mock.calls[1][0].output.annotations.length).toBe(50); expect(update.mock.calls[2][0].output.annotations.length).toBe(1); }); + +test("solidarity blocks some orgs", async () => { + const env = process.env; + const s = new Solidarity({ name: "foo", id: "bar", payload: payload } as any); + s.config = DEFAULT_CONFIGURATION; + expect(s.isBlockedOwner()).toBeFalsy(); + process.env.BLOCKED_ORGS = "jpoehnelt,baz"; + expect(s.isBlockedOwner()).toBeTruthy(); + process.env = env; +}); diff --git a/src/solidarity.ts b/src/solidarity.ts index 600ddf3..84eb142 100644 --- a/src/solidarity.ts +++ b/src/solidarity.ts @@ -109,11 +109,23 @@ export class Solidarity { }; } + isBlockedOwner(): boolean { + return (process.env.BLOCKED_ORGS || "") + .toLowerCase() + .split(",") + .includes(this.owner.toLocaleLowerCase()); + } + async run(): Promise { let conclusion: Conclusion = Conclusion.NEUTRAL; let output: { title: string; summary: string }; await this.start(); + + if (this.isBlockedOwner()) { + return this.update("completed", Conclusion.CANCELLED); + } + await this.update("in_progress"); try {