Skip to content

Commit 459fc46

Browse files
Add integ test run on PR open (#3)
* Add integ test run on pr open * Refactor base test stack for integ tests
1 parent 0f2fed1 commit 459fc46

20 files changed

+2290
-2166
lines changed

.github/workflows/pr.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Pull Request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: lts/hydrogen
16+
registry-url: https://registry.npmjs.org
17+
- uses: actions/cache@v2
18+
with:
19+
path: ~/.npm
20+
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
21+
- run: npm ci
22+
- run: npm run build
23+
- run: npm run layer:build
24+
- run: npm run test:integ

integ.config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"maxWorkers": 2,
33
"parallelRegions": [
4+
"us-east-1",
45
"eu-west-1"
56
],
67
"language": "typescript"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"watch": "tsc -w",
88
"test": "jest",
99
"layer:build": "pkg -t linux-x64 -o lib/layerX86/extensions/revant lib/revant-extension/revant.js && pkg -t linux-arm64 -o lib/layerARM/extensions/revant lib/revant-extension/revant.js",
10-
"integ": "integ-runner --update-on-failed"
10+
"test:integ": "integ-runner"
1111
},
1212
"devDependencies": {
1313
"@aws-cdk/integ-runner": "^2.92.0-alpha.0",

test/integ.ec2.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { App, Aspects, Duration, Stack, StackProps } from "aws-cdk-lib";
1+
import { App, Duration, StackProps } from "aws-cdk-lib";
22
import { Construct } from "constructs";
33
import { ExpectedResult, IntegTest, Match } from "@aws-cdk/integ-tests-alpha";
44

@@ -10,17 +10,12 @@ import {
1010
MachineImage,
1111
Vpc,
1212
} from "aws-cdk-lib/aws-ec2";
13-
import { Revantios } from "../lib/revantios";
14-
import { CostLimit } from "../lib";
15-
import { CoreRessources } from "../lib/core-resources";
13+
import { BaseStackUnderTest } from "./test-utils";
1614

1715
const app = new App();
1816

19-
class EC2Stack extends Stack {
20-
public budget = Revantios.fromUSD(1);
17+
class EC2Stack extends BaseStackUnderTest {
2118
public instanceId: string;
22-
public dynamoDBBudgetIndex: string;
23-
public dynamoDBTableName: string;
2419
constructor(scope: Construct, id: string, props?: StackProps) {
2520
super(scope, id, props);
2621

@@ -31,14 +26,7 @@ class EC2Stack extends Stack {
3126
machineImage: MachineImage.latestAmazonLinux2023(),
3227
});
3328

34-
Aspects.of(this).add(new CostLimit({ budget: this.budget.toCents() }));
3529
this.instanceId = instance.instanceId;
36-
this.dynamoDBBudgetIndex = [
37-
new Date().toISOString().slice(0, 7),
38-
this.node.addr,
39-
].join("#");
40-
this.dynamoDBTableName =
41-
CoreRessources.getInstance(this).dynamoDBTable.tableName;
4230
}
4331
}
4432

@@ -98,7 +86,7 @@ integ.assertions
9886
},
9987
updatedAt: {
10088
S: new Date().toISOString(),
101-
}
89+
},
10290
},
10391
})
10492
)

test/integ.ec2.ts.snapshot/EC2IntegDefaultTestDeployAssert36B7B092.assets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
}
1515
}
1616
},
17-
"0cb8b99422440380d6b24c36030d9775039ff42fbe62b46230d3d264345ec19b": {
17+
"8f0857fc1d012a5bbb3d33d9d631725fd115daa1908a53674b97ab116bd27a92": {
1818
"source": {
1919
"path": "EC2IntegDefaultTestDeployAssert36B7B092.template.json",
2020
"packaging": "file"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "0cb8b99422440380d6b24c36030d9775039ff42fbe62b46230d3d264345ec19b.json",
25+
"objectKey": "8f0857fc1d012a5bbb3d33d9d631725fd115daa1908a53674b97ab116bd27a92.json",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}

test/integ.ec2.ts.snapshot/EC2IntegDefaultTestDeployAssert36B7B092.template.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727
},
2828
"flattenResponse": "false",
29-
"salt": "1694012790544"
29+
"salt": "1694276119451"
3030
},
3131
"UpdateReplacePolicy": "Delete",
3232
"DeletionPolicy": "Delete"
@@ -178,7 +178,7 @@
178178
"Filters": "[{\"Name\":\"instance-state-name\",\"Values\":[\"pending\",\"running\",\"shutting-down\",\"terminated\",\"stopping\",\"stopped\"]}]"
179179
},
180180
"flattenResponse": "false",
181-
"salt": "1694012790544"
181+
"salt": "1694276119451"
182182
},
183183
"DependsOn": [
184184
"AwsApiCallEC2stopInstancesae3190c9cc698cf969f9acf9d133e035"
@@ -425,7 +425,7 @@
425425
}
426426
}
427427
},
428-
"AwsApiCallDynamoDBputItemefd261a4428d09668b91214c4ea140f4": {
428+
"AwsApiCallDynamoDBputItemff310099c11c3b1d47f94c2d167ede56": {
429429
"Type": "Custom::DeployAssert@SdkCallDynamoDBputItem",
430430
"Properties": {
431431
"ServiceToken": {
@@ -449,10 +449,10 @@
449449
]
450450
]
451451
},
452-
"Item": "{\"PK\":{\"S\":\"2023-09#c8f5ec86153761e35310d3376adad0942b36297052\"},\"accruedExpenses\":{\"N\":\"10000000001\"},\"updatedAt\":{\"S\":\"2023-09-06T15:06:30.545Z\"}}"
452+
"Item": "{\"PK\":{\"S\":\"2023-09#c8f5ec86153761e35310d3376adad0942b36297052\"},\"accruedExpenses\":{\"N\":\"10000000001\"},\"updatedAt\":{\"S\":\"2023-09-09T16:15:19.452Z\"}}"
453453
},
454454
"flattenResponse": "false",
455-
"salt": "1694012790545"
455+
"salt": "1694276119452"
456456
},
457457
"DependsOn": [
458458
"AwsApiCallEC2describeInstanceStatusb32986d428de6b3fc2ed9cd3ca844424",
@@ -490,10 +490,10 @@
490490
}
491491
},
492492
"flattenResponse": "false",
493-
"salt": "1694012790545"
493+
"salt": "1694276119452"
494494
},
495495
"DependsOn": [
496-
"AwsApiCallDynamoDBputItemefd261a4428d09668b91214c4ea140f4"
496+
"AwsApiCallDynamoDBputItemff310099c11c3b1d47f94c2d167ede56"
497497
],
498498
"UpdateReplacePolicy": "Delete",
499499
"DeletionPolicy": "Delete"
@@ -529,7 +529,7 @@
529529
"IncludeAllInstances": "true"
530530
},
531531
"flattenResponse": "false",
532-
"salt": "1694012790545"
532+
"salt": "1694276119452"
533533
},
534534
"DependsOn": [
535535
"AwsApiCallEC2startInstancesae3190c9cc698cf969f9acf9d133e035"

test/integ.ec2.ts.snapshot/EC2StackUnderTest.assets.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
22
"version": "33.0.0",
33
"files": {
4-
"4b996a3e5a083d5c78c6f30a8571a94fb7ec557eecbe54dbc065faba0d9076e6": {
4+
"3d0ed04128f7a73685fa26cd18facba2ffc6ba76775010e856976db6cb55ad5f": {
55
"source": {
6-
"path": "asset.4b996a3e5a083d5c78c6f30a8571a94fb7ec557eecbe54dbc065faba0d9076e6",
6+
"path": "asset.3d0ed04128f7a73685fa26cd18facba2ffc6ba76775010e856976db6cb55ad5f",
77
"packaging": "zip"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "4b996a3e5a083d5c78c6f30a8571a94fb7ec557eecbe54dbc065faba0d9076e6.zip",
12+
"objectKey": "3d0ed04128f7a73685fa26cd18facba2ffc6ba76775010e856976db6cb55ad5f.zip",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}
1616
},
17-
"3d0ed04128f7a73685fa26cd18facba2ffc6ba76775010e856976db6cb55ad5f": {
17+
"4b996a3e5a083d5c78c6f30a8571a94fb7ec557eecbe54dbc065faba0d9076e6": {
1818
"source": {
19-
"path": "asset.3d0ed04128f7a73685fa26cd18facba2ffc6ba76775010e856976db6cb55ad5f",
19+
"path": "asset.4b996a3e5a083d5c78c6f30a8571a94fb7ec557eecbe54dbc065faba0d9076e6",
2020
"packaging": "zip"
2121
},
2222
"destinations": {
2323
"current_account-current_region": {
2424
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "3d0ed04128f7a73685fa26cd18facba2ffc6ba76775010e856976db6cb55ad5f.zip",
25+
"objectKey": "4b996a3e5a083d5c78c6f30a8571a94fb7ec557eecbe54dbc065faba0d9076e6.zip",
2626
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2727
}
2828
}
@@ -40,15 +40,15 @@
4040
}
4141
}
4242
},
43-
"3a6278219005c65cf02b6db9d30b907d3e35189fb4a892dff9a35d59c7efaf75": {
43+
"8120cdcfefcafaea628026c2c00aa72c2711c3066ed2a8f9c689285e71d0b15f": {
4444
"source": {
4545
"path": "EC2StackUnderTest.template.json",
4646
"packaging": "file"
4747
},
4848
"destinations": {
4949
"current_account-current_region": {
5050
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
51-
"objectKey": "3a6278219005c65cf02b6db9d30b907d3e35189fb4a892dff9a35d59c7efaf75.json",
51+
"objectKey": "8120cdcfefcafaea628026c2c00aa72c2711c3066ed2a8f9c689285e71d0b15f.json",
5252
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
5353
}
5454
}

0 commit comments

Comments
 (0)