-
Notifications
You must be signed in to change notification settings - Fork 143
175 lines (140 loc) · 5 KB
/
IntegrationTesting.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Integration Testing
on:
push:
branches:
- master
jobs:
build_SDK:
name: Build X-Ray Python SDK
runs-on: ubuntu-latest
steps:
- name: Pull in source code from aws-xray-sdk-python Github repository
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Build X-Ray Python SDK
run: python setup.py sdist
- name: Upload SDK build artifact
uses: actions/upload-artifact@v3
with:
name: sdk-build-artifact
path: .
build_WebApp:
name: Build Web Application
needs: build_SDK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Download X-Ray SDK build artifact
uses: actions/download-artifact@v3
with:
name: sdk-build-artifact
path: ./sample-apps/flask
- name: Build WebApp with X-Ray Python SDK
run: pip3 install . -t .
working-directory: ./sample-apps/flask
- name: Zip up the deployment package
run: zip -r deploy.zip . -x '*.git*'
working-directory: ./sample-apps/flask
- name: Upload WebApp with X-Ray SDK build artifact
uses: actions/upload-artifact@v3
with:
name: sdk-flask-build-artifact
path: ./sample-apps/flask/deploy.zip
deploy_WebApp:
name: Deploy Web Application
needs: build_WebApp
runs-on: ubuntu-latest
steps:
- name: Checkout X-Ray SDK to get terraform source
uses: actions/checkout@v3
- name: Download WebApp with X-Ray SDK build artifact
uses: actions/download-artifact@v3
with:
name: sdk-flask-build-artifact
- name: Copy deployment package to terraform directory
run: cp deploy.zip ./terraform
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Terraform Init
run: terraform init
working-directory: ./terraform
- name: Terraform Validate
run: terraform validate -no-color
working-directory: ./terraform
- name: Terraform Plan
run: terraform plan -var-file="fixtures.us-west-2.tfvars" -no-color
env:
TF_VAR_resource_prefix: '${{ github.run_id }}-${{ github.run_number }}'
continue-on-error: true
working-directory: ./terraform
- name: Terraform Apply
run: terraform apply -var-file="fixtures.us-west-2.tfvars" -auto-approve
env:
TF_VAR_resource_prefix: '${{ github.run_id }}-${{ github.run_number }}'
working-directory: ./terraform
- name: Upload terraform state files for destorying resources
uses: actions/upload-artifact@v3
with:
name: terraform-state-artifact
path: ./terraform
test_WebApp:
name: Test WebApp
needs: deploy_WebApp
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 14
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Checkout test framework
uses: actions/checkout@v3
with:
repository: aws-observability/aws-otel-test-framework
ref: terraform
- name: Run testing suite
run: ./gradlew :validator:run --args='-c default-xray-trace-validation.yml --endpoint http://${{ github.run_id }}-${{ github.run_number }}-eb-app-env.us-west-2.elasticbeanstalk.com'
cleanup:
name: Resource tear down
needs: test_WebApp
if: always()
runs-on: ubuntu-latest
steps:
- name: Download terraform state artifact
uses: actions/download-artifact@v3
with:
name: terraform-state-artifact
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Terraform Init
run: terraform init
- name: set permissions to terraform plugins
run: chmod -R a+x .terraform/*
- name: Destroy resources
run: terraform destroy -state="terraform.tfstate" -var-file="fixtures.us-west-2.tfvars" -auto-approve
env:
TF_VAR_resource_prefix: '${{ github.run_id }}-${{ github.run_number }}'