diff --git a/src/checks/addReprosLabel.test.ts b/src/checks/addReprosLabel.test.ts index 5432d05..b27afb4 100644 --- a/src/checks/addReprosLabel.test.ts +++ b/src/checks/addReprosLabel.test.ts @@ -56,7 +56,8 @@ describe(addReprosLabelOnComments, () => { await addReprosLabelOnComments(api, payload, getFakeLogger()) - expect(mockAPI.issues.addLabels).not.toHaveBeenCalledWith() + expect(mockAPI.issues.addLabels).not.toHaveBeenCalled() + expect(mockAPI.repos.createDispatchEvent).not.toHaveBeenCalled() }) it("NO-OPs when there are no labels already ", async () => { @@ -68,6 +69,7 @@ describe(addReprosLabelOnComments, () => { await addReprosLabelOnComments(api, payload, getFakeLogger()) expect(mockAPI.issues.addLabels).not.toHaveBeenCalledWith() + expect(mockAPI.repos.createDispatchEvent).not.toHaveBeenCalled() }) it("Adds the label when it has a repro in the body and there are labels already", async () => { @@ -84,6 +86,7 @@ describe(addReprosLabelOnComments, () => { owner: "microsoft", repo: "TypeScript-Website", }) + expect(mockAPI.repos.createDispatchEvent).toHaveBeenCalled() expect(pingDiscord).toHaveBeenCalled() }) diff --git a/src/checks/addReprosLabel.ts b/src/checks/addReprosLabel.ts index 2e3f358..1f66c6b 100644 --- a/src/checks/addReprosLabel.ts +++ b/src/checks/addReprosLabel.ts @@ -47,6 +47,9 @@ export const addReprosLabelOnIssue = async (api: Octokit, payload: WebhookPayloa if (issue.labels.find(l => l.name === "Repro Requested")) { await api.issues.removeLabel({ ...thisIssue, name: "Repro Requested" }) } + + // Trigger a run of all repros + api.repos.createDispatchEvent({ ...thisIssue, event_type: "run-twoslash-repros" }) } } @@ -88,5 +91,8 @@ export const addReprosLabelOnComments = async ( if (issue.labels.find(l => l.name === "Repro Requested")) { await api.issues.removeLabel({ ...thisIssue, name: "Repro Requested" }) } + + // Trigger a run of all repros + api.repos.createDispatchEvent({ ...thisIssue, event_type: "run-twoslash-repros" }) } } diff --git a/src/util/tests/createMockGitHubClient.ts b/src/util/tests/createMockGitHubClient.ts index 44ac86c..c8efd2d 100644 --- a/src/util/tests/createMockGitHubClient.ts +++ b/src/util/tests/createMockGitHubClient.ts @@ -25,6 +25,7 @@ export const createMockGitHubClient = () => { checkCollaborator: jest.fn(), getContents: jest.fn(), getCombinedStatusForRef: jest.fn(), + createDispatchEvent: jest.fn() }, issues: { addAssignees: jest.fn(), @@ -82,6 +83,7 @@ export const createFakeGitHubClient = () => { checkCollaborator: Promise.resolve({}), getContents: Promise.resolve({}), getCombinedStatusForRef: Promise.resolve({}), + createDispatchEvent: Promise.resolve({}), }, issues: { addAssignees: Promise.resolve({}),