Skip to content

Commit d4b0e68

Browse files
authored
feat: Remove support check_run (#2521)
* chore: Remove support check_run * format, lint
1 parent cd9b9b1 commit d4b0e68

File tree

9 files changed

+2098
-2615
lines changed

9 files changed

+2098
-2615
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,14 @@ A logical question would be, why not Kubernetes? In the current approach, we sta
4646

4747
## Overview
4848

49-
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.
49+
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.
5050

51-
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:
51+
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.
5252

53-
- `workflow_job`: **(preferred option)** create a webhook on enterprise, org or app level. Select this option for ephemeral runners.
54-
- `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.
55-
- a Webhook needs to be created. The webhook hook can be defined on enterprise, org, repo, or app level.
53+
- Create a GitHup app, define a webhook and subscribe the app to the `workflow_job` event.
54+
- Create a webhook on enterprise, org or repo level, define a webhook and subscribe the app to the `workflow_job` event.
5655

57-
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.
56+
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.
5857

5958
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.
6059

modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/yarn.lock

Lines changed: 688 additions & 819 deletions
Large diffs are not rendered by default.

modules/runners/lambdas/runners/src/scale-runners/scale-up.test.ts

Lines changed: 0 additions & 18 deletions
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';
@@ -396,14 +391,6 @@ describe('scaleUp with public GH', () => {
396391
expect(listEC2Runners).not.toBeCalled();
397392
});
398393

399-
it('does not list runners when no workflows are queued (check_run)', async () => {
400-
mockOctokit.checks.get.mockImplementation(() => ({
401-
data: { status: 'completed' },
402-
}));
403-
await scaleUpModule.scaleUp('aws:sqs', { ...TEST_DATA, eventType: 'check_run' });
404-
expect(listEC2Runners).not.toBeCalled();
405-
});
406-
407394
describe('on org level', () => {
408395
beforeEach(() => {
409396
process.env.ENABLE_ORGANIZATION_RUNNERS = 'true';
@@ -443,11 +430,6 @@ describe('scaleUp with public GH', () => {
443430
expect(createRunner).toBeCalledWith(expectedRunnerParams);
444431
});
445432

446-
it('creates a runner with legacy event check_run', async () => {
447-
await scaleUpModule.scaleUp('aws:sqs', { ...TEST_DATA, eventType: 'check_run' });
448-
expect(createRunner).toBeCalledWith(expectedRunnerParams);
449-
});
450-
451433
it('creates a runner with labels in s specific group', async () => {
452434
process.env.RUNNER_EXTRA_LABELS = 'label1,label2';
453435
process.env.RUNNER_GROUP_NAME = 'TEST_GROUP';

modules/runners/lambdas/runners/src/scale-runners/scale-up.ts

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

0 commit comments

Comments
 (0)