-
Notifications
You must be signed in to change notification settings - Fork 240
145 lines (127 loc) · 4.5 KB
/
canary.yml
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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
name: 'Canary Test'
on:
schedule:
- cron: '0 */3 * * *' # triggers the workflow every three hours
workflow_dispatch:
env:
TF_VAR_patch: 'true'
TESTING_FRAMEWORK_REPO: aws-observability/aws-otel-test-framework
concurrency:
group: canary-${{ github.ref_name }}
permissions:
id-token: write
contents: read
jobs:
create-test-ref:
runs-on: ubuntu-22.04
outputs:
testRef: ${{ steps.setRef.outputs.ref }}
steps:
- name: Set testRef output
id: setRef
run: |
if [[ ${{ github.ref_name }} == release/v* ]]; then
echo "ref=${{github.ref_name}}" >> $GITHUB_OUTPUT
else
echo "ref=terraform" >> $GITHUB_OUTPUT
fi
build-aotutil:
runs-on: ubuntu-22.04
needs: create-test-ref
steps:
- name: Check out testing framework
uses: actions/checkout@v4
with:
repository: ${{ env.TESTING_FRAMEWORK_REPO }}
path: testing-framework
ref: ${{ needs.create-test-ref.outputs.testRef }}
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: '~1.22.7'
cache-dependency-path: testing-framework/cmd/aotutil/go.sum
- name: Build aotutil
run: cd testing-framework/cmd/aotutil && make build
- name: Cache aotutil
uses: actions/cache@v3
with:
key: "aotutil_${{ github.run_id }}"
path: testing-framework/cmd/aotutil/aotutil
get-canary-test-cases:
runs-on: ubuntu-22.04
needs:
- build-aotutil
outputs:
canary_matrix: ${{ steps.get-test-cases.outputs.canary_matrix }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: get all the canary test cases
id: get-test-cases
run: |
canary_matrix=$(python e2etest/get-testcases.py canary_matrix)
echo "canary_matrix=$canary_matrix" >> $GITHUB_OUTPUT
run-canary-test:
runs-on: ubuntu-22.04
needs: [get-canary-test-cases, create-test-ref]
strategy:
matrix: ${{ fromJson(needs.get-canary-test-cases.outputs.canary_matrix) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.COLLECTOR_ASSUMABLE_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '11'
- name: Set up terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "~1.5"
- name: Check out testing framework
uses: actions/checkout@v4
with:
repository: ${{ env.TESTING_FRAMEWORK_REPO }}
path: testing-framework
ref: ${{ needs.create-test-ref.outputs.testRef }}
- name: Restore aoutil
uses: actions/cache@v3
with:
key: "aotutil_${{ github.run_id }}"
path: testing-framework/cmd/aotutil/aotutil
- name: Run Canary test
uses: nick-fields/retry@v2
with:
max_attempts: 3
timeout_minutes: 60
command: |
opts=""
if [[ -f testing-framework/terraform/testcases/${{ matrix.testcase }}/parameters.tfvars ]] ; then opts="-var-file=../testcases/${{ matrix.testcase }}/parameters.tfvars" ; fi
cd testing-framework/terraform/canary
terraform init
terraform apply -auto-approve -lock=false $opts -var="aoc_version=latest" -var="testcase=../testcases/${{ matrix.testcase }}" -var="testing_ami=${{ matrix.testing_ami }}"
- name: Destroy terraform resources
if: ${{ always() }}
run: |
cd testing-framework/terraform/canary && terraform destroy -auto-approve -var="region=us-west-2"