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

Commit 4677619

Browse files
committed
feat!: Remove support check_run (#2521)
Migration: In the past we used for scaling the check_run event, since GitHub had now support for a workflow_job event. Now the event is upport for quite some time. And also support exists on GHES. We will phase out check_run support. Ensure you configure the GitHub app to subscribe to workflow_job. In case you on an old GHES server version, the only. migration path is to update GHES or remain on old version of the module
1 parent 0d2b294 commit 4677619

File tree

8 files changed

+101
-125
lines changed

8 files changed

+101
-125
lines changed

Diff for: README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@ A logical question would be, why not Kubernetes? In the current approach, we sta
5151

5252
## Overview
5353

54-
The moment a GitHub action workflow requiring a `self-hosted` runner is triggered, GitHub will try to find a runner which can execute the workload. This module reacts to GitHub's [`check_run` event](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#check_run) or [`workflow_job` event](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads#workflow_job) for the triggered workflow and creates a new runner if necessary.
54+
The moment a GitHub action workflow requiring a `self-hosted` runner is triggered, GitHub will try to find a runner which can execute the workload. This module reacts to GitHub's [`workflow_job` event](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads#workflow_job) for the triggered workflow and creates a new runner if necessary.
5555

56-
For receiving the `check_run` or `workflow_job` event by the webhook (lambda), a webhook needs to be created in GitHub. The `workflow_job` is the preferred option, and the `check_run` option will be maintained for backward compatibility. The advantage of the `workflow_job` event is that the runner checks if the received event can run on the configured runners by matching the labels, which avoid instances being scaled up and never used. The following options are available:
56+
For receiving the `workflow_job` event by the webhook (lambda), a webhook needs to be created in GitHub. The `check_run` option is dropped from version 2.x. The following options to sent the event are supported.
5757

58-
- `workflow_job`: **(preferred option)** create a webhook on enterprise, org or app level. Select this option for ephemeral runners.
59-
- `check_run`: create a webhook on enterprise, org, repo or app level. When using the app option, the app needs to be installed to repo's are using the self-hosted runners.
60-
- a Webhook needs to be created. The webhook hook can be defined on enterprise, org, repo, or app level.
58+
- Create a GitHup app, define a webhook and subscribe the app to the `workflow_job` event.
59+
- Create a webhook on enterprise, org or repo level, define a webhook and subscribe the app to the `workflow_job` event.
6160

62-
In AWS a [API gateway](https://docs.aws.amazon.com/apigateway/index.html) endpoint is created that is able to receive the GitHub webhook events via HTTP post. The gateway triggers the webhook lambda which will verify the signature of the event. This check guarantees the event is sent by the GitHub App. The lambda only handles `workflow_job` or `check_run` events with status `queued` and matching the runner labels (only for `workflow_job`). The accepted events are posted on a SQS queue. Messages on this queue will be delayed for a configurable amount of seconds (default 30 seconds) to give the available runners time to pick up this build.
61+
In AWS a [API gateway](https://docs.aws.amazon.com/apigateway/index.html) endpoint is created that is able to receive the GitHub webhook events via HTTP post. The gateway triggers the webhook lambda which will verify the signature of the event. This check guarantees the event is sent by the GitHub App. The lambda only handles `workflow_job` events with status `queued` and matching the runner labels. The accepted events are posted on a SQS queue. Messages on this queue will be delayed for a configurable amount of seconds (default 30 seconds) to give the available runners time to pick up this build.
6362

6463
The "scale up runner" lambda listens to the SQS queue and picks up events. The lambda runs various checks to decide whether a new EC2 spot instance needs to be created. For example, the instance is not created if the build is already started by an existing runner, or the maximum number of runners is reached.
6564

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

+75-8
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.19.4.tgz#95c86de137bf0317f3a570e1b6e996b427299747"
4242
integrity sha512-CHIGpJcUQ5lU9KrPHTjBMhVwQG6CQjxfg36fGXl3qk/Gik1WwWachaXFuo0uCWJT/mStOKtcbFJCaVLihC1CMw==
4343

44-
44+
"@babel/[email protected]", "@babel/core@^7.12.3":
4545
version "7.17.8"
4646
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.8.tgz#3dac27c190ebc3a4381110d46c80e77efe172e1a"
4747
integrity sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ==
@@ -62,7 +62,7 @@
6262
json5 "^2.1.2"
6363
semver "^6.3.0"
6464

65-
"@babel/core@^7.11.6", "@babel/core@^7.12.3":
65+
"@babel/core@^7.11.6":
6666
version "7.19.3"
6767
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.19.3.tgz#2519f62a51458f43b682d61583c3810e7dcee64c"
6868
integrity sha512-WneDJxdsjEvyKtXKsaBGbDeiyOjR5vYq4HcShxnIbG0qixpoHjI3MqeZM9NDvsojNCEBItQE4juOo/bU6e72gQ==
@@ -101,6 +101,15 @@
101101
"@jridgewell/gen-mapping" "^0.3.2"
102102
jsesc "^2.5.1"
103103

104+
"@babel/generator@^7.19.3", "@babel/generator@^7.19.4":
105+
version "7.19.5"
106+
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.19.5.tgz#da3f4b301c8086717eee9cab14da91b1fa5dcca7"
107+
integrity sha512-DxbNz9Lz4aMZ99qPpO1raTbcrI1ZeYh+9NR9qhfkQIbFtVEqotHojEBxHzmxhVONkGt6VyrqVQcgpefMy9pqcg==
108+
dependencies:
109+
"@babel/types" "^7.19.4"
110+
"@jridgewell/gen-mapping" "^0.3.2"
111+
jsesc "^2.5.1"
112+
104113
"@babel/helper-compilation-targets@^7.17.7":
105114
version "7.18.9"
106115
resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz#69e64f57b524cde3e5ff6cc5a9f4a387ee5563bf"
@@ -150,6 +159,14 @@
150159
"@babel/template" "^7.18.10"
151160
"@babel/types" "^7.19.0"
152161

162+
"@babel/helper-function-name@^7.19.0":
163+
version "7.19.0"
164+
resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz#941574ed5390682e872e52d3f38ce9d1bef4648c"
165+
integrity sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==
166+
dependencies:
167+
"@babel/template" "^7.18.10"
168+
"@babel/types" "^7.19.0"
169+
153170
"@babel/helper-get-function-arity@^7.16.7":
154171
version "7.16.7"
155172
resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz#ea08ac753117a669f1508ba06ebcc49156387419"
@@ -488,6 +505,22 @@
488505
debug "^4.1.0"
489506
globals "^11.1.0"
490507

508+
"@babel/traverse@^7.19.0", "@babel/traverse@^7.19.3", "@babel/traverse@^7.19.4":
509+
version "7.19.4"
510+
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.19.4.tgz#f117820e18b1e59448a6c1fa9d0ff08f7ac459a8"
511+
integrity sha512-w3K1i+V5u2aJUOXBFFC5pveFLmtq1s3qcdDNC2qRI6WPBQIDaKFqXxDEqDO/h1dQ3HjsZoZMyIy6jGLq0xtw+g==
512+
dependencies:
513+
"@babel/code-frame" "^7.18.6"
514+
"@babel/generator" "^7.19.4"
515+
"@babel/helper-environment-visitor" "^7.18.9"
516+
"@babel/helper-function-name" "^7.19.0"
517+
"@babel/helper-hoist-variables" "^7.18.6"
518+
"@babel/helper-split-export-declaration" "^7.18.6"
519+
"@babel/parser" "^7.19.4"
520+
"@babel/types" "^7.19.4"
521+
debug "^4.1.0"
522+
globals "^11.1.0"
523+
491524
492525
version "7.17.0"
493526
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.0.tgz#a826e368bccb6b3d84acd76acad5c0d87342390b"
@@ -505,6 +538,15 @@
505538
"@babel/helper-validator-identifier" "^7.19.1"
506539
to-fast-properties "^2.0.0"
507540

541+
"@babel/types@^7.18.10", "@babel/types@^7.19.0", "@babel/types@^7.19.3", "@babel/types@^7.19.4":
542+
version "7.19.4"
543+
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.19.4.tgz#0dd5c91c573a202d600490a35b33246fed8a41c7"
544+
integrity sha512-M5LK7nAeS6+9j7hAq+b3fQs+pNfUtTGq+yFFfHnauFA8zQtLRfmuipmsKDKKLuyG+wC8ABW43A153YNawNTEtw==
545+
dependencies:
546+
"@babel/helper-string-parser" "^7.19.4"
547+
"@babel/helper-validator-identifier" "^7.19.1"
548+
to-fast-properties "^2.0.0"
549+
508550
"@bcoe/v8-coverage@^0.2.3":
509551
version "0.2.3"
510552
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
@@ -1536,9 +1578,9 @@ caniuse-lite@^1.0.30001366:
15361578
integrity sha512-XDgbeOHfifWV3GEES2B8rtsrADx4Jf+juKX2SICJcaUhjYBO3bR96kvEIHa15VU6ohtOhBZuPGGYGbXMRn0NCw==
15371579

15381580
caniuse-lite@^1.0.30001400:
1539-
version "1.0.30001420"
1540-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001420.tgz#f62f35f051e0b6d25532cf376776d41e45b47ef6"
1541-
integrity sha512-OnyeJ9ascFA9roEj72ok2Ikp7PHJTKubtEJIQ/VK3fdsS50q4KWy+Z5X0A1/GswEItKX0ctAp8n4SYDE7wTu6A==
1581+
version "1.0.30001419"
1582+
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001419.tgz#3542722d57d567c8210d5e4d0f9f17336b776457"
1583+
integrity sha512-aFO1r+g6R7TW+PNQxKzjITwLOyDhVRLjW0LcwS/HCZGUUKTGNp9+IwLC4xyDSZBygVL/mxaFR3HIV6wEKQuSzw==
15421584

15431585
chalk@^2.0.0:
15441586
version "2.4.2"
@@ -1725,6 +1767,11 @@ diff-sequences@^29.3.1:
17251767
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.3.1.tgz#104b5b95fe725932421a9c6e5b4bef84c3f2249e"
17261768
integrity sha512-hlM3QR272NXCi4pq+N4Kok4kOp6EsgOM3ZSpJI7Da3UAs+Ttsi8MRmB6trM/lhyzUxGfOgnpkHtgqm5Q/CTcfQ==
17271769

1770+
diff-sequences@^29.2.0:
1771+
version "29.2.0"
1772+
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.2.0.tgz#4c55b5b40706c7b5d2c5c75999a50c56d214e8f6"
1773+
integrity sha512-413SY5JpYeSBZxmenGEmCVQ8mCgtFJF0w9PROdaS6z987XC2Pd2GOKqOITLtMftmyFZqgtCOb/QA7/Z3ZXfzIw==
1774+
17281775
diff@^4.0.1:
17291776
version "4.0.2"
17301777
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
@@ -1757,9 +1804,9 @@ electron-to-chromium@^1.4.188:
17571804
integrity sha512-8nCXyIQY9An88NXAp+PuPy5h3/w5ZY7Iu2lag65Q0XREprcat5F8gKhoHsBUnQcFuCRnmevpR8yEBYRU3d2HDw==
17581805

17591806
electron-to-chromium@^1.4.251:
1760-
version "1.4.283"
1761-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.283.tgz#d4f263f5df402fd799c0a06255d580dcf8aa9a8e"
1762-
integrity sha512-g6RQ9zCOV+U5QVHW9OpFR7rdk/V7xfopNXnyAamdpFgCHgZ1sjI8VuR1+zG2YG/TZk+tQ8mpNkug4P8FU0fuOA==
1807+
version "1.4.282"
1808+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.282.tgz#02af3fd6051e97ac3388a4b11d455bc1ca49838f"
1809+
integrity sha512-Dki0WhHNh/br/Xi1vAkueU5mtIc9XLHcMKB6tNfQKk+kPG0TEUjRh5QEMAUbRp30/rYNMFD1zKKvbVzwq/4wmg==
17631810

17641811
emittery@^0.13.1:
17651812
version "0.13.1"
@@ -2662,6 +2709,16 @@ jest-diff@^29.3.1:
26622709
jest-get-type "^29.2.0"
26632710
pretty-format "^29.3.1"
26642711

2712+
jest-diff@^29.2.0:
2713+
version "29.2.0"
2714+
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-29.2.0.tgz#b1e11ac1a1401fc4792ef8ba406b48f1ae7d2bc5"
2715+
integrity sha512-GsH07qQL+/D/GxlnU+sSg9GL3fBOcuTlmtr3qr2pnkiODCwubNN2/7slW4m3CvxDsEus/VEOfQKRFLyXsUlnZw==
2716+
dependencies:
2717+
chalk "^4.0.0"
2718+
diff-sequences "^29.2.0"
2719+
jest-get-type "^29.2.0"
2720+
pretty-format "^29.2.0"
2721+
26652722
jest-docblock@^29.2.0:
26662723
version "29.2.0"
26672724
resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-29.2.0.tgz#307203e20b637d97cee04809efc1d43afc641e82"
@@ -2692,6 +2749,11 @@ jest-environment-node@^29.3.1:
26922749
jest-mock "^29.3.1"
26932750
jest-util "^29.3.1"
26942751

2752+
jest-get-type@^27.5.1:
2753+
version "27.5.1"
2754+
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.5.1.tgz#3cd613c507b0f7ace013df407a1c1cd578bcb4f1"
2755+
integrity sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw==
2756+
26952757
jest-get-type@^29.2.0:
26962758
version "29.2.0"
26972759
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-29.2.0.tgz#726646f927ef61d583a3b3adb1ab13f3a5036408"
@@ -3377,6 +3439,11 @@ react-is@^18.0.0:
33773439
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
33783440
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
33793441

3442+
react-is@^18.0.0:
3443+
version "18.2.0"
3444+
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
3445+
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
3446+
33803447
readdirp@~3.6.0:
33813448
version "3.6.0"
33823449
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7"

Diff for: modules/runners/lambdas/runners/src/scale-runners/scale-up.test.ts

-18
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,6 @@ describe('scaleUp with GHES', () => {
227227
expect(createRunner).toBeCalledWith(expectedRunnerParams);
228228
});
229229

230-
it('creates a runner with legacy event check_run', async () => {
231-
await scaleUpModule.scaleUp('aws:sqs', { ...TEST_DATA, eventType: 'check_run' });
232-
expect(createRunner).toBeCalledWith(expectedRunnerParams);
233-
});
234-
235230
it('creates a runner with labels in a specific group', async () => {
236231
process.env.RUNNER_EXTRA_LABELS = 'label1,label2';
237232
process.env.RUNNER_GROUP_NAME = 'TEST_GROUP';
@@ -402,14 +397,6 @@ describe('scaleUp with public GH', () => {
402397
expect(listEC2Runners).not.toBeCalled();
403398
});
404399

405-
it('does not list runners when no workflows are queued (check_run)', async () => {
406-
mockOctokit.checks.get.mockImplementation(() => ({
407-
data: { status: 'completed' },
408-
}));
409-
await scaleUpModule.scaleUp('aws:sqs', { ...TEST_DATA, eventType: 'check_run' });
410-
expect(listEC2Runners).not.toBeCalled();
411-
});
412-
413400
describe('on org level', () => {
414401
beforeEach(() => {
415402
process.env.ENABLE_ORGANIZATION_RUNNERS = 'true';
@@ -449,11 +436,6 @@ describe('scaleUp with public GH', () => {
449436
expect(createRunner).toBeCalledWith(expectedRunnerParams);
450437
});
451438

452-
it('creates a runner with legacy event check_run', async () => {
453-
await scaleUpModule.scaleUp('aws:sqs', { ...TEST_DATA, eventType: 'check_run' });
454-
expect(createRunner).toBeCalledWith(expectedRunnerParams);
455-
});
456-
457439
it('creates a runner with labels in s specific group', async () => {
458440
process.env.RUNNER_EXTRA_LABELS = 'label1,label2';
459441
process.env.RUNNER_GROUP_NAME = 'TEST_GROUP';

Diff for: modules/runners/lambdas/runners/src/scale-runners/scale-up.ts

-7
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,6 @@ async function isJobQueued(githubInstallationClient: Octokit, payload: ActionReq
105105
repo: payload.repositoryName,
106106
});
107107
isQueued = jobForWorkflowRun.data.status === 'queued';
108-
} else if (payload.eventType === 'check_run') {
109-
const checkRun = await githubInstallationClient.checks.get({
110-
check_run_id: payload.id,
111-
owner: payload.repositoryOwner,
112-
repo: payload.repositoryName,
113-
});
114-
isQueued = checkRun.data.status === 'queued';
115108
} else {
116109
throw Error(`Event ${payload.eventType} is not supported`);
117110
}

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -2394,9 +2394,9 @@ caniuse-lite@^1.0.30001366:
23942394
integrity sha512-wgfRYa9DenEomLG/SdWgQxpIyvdtH3NW8Vq+tB6AwR9e56iOIcu1im5F/wNdDf04XlKHXqIx4N8Jo0PemeBenQ==
23952395

23962396
caniuse-lite@^1.0.30001400:
2397-
version "1.0.30001420"
2398-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001420.tgz#f62f35f051e0b6d25532cf376776d41e45b47ef6"
2399-
integrity sha512-OnyeJ9ascFA9roEj72ok2Ikp7PHJTKubtEJIQ/VK3fdsS50q4KWy+Z5X0A1/GswEItKX0ctAp8n4SYDE7wTu6A==
2397+
version "1.0.30001419"
2398+
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001419.tgz#3542722d57d567c8210d5e4d0f9f17336b776457"
2399+
integrity sha512-aFO1r+g6R7TW+PNQxKzjITwLOyDhVRLjW0LcwS/HCZGUUKTGNp9+IwLC4xyDSZBygVL/mxaFR3HIV6wEKQuSzw==
24002400

24012401
chalk@^2.0.0:
24022402
version "2.4.2"
@@ -2617,9 +2617,9 @@ electron-to-chromium@^1.4.188:
26172617
integrity sha512-uxMa/Dt7PQsLBVXwH+t6JvpHJnrsYBaxWKi/J6HE+/nBtoHENhwBoNkgkm226/Kfxeg0z1eMQLBRPPKcDH8xWA==
26182618

26192619
electron-to-chromium@^1.4.251:
2620-
version "1.4.283"
2621-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.283.tgz#d4f263f5df402fd799c0a06255d580dcf8aa9a8e"
2622-
integrity sha512-g6RQ9zCOV+U5QVHW9OpFR7rdk/V7xfopNXnyAamdpFgCHgZ1sjI8VuR1+zG2YG/TZk+tQ8mpNkug4P8FU0fuOA==
2620+
version "1.4.282"
2621+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.282.tgz#02af3fd6051e97ac3388a4b11d455bc1ca49838f"
2622+
integrity sha512-Dki0WhHNh/br/Xi1vAkueU5mtIc9XLHcMKB6tNfQKk+kPG0TEUjRh5QEMAUbRp30/rYNMFD1zKKvbVzwq/4wmg==
26232623

26242624
emittery@^0.13.1:
26252625
version "0.13.1"

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

+3-55
Original file line numberDiff line numberDiff line change
@@ -246,67 +246,15 @@ describe('handler', () => {
246246
});
247247
});
248248

249-
describe('Test for check_run event (legacy): ', () => {
249+
describe('Test for check_run is ignored.', () => {
250250
it('handles check_run events', async () => {
251251
const event = JSON.stringify(checkrun_event);
252252
const resp = await handle(
253253
{ 'X-Hub-Signature': await webhooks.sign(event), 'X-GitHub-Event': 'check_run' },
254254
event,
255255
);
256-
expect(resp.statusCode).toBe(201);
257-
expect(sendActionRequest).toBeCalled();
258-
});
259-
260-
it('does not handle check_run events with actions other than queued (action = started)', async () => {
261-
const event = JSON.stringify({ ...checkrun_event, action: 'started' });
262-
const resp = await handle(
263-
{ 'X-Hub-Signature': await webhooks.sign(event), 'X-GitHub-Event': 'check_run' },
264-
event,
265-
);
266-
expect(resp.statusCode).toBe(201);
267-
expect(sendActionRequest).not.toBeCalled();
268-
});
269-
270-
it('does not handle check_run events with actions other than queued (action = completed)', async () => {
271-
const event = JSON.stringify({ ...checkrun_event, action: 'completed' });
272-
const resp = await handle(
273-
{ 'X-Hub-Signature': await webhooks.sign(event), 'X-GitHub-Event': 'check_run' },
274-
event,
275-
);
276-
expect(resp.statusCode).toBe(201);
277-
expect(sendActionRequest).not.toBeCalled();
278-
});
279-
280-
it('does not handle check_run events from unlisted repositories', async () => {
281-
const event = JSON.stringify(checkrun_event);
282-
process.env.REPOSITORY_WHITE_LIST = '["NotCodertocat/Hello-World"]';
283-
const resp = await handle(
284-
{ 'X-Hub-Signature': await webhooks.sign(event), 'X-GitHub-Event': 'check_run' },
285-
event,
286-
);
287-
expect(resp.statusCode).toBe(403);
288-
expect(sendActionRequest).not.toBeCalled();
289-
});
290-
291-
it('handles check_run events from whitelisted repositories', async () => {
292-
const event = JSON.stringify(checkrun_event);
293-
process.env.REPOSITORY_WHITE_LIST = '["Codertocat/Hello-World"]';
294-
const resp = await handle(
295-
{ 'X-Hub-Signature': await webhooks.sign(event), 'X-GitHub-Event': 'check_run' },
296-
event,
297-
);
298-
expect(resp.statusCode).toBe(201);
299-
expect(sendActionRequest).toBeCalled();
300-
});
301-
302-
it('handles check_run events with no installation id.', async () => {
303-
const event = JSON.stringify({ ...checkrun_event, installation: { id: null } });
304-
const resp = await handle(
305-
{ 'X-Hub-Signature': await webhooks.sign(event), 'X-GitHub-Event': 'check_run' },
306-
event,
307-
);
308-
expect(resp.statusCode).toBe(201);
309-
expect(sendActionRequest).toBeCalled();
256+
expect(resp.statusCode).toBe(202);
257+
expect(sendActionRequest).toBeCalledTimes(0);
310258
});
311259
});
312260

0 commit comments

Comments
 (0)