@cloudsnorkel/cdk-github-runners 0.10.3 → 0.10.5

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.
Files changed (52) hide show
  1. package/.gitattributes +1 -1
  2. package/.jsii +69 -30
  3. package/API.md +42 -7
  4. package/SETUP_GITHUB.md +16 -12
  5. package/TESTING.md +61 -0
  6. package/assets/{delete-runner.lambda → delete-failed-runner.lambda}/index.js +2031 -518
  7. package/assets/idle-runner-repear.lambda/index.js +2052 -522
  8. package/assets/image-builders/aws-image-builder/versioner.lambda/index.js +1 -1
  9. package/assets/setup.lambda/index.html +1 -1
  10. package/assets/setup.lambda/index.js +577 -159
  11. package/assets/status.lambda/index.js +1652 -473
  12. package/assets/token-retriever.lambda/index.js +2025 -521
  13. package/lib/access.d.ts +4 -2
  14. package/lib/access.js +7 -5
  15. package/lib/delete-failed-runner-function.d.ts +13 -0
  16. package/lib/delete-failed-runner-function.js +23 -0
  17. package/lib/delete-failed-runner.lambda.js +51 -0
  18. package/lib/idle-runner-repear.lambda.js +43 -10
  19. package/lib/image-builders/api.js +1 -1
  20. package/lib/image-builders/aws-image-builder/builder.js +1 -1
  21. package/lib/image-builders/aws-image-builder/deprecated/ami.js +1 -1
  22. package/lib/image-builders/aws-image-builder/deprecated/container.js +1 -1
  23. package/lib/image-builders/aws-image-builder/deprecated/linux-components.js +1 -1
  24. package/lib/image-builders/aws-image-builder/deprecated/windows-components.js +1 -1
  25. package/lib/image-builders/codebuild-deprecated.js +1 -1
  26. package/lib/image-builders/components.js +1 -1
  27. package/lib/image-builders/static.js +1 -1
  28. package/lib/lambda-github.d.ts +8 -4
  29. package/lib/lambda-github.js +23 -2
  30. package/lib/lambda-helpers.d.ts +5 -1
  31. package/lib/lambda-helpers.js +1 -1
  32. package/lib/providers/codebuild.js +2 -2
  33. package/lib/providers/common.d.ts +2 -0
  34. package/lib/providers/common.js +4 -4
  35. package/lib/providers/ec2.js +2 -2
  36. package/lib/providers/ecs.d.ts +1 -1
  37. package/lib/providers/ecs.js +14 -5
  38. package/lib/providers/fargate.js +2 -2
  39. package/lib/providers/lambda.js +2 -2
  40. package/lib/runner.d.ts +1 -1
  41. package/lib/runner.js +26 -25
  42. package/lib/secrets.d.ts +2 -2
  43. package/lib/secrets.js +2 -2
  44. package/lib/setup.lambda.js +2 -2
  45. package/lib/status.lambda.js +4 -4
  46. package/lib/token-retriever.lambda.js +2 -2
  47. package/lib/webhook.js +2 -2
  48. package/package.json +14 -14
  49. package/lib/delete-runner-function.d.ts +0 -13
  50. package/lib/delete-runner-function.js +0 -23
  51. package/lib/delete-runner.lambda.js +0 -41
  52. /package/lib/{delete-runner.lambda.d.ts → delete-failed-runner.lambda.d.ts} +0 -0
package/.gitattributes CHANGED
@@ -26,7 +26,7 @@
26
26
  /cdk.json linguist-generated
27
27
  /LICENSE linguist-generated
28
28
  /package.json linguist-generated
29
- /src/delete-runner-function.ts linguist-generated
29
+ /src/delete-failed-runner-function.ts linguist-generated
30
30
  /src/idle-runner-repear-function.ts linguist-generated
31
31
  /src/image-builders/aws-image-builder/delete-ami-function.ts linguist-generated
32
32
  /src/image-builders/aws-image-builder/filter-failed-builds-function.ts linguist-generated
package/.jsii CHANGED
@@ -3114,7 +3114,7 @@
3114
3114
  "stability": "experimental"
3115
3115
  },
3116
3116
  "homepage": "https://github.com/CloudSnorkel/cdk-github-runners.git",
3117
- "jsiiVersion": "5.0.7 (build 5782cd5)",
3117
+ "jsiiVersion": "5.0.9 (build a2ff859)",
3118
3118
  "keywords": [
3119
3119
  "aws",
3120
3120
  "aws-cdk",
@@ -4907,7 +4907,7 @@
4907
4907
  },
4908
4908
  "locationInModule": {
4909
4909
  "filename": "src/providers/common.ts",
4910
- "line": 471
4910
+ "line": 473
4911
4911
  },
4912
4912
  "name": "labelsFromProperties",
4913
4913
  "parameters": [
@@ -6219,7 +6219,7 @@
6219
6219
  },
6220
6220
  "locationInModule": {
6221
6221
  "filename": "src/providers/common.ts",
6222
- "line": 471
6222
+ "line": 473
6223
6223
  },
6224
6224
  "name": "labelsFromProperties",
6225
6225
  "parameters": [
@@ -6732,7 +6732,7 @@
6732
6732
  },
6733
6733
  "locationInModule": {
6734
6734
  "filename": "src/providers/ecs.ts",
6735
- "line": 503
6735
+ "line": 512
6736
6736
  },
6737
6737
  "name": "getStepFunctionTask",
6738
6738
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -6761,7 +6761,7 @@
6761
6761
  },
6762
6762
  "locationInModule": {
6763
6763
  "filename": "src/providers/ecs.ts",
6764
- "line": 548
6764
+ "line": 557
6765
6765
  },
6766
6766
  "name": "grantStateMachine",
6767
6767
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -6780,7 +6780,7 @@
6780
6780
  },
6781
6781
  "locationInModule": {
6782
6782
  "filename": "src/providers/common.ts",
6783
- "line": 471
6783
+ "line": 473
6784
6784
  },
6785
6785
  "name": "labelsFromProperties",
6786
6786
  "parameters": [
@@ -6830,7 +6830,7 @@
6830
6830
  },
6831
6831
  "locationInModule": {
6832
6832
  "filename": "src/providers/ecs.ts",
6833
- "line": 551
6833
+ "line": 560
6834
6834
  },
6835
6835
  "name": "status",
6836
6836
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -7480,7 +7480,7 @@
7480
7480
  },
7481
7481
  "locationInModule": {
7482
7482
  "filename": "src/providers/common.ts",
7483
- "line": 471
7483
+ "line": 473
7484
7484
  },
7485
7485
  "name": "labelsFromProperties",
7486
7486
  "parameters": [
@@ -8136,7 +8136,7 @@
8136
8136
  },
8137
8137
  "locationInModule": {
8138
8138
  "filename": "src/runner.ts",
8139
- "line": 737
8139
+ "line": 742
8140
8140
  },
8141
8141
  "name": "failedImageBuildsTopic",
8142
8142
  "returns": {
@@ -8153,7 +8153,7 @@
8153
8153
  },
8154
8154
  "locationInModule": {
8155
8155
  "filename": "src/runner.ts",
8156
- "line": 719
8156
+ "line": 724
8157
8157
  },
8158
8158
  "name": "metricFailed",
8159
8159
  "parameters": [
@@ -8179,7 +8179,7 @@
8179
8179
  },
8180
8180
  "locationInModule": {
8181
8181
  "filename": "src/runner.ts",
8182
- "line": 664
8182
+ "line": 669
8183
8183
  },
8184
8184
  "name": "metricJobCompleted",
8185
8185
  "parameters": [
@@ -8205,7 +8205,7 @@
8205
8205
  },
8206
8206
  "locationInModule": {
8207
8207
  "filename": "src/runner.ts",
8208
- "line": 710
8208
+ "line": 715
8209
8209
  },
8210
8210
  "name": "metricSucceeded",
8211
8211
  "parameters": [
@@ -8231,7 +8231,7 @@
8231
8231
  },
8232
8232
  "locationInModule": {
8233
8233
  "filename": "src/runner.ts",
8234
- "line": 726
8234
+ "line": 731
8235
8235
  },
8236
8236
  "name": "metricTime",
8237
8237
  "parameters": [
@@ -8790,7 +8790,7 @@
8790
8790
  },
8791
8791
  "locationInModule": {
8792
8792
  "filename": "src/providers/common.ts",
8793
- "line": 443
8793
+ "line": 445
8794
8794
  },
8795
8795
  "name": "getStepFunctionTask",
8796
8796
  "parameters": [
@@ -8819,7 +8819,7 @@
8819
8819
  },
8820
8820
  "locationInModule": {
8821
8821
  "filename": "src/providers/common.ts",
8822
- "line": 451
8822
+ "line": 453
8823
8823
  },
8824
8824
  "name": "grantStateMachine",
8825
8825
  "parameters": [
@@ -8843,7 +8843,7 @@
8843
8843
  },
8844
8844
  "locationInModule": {
8845
8845
  "filename": "src/providers/common.ts",
8846
- "line": 458
8846
+ "line": 460
8847
8847
  },
8848
8848
  "name": "status",
8849
8849
  "parameters": [
@@ -8908,13 +8908,14 @@
8908
8908
  {
8909
8909
  "abstract": true,
8910
8910
  "docs": {
8911
- "stability": "experimental",
8911
+ "deprecated": "do not use",
8912
+ "stability": "deprecated",
8912
8913
  "summary": "List of step functions errors that should be retried."
8913
8914
  },
8914
8915
  "immutable": true,
8915
8916
  "locationInModule": {
8916
8917
  "filename": "src/providers/common.ts",
8917
- "line": 434
8918
+ "line": 436
8918
8919
  },
8919
8920
  "name": "retryableErrors",
8920
8921
  "type": {
@@ -9448,9 +9449,9 @@
9448
9449
  "abstract": true,
9449
9450
  "assembly": "@cloudsnorkel/cdk-github-runners",
9450
9451
  "docs": {
9451
- "remarks": "Use this to limit access to these functions.",
9452
+ "remarks": "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.",
9452
9453
  "stability": "experimental",
9453
- "summary": "Access configuration options for Lambda functions like setup and webhook function."
9454
+ "summary": "Access configuration options for Lambda functions like setup and webhook function. Use this to limit access to these functions."
9454
9455
  },
9455
9456
  "fqn": "@cloudsnorkel/cdk-github-runners.LambdaAccess",
9456
9457
  "initializer": {
@@ -9461,7 +9462,7 @@
9461
9462
  "kind": "class",
9462
9463
  "locationInModule": {
9463
9464
  "filename": "src/access.ts",
9464
- "line": 46
9465
+ "line": 48
9465
9466
  },
9466
9467
  "methods": [
9467
9468
  {
@@ -9472,7 +9473,7 @@
9472
9473
  },
9473
9474
  "locationInModule": {
9474
9475
  "filename": "src/access.ts",
9475
- "line": 78
9476
+ "line": 80
9476
9477
  },
9477
9478
  "name": "apiGateway",
9478
9479
  "parameters": [
@@ -9499,7 +9500,7 @@
9499
9500
  },
9500
9501
  "locationInModule": {
9501
9502
  "filename": "src/access.ts",
9502
- "line": 87
9503
+ "line": 89
9503
9504
  },
9504
9505
  "name": "githubWebhookIps",
9505
9506
  "returns": {
@@ -9522,7 +9523,7 @@
9522
9523
  },
9523
9524
  "locationInModule": {
9524
9525
  "filename": "src/access.ts",
9525
- "line": 57
9526
+ "line": 59
9526
9527
  },
9527
9528
  "name": "lambdaUrl",
9528
9529
  "returns": {
@@ -9540,7 +9541,7 @@
9540
9541
  },
9541
9542
  "locationInModule": {
9542
9543
  "filename": "src/access.ts",
9543
- "line": 50
9544
+ "line": 52
9544
9545
  },
9545
9546
  "name": "noAccess",
9546
9547
  "returns": {
@@ -9549,6 +9550,44 @@
9549
9550
  }
9550
9551
  },
9551
9552
  "static": true
9553
+ },
9554
+ {
9555
+ "abstract": true,
9556
+ "docs": {
9557
+ "returns": "access URL or empty string if disabled",
9558
+ "stability": "experimental",
9559
+ "summary": "Creates all required resources and returns access URL or empty string if disabled."
9560
+ },
9561
+ "locationInModule": {
9562
+ "filename": "src/access.ts",
9563
+ "line": 100
9564
+ },
9565
+ "name": "bind",
9566
+ "parameters": [
9567
+ {
9568
+ "name": "scope",
9569
+ "type": {
9570
+ "fqn": "constructs.Construct"
9571
+ }
9572
+ },
9573
+ {
9574
+ "name": "id",
9575
+ "type": {
9576
+ "primitive": "string"
9577
+ }
9578
+ },
9579
+ {
9580
+ "name": "lambdaFunction",
9581
+ "type": {
9582
+ "fqn": "aws-cdk-lib.aws_lambda.Function"
9583
+ }
9584
+ }
9585
+ ],
9586
+ "returns": {
9587
+ "type": {
9588
+ "primitive": "string"
9589
+ }
9590
+ }
9552
9591
  }
9553
9592
  ],
9554
9593
  "name": "LambdaAccess",
@@ -9743,7 +9782,7 @@
9743
9782
  },
9744
9783
  "locationInModule": {
9745
9784
  "filename": "src/providers/common.ts",
9746
- "line": 471
9785
+ "line": 473
9747
9786
  },
9748
9787
  "name": "labelsFromProperties",
9749
9788
  "parameters": [
@@ -12523,7 +12562,7 @@
12523
12562
  "docs": {
12524
12563
  "remarks": "This secret is used to register runners and\ncancel jobs when the runner fails to start.\n\nThis secret is meant to be edited by the user after being created.",
12525
12564
  "stability": "experimental",
12526
- "summary": "Authentication secret for GitHub containing either app details or personal authentication token."
12565
+ "summary": "Authentication secret for GitHub containing either app details or personal access token."
12527
12566
  },
12528
12567
  "immutable": true,
12529
12568
  "locationInModule": {
@@ -12539,7 +12578,7 @@
12539
12578
  "docs": {
12540
12579
  "remarks": "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.",
12541
12580
  "stability": "experimental",
12542
- "summary": "GitHub app private key. Not needed when using personal authentication tokens."
12581
+ "summary": "GitHub app private key. Not needed when using personal access tokens."
12543
12582
  },
12544
12583
  "immutable": true,
12545
12584
  "locationInModule": {
@@ -12974,6 +13013,6 @@
12974
13013
  "symbolId": "src/image-builders/aws-image-builder/deprecated/windows-components:WindowsComponents"
12975
13014
  }
12976
13015
  },
12977
- "version": "0.10.3",
12978
- "fingerprint": "AYyfAYvwgR45c5Do+7mQmlWMzqvOxbJ4WoFcX3xTZLI="
13016
+ "version": "0.10.5",
13017
+ "fingerprint": "1KE/jJUTDM7Ylmv7UyWMw1Rxss5Z4fTZZXn6NDFHalM="
12979
13018
  }
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 authentication 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 authentication tokens. |
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 authentication token.
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 authentication tokens.
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
- Use this to limit access to these functions.
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
- ##### `retryableErrors`<sup>Required</sup> <a name="retryableErrors" id="@cloudsnorkel/cdk-github-runners.IRunnerProvider.property.retryableErrors"></a>
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/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. If you want to create an app for your personal repositories, click the Create button under New Personal App
11
- 3. If you want to create an app for your organization:
12
- 1. Find the New Organization App section
13
- 2. Type in the organization name in organization slug (ORGANIZATION from https://github.com/ORGANIZATION/REPO)
14
- 3. Click the Create button
15
- 4. Follow the instructions on GitHub
16
- 5. When brought back to the setup wizard, click the install link
17
- 6. Install the new app on your desired repositories
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
- 6. Ignore/delete `dummy` and **leave `personalAuthToken` empty**
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. Enter your personal access token under Using Personal Access Token
60
- 3. Click the Set button
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