@cloudsnorkel/cdk-github-runners 0.10.4 → 0.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +1 -1
- package/.jsii +164 -125
- package/API.md +42 -7
- package/README.md +1 -1
- package/SETUP_GITHUB.md +16 -12
- package/TESTING.md +61 -0
- package/assets/{delete-runner.lambda → delete-failed-runner.lambda}/index.js +3972 -1334
- package/assets/idle-runner-repear.lambda/index.js +3994 -1339
- package/assets/image-builders/aws-image-builder/versioner.lambda/index.js +45 -1
- package/assets/setup.lambda/index.html +13 -13
- package/assets/setup.lambda/index.js +2057 -724
- package/assets/status.lambda/index.js +2236 -788
- package/assets/token-retriever.lambda/index.js +3962 -1333
- package/lib/access.d.ts +4 -2
- package/lib/access.js +7 -5
- package/lib/delete-failed-runner-function.d.ts +13 -0
- package/lib/delete-failed-runner-function.js +23 -0
- package/lib/delete-failed-runner.lambda.js +51 -0
- package/lib/idle-runner-repear.lambda.js +43 -10
- package/lib/image-builders/api.js +1 -1
- package/lib/image-builders/aws-image-builder/ami.d.ts +1 -1
- package/lib/image-builders/aws-image-builder/ami.js +9 -9
- package/lib/image-builders/aws-image-builder/builder.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/ami.d.ts +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/ami.js +9 -9
- package/lib/image-builders/aws-image-builder/deprecated/common.d.ts +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/common.js +10 -10
- package/lib/image-builders/aws-image-builder/deprecated/container.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/linux-components.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/windows-components.js +1 -1
- package/lib/image-builders/codebuild-deprecated.js +1 -1
- package/lib/image-builders/components.js +1 -1
- package/lib/image-builders/static.js +1 -1
- package/lib/lambda-github.d.ts +8 -4
- package/lib/lambda-github.js +23 -2
- package/lib/lambda-helpers.d.ts +5 -1
- package/lib/lambda-helpers.js +1 -1
- package/lib/providers/codebuild.js +7 -5
- package/lib/providers/common.d.ts +4 -1
- package/lib/providers/common.js +5 -6
- package/lib/providers/ec2.d.ts +1 -0
- package/lib/providers/ec2.js +16 -11
- package/lib/providers/ecs.js +12 -5
- package/lib/providers/fargate.js +6 -3
- package/lib/providers/lambda.js +2 -2
- package/lib/runner.d.ts +1 -1
- package/lib/runner.js +26 -25
- package/lib/secrets.d.ts +2 -2
- package/lib/secrets.js +2 -2
- package/lib/setup.lambda.js +2 -2
- package/lib/status.lambda.js +4 -4
- package/lib/token-retriever.lambda.js +2 -2
- package/lib/utils.d.ts +19 -1
- package/lib/utils.js +48 -2
- package/lib/webhook.js +2 -2
- package/package.json +16 -15
- package/lib/delete-runner-function.d.ts +0 -13
- package/lib/delete-runner-function.js +0 -23
- package/lib/delete-runner.lambda.js +0 -41
- /package/lib/{delete-runner.lambda.d.ts → delete-failed-runner.lambda.d.ts} +0 -0
package/API.md
CHANGED
|
@@ -4677,8 +4677,8 @@ Any object.
|
|
|
4677
4677
|
| **Name** | **Type** | **Description** |
|
|
4678
4678
|
| --- | --- | --- |
|
|
4679
4679
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
|
|
4680
|
-
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.github">github</a></code> | <code>aws-cdk-lib.aws_secretsmanager.Secret</code> | Authentication secret for GitHub containing either app details or personal
|
|
4681
|
-
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.githubPrivateKey">githubPrivateKey</a></code> | <code>aws-cdk-lib.aws_secretsmanager.Secret</code> | GitHub app private key. Not needed when using personal
|
|
4680
|
+
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.github">github</a></code> | <code>aws-cdk-lib.aws_secretsmanager.Secret</code> | Authentication secret for GitHub containing either app details or personal access token. |
|
|
4681
|
+
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.githubPrivateKey">githubPrivateKey</a></code> | <code>aws-cdk-lib.aws_secretsmanager.Secret</code> | GitHub app private key. Not needed when using personal access tokens. |
|
|
4682
4682
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.setup">setup</a></code> | <code>aws-cdk-lib.aws_secretsmanager.Secret</code> | Setup secret used to authenticate user for our setup wizard. |
|
|
4683
4683
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.webhook">webhook</a></code> | <code>aws-cdk-lib.aws_secretsmanager.Secret</code> | Webhook secret used to confirm events are coming from GitHub and nowhere else. |
|
|
4684
4684
|
|
|
@@ -4704,7 +4704,7 @@ public readonly github: Secret;
|
|
|
4704
4704
|
|
|
4705
4705
|
- *Type:* aws-cdk-lib.aws_secretsmanager.Secret
|
|
4706
4706
|
|
|
4707
|
-
Authentication secret for GitHub containing either app details or personal
|
|
4707
|
+
Authentication secret for GitHub containing either app details or personal access token.
|
|
4708
4708
|
|
|
4709
4709
|
This secret is used to register runners and
|
|
4710
4710
|
cancel jobs when the runner fails to start.
|
|
@@ -4721,7 +4721,7 @@ public readonly githubPrivateKey: Secret;
|
|
|
4721
4721
|
|
|
4722
4722
|
- *Type:* aws-cdk-lib.aws_secretsmanager.Secret
|
|
4723
4723
|
|
|
4724
|
-
GitHub app private key. Not needed when using personal
|
|
4724
|
+
GitHub app private key. Not needed when using personal access tokens.
|
|
4725
4725
|
|
|
4726
4726
|
This secret is meant to be edited by the user after being created. It is separate than the main GitHub secret because inserting private keys into JSON is hard.
|
|
4727
4727
|
|
|
@@ -8171,9 +8171,9 @@ X86_64.
|
|
|
8171
8171
|
|
|
8172
8172
|
### LambdaAccess <a name="LambdaAccess" id="@cloudsnorkel/cdk-github-runners.LambdaAccess"></a>
|
|
8173
8173
|
|
|
8174
|
-
Access configuration options for Lambda functions like setup and webhook function.
|
|
8174
|
+
Access configuration options for Lambda functions like setup and webhook function. Use this to limit access to these functions.
|
|
8175
8175
|
|
|
8176
|
-
|
|
8176
|
+
If you need a custom access point, you can implement this abstract class yourself. Note that the Lambda functions expect API Gateway v1 or v2 input. They also expect every URL under the constructed URL to point to the function.
|
|
8177
8177
|
|
|
8178
8178
|
#### Initializers <a name="Initializers" id="@cloudsnorkel/cdk-github-runners.LambdaAccess.Initializer"></a>
|
|
8179
8179
|
|
|
@@ -8188,6 +8188,39 @@ new LambdaAccess()
|
|
|
8188
8188
|
|
|
8189
8189
|
---
|
|
8190
8190
|
|
|
8191
|
+
#### Methods <a name="Methods" id="Methods"></a>
|
|
8192
|
+
|
|
8193
|
+
| **Name** | **Description** |
|
|
8194
|
+
| --- | --- |
|
|
8195
|
+
| <code><a href="#@cloudsnorkel/cdk-github-runners.LambdaAccess.bind">bind</a></code> | Creates all required resources and returns access URL or empty string if disabled. |
|
|
8196
|
+
|
|
8197
|
+
---
|
|
8198
|
+
|
|
8199
|
+
##### `bind` <a name="bind" id="@cloudsnorkel/cdk-github-runners.LambdaAccess.bind"></a>
|
|
8200
|
+
|
|
8201
|
+
```typescript
|
|
8202
|
+
public bind(scope: Construct, id: string, lambdaFunction: Function): string
|
|
8203
|
+
```
|
|
8204
|
+
|
|
8205
|
+
Creates all required resources and returns access URL or empty string if disabled.
|
|
8206
|
+
|
|
8207
|
+
###### `scope`<sup>Required</sup> <a name="scope" id="@cloudsnorkel/cdk-github-runners.LambdaAccess.bind.parameter.scope"></a>
|
|
8208
|
+
|
|
8209
|
+
- *Type:* constructs.Construct
|
|
8210
|
+
|
|
8211
|
+
---
|
|
8212
|
+
|
|
8213
|
+
###### `id`<sup>Required</sup> <a name="id" id="@cloudsnorkel/cdk-github-runners.LambdaAccess.bind.parameter.id"></a>
|
|
8214
|
+
|
|
8215
|
+
- *Type:* string
|
|
8216
|
+
|
|
8217
|
+
---
|
|
8218
|
+
|
|
8219
|
+
###### `lambdaFunction`<sup>Required</sup> <a name="lambdaFunction" id="@cloudsnorkel/cdk-github-runners.LambdaAccess.bind.parameter.lambdaFunction"></a>
|
|
8220
|
+
|
|
8221
|
+
- *Type:* aws-cdk-lib.aws_lambda.Function
|
|
8222
|
+
|
|
8223
|
+
---
|
|
8191
8224
|
|
|
8192
8225
|
#### Static Functions <a name="Static Functions" id="Static Functions"></a>
|
|
8193
8226
|
|
|
@@ -9669,7 +9702,9 @@ Note that this is not the job log, but the runner itself. It will not contain ou
|
|
|
9669
9702
|
|
|
9670
9703
|
---
|
|
9671
9704
|
|
|
9672
|
-
#####
|
|
9705
|
+
##### ~~`retryableErrors`~~<sup>Required</sup> <a name="retryableErrors" id="@cloudsnorkel/cdk-github-runners.IRunnerProvider.property.retryableErrors"></a>
|
|
9706
|
+
|
|
9707
|
+
- *Deprecated:* do not use
|
|
9673
9708
|
|
|
9674
9709
|
```typescript
|
|
9675
9710
|
public readonly retryableErrors: string[];
|
package/README.md
CHANGED
|
@@ -299,7 +299,7 @@ Other useful metrics to track:
|
|
|
299
299
|
|
|
300
300
|
|
|
301
301
|
[1]: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners
|
|
302
|
-
[2]: https://github.com/marketplace/actions/configure-aws-credentials-
|
|
302
|
+
[2]: https://github.com/marketplace/actions/configure-aws-credentials-for-github-actions
|
|
303
303
|
[3]: https://github.com/philips-labs/terraform-aws-github-runner
|
|
304
304
|
[4]: https://github.com/actions/actions-runner-controller
|
|
305
305
|
[5]: https://github.com/actions/runner
|
package/SETUP_GITHUB.md
CHANGED
|
@@ -7,14 +7,16 @@ Integration with GitHub can be done using an [app](#app-authentication) or [pers
|
|
|
7
7
|
### Setup Wizard
|
|
8
8
|
|
|
9
9
|
1. Open the URL in `github.setup.url` from `status.json`
|
|
10
|
-
2.
|
|
11
|
-
3.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
2. Choose whether you're integrating with GitHub.com or GitHub Enterprise Server
|
|
11
|
+
3. Next choose New GitHub App
|
|
12
|
+
4. If you want to create an app for your personal repositories, choose User app
|
|
13
|
+
5. If you want to create an app for your organization:
|
|
14
|
+
1. Choose Organization app
|
|
15
|
+
2. Type in the organization slug (ORGANIZATION from https://github.com/ORGANIZATION/REPO)
|
|
16
|
+
6. Click Create GitHub App to take you to GitHub to finish the setup
|
|
17
|
+
7. Follow the instructions on GitHub
|
|
18
|
+
8. When brought back to the setup wizard, click the install link
|
|
19
|
+
9. Install the new app on your desired repositories
|
|
18
20
|
|
|
19
21
|
### Manually
|
|
20
22
|
|
|
@@ -37,7 +39,7 @@ Integration with GitHub can be done using an [app](#app-authentication) or [pers
|
|
|
37
39
|
10. Open the URL in `github.auth.secretUrl` from `status.json` and edit the secret value
|
|
38
40
|
1. If you're using a self-hosted GitHub instance, put its domain in `domain` (e.g. `github.mycompany.com`)
|
|
39
41
|
2. Put the new application id in `appId` (e.g. `34789562`)
|
|
40
|
-
|
|
42
|
+
3. Ignore/delete `dummy` and **leave `personalAuthToken` empty**
|
|
41
43
|
11. Open the URL in `github.auth.privateKeySecretUrl` from `status.json` and edit the secret value
|
|
42
44
|
1. Open the downloaded private key with any text editor
|
|
43
45
|
2. Copy the text from the private key as-is into the secret
|
|
@@ -56,14 +58,16 @@ Integration with GitHub can be done using an [app](#app-authentication) or [pers
|
|
|
56
58
|
#### Setup Wizard
|
|
57
59
|
|
|
58
60
|
1. Open the URL in `github.setup.url` from `status.json`
|
|
59
|
-
2.
|
|
60
|
-
3.
|
|
61
|
+
2. Choose whether you're integrating with GitHub.com or GitHub Enterprise Server
|
|
62
|
+
3. Next choose Personal Access Token
|
|
63
|
+
4. Enter your personal access token
|
|
64
|
+
5. Click the Setup button
|
|
61
65
|
|
|
62
66
|
#### Manually
|
|
63
67
|
|
|
64
68
|
1. Open the URL in `github.auth.secretUrl` from `status.json` and edit the secret value
|
|
65
69
|
2. If you're using a self-hosted GitHub instance, put its domain in `domain` (e.g. `github.mycompany.com`)
|
|
66
|
-
3. Put the generated token in `personalAuthToken`
|
|
70
|
+
3. Put the generated token in `personalAuthToken` (**not** `personalAccessToken`)
|
|
67
71
|
4. Ignore all other values
|
|
68
72
|
|
|
69
73
|
### Setup Webhook
|
package/TESTING.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
## Unit Tests
|
|
2
|
+
|
|
3
|
+
Unit tests are executed with `npm run build` and `npm run test`. GitHub Actions won't let PRs merge if the tests fail.
|
|
4
|
+
|
|
5
|
+
To run on Windows, use:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
jest --testMatch */**/*.test.ts
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Integration Test
|
|
12
|
+
|
|
13
|
+
We have one set of [integration tests](test/default.integ.ts). It is a CDK app that creates a set of runners. Once deployed, the runners should be tested using the [self-hosted.yml](.github/workflows/self-hosted.yml) workflow. This should tell us GitHub integration and all runner provider types are working properly.
|
|
14
|
+
|
|
15
|
+
We keep a snapshot of the CloudFormation template generated by the integration test in [test/default.integ.snapshot](test/default.integ.snapshot). During build time and PR validation, we validate the integration test still results in the same CloudFormation template as the snapshot. GitHub Actions won't let PRs merge if the tests fail.
|
|
16
|
+
|
|
17
|
+
If the snapshot changes, you should commit it as part of your PR. You should ideally deploy and test it. The PR should mention whether the integration test was actually deployed and tested.
|
|
18
|
+
|
|
19
|
+
To assert the snapshot hasn't changed, use:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
npm run integ:default:assert
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
To deploy the integration test, use:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
npm run integ:default:deploy
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
To update the snapshot, use:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
npm run integ:default:snapshot
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Manual Tests
|
|
38
|
+
|
|
39
|
+
Integration tests check the happy paths. We should also test the unhappy paths manually. This is a list of scenarios we should manually test before releasing a new version:
|
|
40
|
+
|
|
41
|
+
* Setup page
|
|
42
|
+
* GitHub app
|
|
43
|
+
* Personal access token
|
|
44
|
+
* GitHub Enterprise Server
|
|
45
|
+
* Idle reaper
|
|
46
|
+
* Confirm idle runner is stopped automatically
|
|
47
|
+
* Confirm runner doesn't stay registered in GitHub
|
|
48
|
+
* Confirm runner is not retried
|
|
49
|
+
* Step function result is aborted and not failed
|
|
50
|
+
* Retries
|
|
51
|
+
* Confirm runner errors are retried
|
|
52
|
+
* Confirm failed runner doesn't stay registered in GitHub
|
|
53
|
+
|
|
54
|
+
The last two scenarios can be tested with the following test cases:
|
|
55
|
+
|
|
56
|
+
* Start step function without a job actually pending (e.g. by duplicating input from a previous job, or cancelling a job before a runner picks it up)
|
|
57
|
+
* The step function should be aborted as an idle runner
|
|
58
|
+
* No runner should be registered on GitHub at the end
|
|
59
|
+
* Let Lambda runner timeout by starting a job that lasts longer than 15 minutes
|
|
60
|
+
* The runner should be retried and eventually the step function should be aborted as an idle runner
|
|
61
|
+
* No runner should be registered on GitHub at the end
|