Skip to content

Commit c5ae346

Browse files
committed
chore: migrate to GHA
1 parent 28ef544 commit c5ae346

23 files changed

+1417
-1
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: Acceptenace Test Run
3+
on:
4+
workflow_call:
5+
inputs:
6+
tests:
7+
required: true
8+
type: string
9+
deletion-policy:
10+
required: true
11+
type: string # delete/retain
12+
permissions:
13+
id-token: write
14+
contents: read
15+
defaults:
16+
run:
17+
shell: bash
18+
jobs:
19+
run:
20+
runs-on: ['hyperenv', 'medium']
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: aws-actions/configure-aws-credentials@v4.0.1
24+
with:
25+
role-to-assume: arn:aws:iam::859548834666:role/github-openid-connect
26+
role-session-name: github-actions-aws-in-action-code3
27+
role-duration-seconds: 21600
28+
aws-region: us-east-1
29+
- uses: actions/setup-java@v3
30+
with:
31+
distribution: corretto
32+
java-version: '8'
33+
cache: maven
34+
- working-directory: test
35+
env:
36+
DELETION_POLICY: ${{ inputs.deletion-policy }}
37+
TEMPLATE_DIR: ../
38+
run: mvn -B clean test site -Dtest=${{ inputs.tests }} -Dsurefire.reportNameSuffix=us-east-1
39+
- uses: actions/upload-artifact@v3
40+
if: failure()
41+
with:
42+
name: surefire-reports-us-east-1
43+
path: |
44+
test/target/surefire-reports/
45+
test/target/site/

.github/workflows/acceptance-test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: Acceptenace Test
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tests:
7+
required: true
8+
type: choice
9+
default: '*'
10+
options: # compile list with cd test/src && find . -name '*Test*' -execdir basename {} .java ';' | sort
11+
- '*'
12+
- Chapter02Test
13+
- Chapter04Test
14+
- Chapter05Test
15+
- Chapter08Test
16+
- Chapter09Test
17+
- Chapter10Test
18+
- Chapter11Test
19+
- Chapter13Test
20+
- Chapter14Test
21+
- Chapter15Test
22+
- Chapter17Test
23+
- Chapter18Test
24+
deletion-policy:
25+
required: true
26+
type: choice
27+
default: delete
28+
options:
29+
- delete
30+
- retain
31+
defaults:
32+
run:
33+
shell: bash
34+
jobs:
35+
acceptance-test:
36+
uses: ./.github/workflows/acceptance-test-run.yml
37+
with:
38+
tests: ${{ inputs.tests }}
39+
deletion-policy: ${{ inputs.deletion-policy }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Acceptenace Tests
3+
on:
4+
workflow_dispatch: {}
5+
push:
6+
branches:
7+
- master
8+
paths:
9+
- '.github/workflows/acceptance-tests.yml'
10+
- '*.yaml'
11+
- 'test/**'
12+
concurrency: acceptenace-tests-${{ github.ref }}
13+
defaults:
14+
run:
15+
shell: bash
16+
jobs:
17+
acceptance-test:
18+
uses: ./.github/workflows/acceptance-test-run.yml
19+
with:
20+
tests: '*'
21+
deletion-policy: delete

.github/workflows/latest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
aws-region: us-east-1
2323
- name: latest
2424
run: |
25-
aws s3 sync --delete --exact-timestamps --exclude ".git/*" --exclude ".github/*" ./ s3://awsinaction-code3/
25+
aws s3 sync --delete --exact-timestamps --exclude ".git/*" --exclude ".github/*" --exclude "test/*" ./ s3://awsinaction-code3/

test/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# AWS in Action (3rd edition) Code tests
2+
3+
Tests for https://github.com/AWSinAction/code3
4+
5+
The goal of this tests is to ensure that our templates are always working. The test are implemented in Java 8 and run in JUnit 4.
6+
7+
If you run this tests, many AWS CloudFormation tests are created and **charges will apply**!
8+
9+
## Supported env variables
10+
11+
* `IAM_ROLE_ARN` if the tests should assume an IAM role before they run supply the ARN of the IAM role
12+
* `TEMPLATE_DIR` Load templates from local disk (instead of S3 bucket `widdix-aws-cf-templates`). Must end with an `/`. See `BUCKET_NAME` as well.
13+
* `BUCKET_NAME` Some templates are to big to be passed as a string from local disk, therefore you need to supply the name of the bucket that is used to upload templates.
14+
* `BUCKET_REGION` **required if BUCKET_NAME is set** Region of the bucket
15+
* `DELETION_POLICY` (default `delete`, allowed values [`delete`, `retain`]) should resources be deleted?
16+
17+
## Usage
18+
19+
### AWS credentials
20+
21+
The AWS credentials are passed in as defined by the AWS SDK for Java: http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html
22+
23+
One addition is, that you can supply the env variable `IAM_ROLE_ARN` which let's the tests assume a role before they start with the default credentials.
24+
25+
### Region selection
26+
27+
The region selection works like defined by the AWS SDK for Java: http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-region-selection.html
28+
29+
### Run all tests
30+
31+
```
32+
AWS_REGION="us-east-1" mvn test
33+
```
34+
35+
### Run a single test suite
36+
37+
to run the `TestJenkins` tests:
38+
39+
```
40+
AWS_REGION="us-east-1" mvn -Dtest=TestJenkins test
41+
```
42+
43+
### Run a single test
44+
45+
to run the `TestJenkins.testHA` test:
46+
47+
```
48+
AWS_REGION="us-east-1" mvn -Dtest=TestJenkins#testHA test
49+
```
50+
51+
### Load templates from local file system
52+
53+
```
54+
AWS_REGION="us-east-1" BUCKET_REGION="..." BUCKET_NAME="..." TEMPLATE_DIR="/path/to/widdix-aws-cf-templates/" mvn test
55+
```
56+
57+
### Assume role
58+
59+
This is useful if you run on a integration server like Jenkins and want to assume a different IAM role for this tests.
60+
61+
```
62+
IAM_ROLE_ARN="arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME" mvn test
63+
```

test/pom.xml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>de.widdix</groupId>
8+
<artifactId>aws-in-action-code3-tests</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<dependencies>
12+
<dependency>
13+
<groupId>com.amazonaws</groupId>
14+
<artifactId>aws-java-sdk-cloudformation</artifactId>
15+
<scope>test</scope>
16+
</dependency>
17+
<dependency>
18+
<groupId>com.amazonaws</groupId>
19+
<artifactId>aws-java-sdk-ec2</artifactId>
20+
<scope>test</scope>
21+
</dependency>
22+
<dependency>
23+
<groupId>com.amazonaws</groupId>
24+
<artifactId>aws-java-sdk-s3</artifactId>
25+
<scope>test</scope>
26+
</dependency>
27+
<dependency>
28+
<groupId>com.amazonaws</groupId>
29+
<artifactId>aws-java-sdk-ecs</artifactId>
30+
<scope>test</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.amazonaws</groupId>
34+
<artifactId>aws-java-sdk-sts</artifactId>
35+
<scope>test</scope>
36+
</dependency>
37+
<dependency>
38+
<groupId>de.taimos</groupId>
39+
<artifactId>httputils</artifactId>
40+
<version>1.10</version>
41+
<scope>test</scope>
42+
</dependency>
43+
<dependency>
44+
<groupId>com.evanlennick</groupId>
45+
<artifactId>retry4j</artifactId>
46+
<version>0.6.2</version>
47+
<scope>test</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>com.jcraft</groupId>
51+
<artifactId>jsch</artifactId>
52+
<version>0.1.54</version>
53+
<scope>test</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>junit</groupId>
57+
<artifactId>junit</artifactId>
58+
<version>4.12</version>
59+
<scope>test</scope>
60+
</dependency>
61+
</dependencies>
62+
63+
<dependencyManagement>
64+
<dependencies>
65+
<dependency>
66+
<groupId>com.amazonaws</groupId>
67+
<artifactId>aws-java-sdk-bom</artifactId>
68+
<version>1.11.883</version>
69+
<type>pom</type>
70+
<scope>import</scope>
71+
</dependency>
72+
</dependencies>
73+
</dependencyManagement>
74+
75+
<build>
76+
<plugins>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-compiler-plugin</artifactId>
80+
<version>3.6.1</version>
81+
<configuration>
82+
<source>1.8</source>
83+
<target>1.8</target>
84+
</configuration>
85+
</plugin>
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-surefire-plugin</artifactId>
89+
<version>2.20</version>
90+
<configuration>
91+
<parallel>classes</parallel>
92+
<threadCount>2</threadCount>
93+
</configuration>
94+
</plugin>
95+
</plugins>
96+
</build>
97+
98+
</project>

0 commit comments

Comments
 (0)