-
Notifications
You must be signed in to change notification settings - Fork 1.7k
327 lines (313 loc) · 14 KB
/
automation-ondemand-tests.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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
name: Automation On Demand Tests
on:
workflow_dispatch:
inputs:
chainlinkVersion:
description: Chainlink image version to use
required: false
type: string
chainlinkImage:
description: Chainlink image repo to use (Leave empty to build from head/ref)
options:
- public.ecr.aws/chainlink/chainlink
- QA_ECR
type: choice
chainlinkVersionUpdate:
description: Chainlink image version to use initially for upgrade test
default: latest
required: true
type: string
chainlinkImageUpdate:
description: Chainlink image repo to use initially for upgrade test
required: true
options:
- public.ecr.aws/chainlink/chainlink
- QA_ECR
type: choice
enableChaos:
description: Check to enable chaos tests
type: boolean
default: false
required: true
enableReorg:
description: Check to enable reorg tests
type: boolean
default: false
required: true
env:
ENV_JOB_IMAGE: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/chainlink-tests:${{ github.sha }}
CHAINLINK_IMAGE: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/chainlink
jobs:
build-chainlink:
environment: integration
permissions:
id-token: write
contents: read
strategy:
matrix:
image:
- name: ""
dockerfile: core/chainlink.Dockerfile
tag-suffix: ""
- name: (plugins)
dockerfile: plugins/chainlink.Dockerfile
tag-suffix: -plugins
name: Build Chainlink Image ${{ matrix.image.name }}
runs-on: ubuntu22.04-16cores-64GB
steps:
- name: Collect Metrics
if: inputs.chainlinkImage == ''
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d9da21a2747016b3e13de58c7d4115a3d5c97935 # v3.0.1
with:
id: automation-on-demand-build-chainlink
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }}
this-job-name: Build Chainlink Image ${{ matrix.image.name }}
continue-on-error: true
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
ref: ${{ github.head_ref || github.ref_name }}
- name: Check if image exists
if: inputs.chainlinkImage == ''
id: check-image
uses: smartcontractkit/chainlink-github-actions/docker/image-exists@75a9005952a9e905649cfb5a6971fd9429436acd # v2.3.25
with:
repository: chainlink
tag: ${{ github.sha }}${{ matrix.image.tag-suffix }}
AWS_REGION: ${{ secrets.QA_AWS_REGION }}
AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
- name: Build Image
if: steps.check-image.outputs.exists == 'false' && inputs.chainlinkImage == ''
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/build-image@75a9005952a9e905649cfb5a6971fd9429436acd # v2.3.25
with:
cl_repo: smartcontractkit/chainlink
cl_ref: ${{ github.sha }}
cl_dockerfile: ${{ matrix.image.dockerfile }}
push_tag: ${{ env.CHAINLINK_IMAGE }}:${{ github.sha }}${{ matrix.image.tag-suffix }}
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
- name: Print Chainlink Image Built
if: inputs.chainlinkImage == ''
run: |
echo "### chainlink node image tag used for this test run :link:" >>$GITHUB_STEP_SUMMARY
echo "\`${GITHUB_SHA}\`" >>$GITHUB_STEP_SUMMARY
build-test-image:
environment: integration
permissions:
id-token: write
contents: read
name: Build Test Image
runs-on: ubuntu22.04-16cores-64GB
steps:
- name: Collect Metrics
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d9da21a2747016b3e13de58c7d4115a3d5c97935 # v3.0.1
with:
id: automation-on-demand-build-test-image
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }}
this-job-name: Build Test Image
continue-on-error: true
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
ref: ${{ github.head_ref || github.ref_name }}
- name: Build Test Image
if: inputs.enableChaos || inputs.enableReorg
uses: ./.github/actions/build-test-image
with:
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ACCOUNT_NUMBER: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
automation-on-demand-tests:
environment: integration
permissions:
checks: write
pull-requests: write
id-token: write
contents: read
needs: [build-chainlink, build-test-image]
env:
CHAINLINK_COMMIT_SHA: ${{ github.sha }}
CHAINLINK_ENV_USER: ${{ github.actor }}
TEST_LOG_LEVEL: info
strategy:
fail-fast: false
matrix:
tests:
- name: chaos
id: chaos
suite: chaos
nodes: 15
os: ubuntu-latest
enabled: ${{ inputs.enableChaos }}
pyroscope_env: ci-automation-on-demand-chaos
network: SIMULATED
command: -run ^TestAutomationChaos$ ./chaos
- name: reorg
id: reorg
suite: reorg
nodes: 7
os: ubuntu-latest
enabled: ${{ inputs.enableReorg }}
pyroscope_env: ci-automation-on-demand-reorg
network: SIMULATED
command: -run ^TestAutomationReorg$ ./reorg
- name: upgrade 2.0
id: upgrade-2.0
type: upgrade
suite: smoke
nodes: 1
os: ubuntu22.04-8cores-32GB
enabled: true
pyroscope_env: ci-automation-on-demand-upgrade
network: SIMULATED
command: -run ^TestAutomationNodeUpgrade/registry_2_0 ./smoke
- name: upgrade 2.1
id: upgrade-2.1
type: upgrade
suite: smoke
nodes: 5
os: ubuntu22.04-8cores-32GB
enabled: true
pyroscope_env: ci-automation-on-demand-upgrade
network: SIMULATED
command: -run ^TestAutomationNodeUpgrade/registry_2_1 ./smoke
- name: upgrade 2.2
id: upgrade-2.2
type: upgrade
suite: smoke
nodes: 5
os: ubuntu22.04-8cores-32GB
enabled: true
pyroscope_env: ci-automation-on-demand-upgrade
network: SIMULATED
command: -run ^TestAutomationNodeUpgrade/registry_2_2 ./smoke
runs-on: ${{ matrix.tests.os }}
name: Automation On Demand ${{ matrix.tests.name }} Test
steps:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
ref: ${{ github.head_ref || github.ref_name }}
- name: Determine build to use
id: determine-build
shell: bash
run: |
if [[ "${{ inputs.chainlinkImage }}" == "QA_ECR" ]]; then
echo "image=${{ env.CHAINLINK_IMAGE }}" >>$GITHUB_OUTPUT
echo "version=${{ github.sha }}" >>$GITHUB_OUTPUT
echo "upgrade_version=${{ github.sha }}" >>$GITHUB_OUTPUT
echo "upgrade_image=${{ env.CHAINLINK_IMAGE }}" >>$GITHUB_OUTPUT
elif [[ "${{ inputs.chainlinkImage }}" == "public.ecr.aws/chainlink/chainlink" ]]; then
READ_CL_IMAGE="public.ecr.aws/chainlink/chainlink"
echo "image=$READ_CL_IMAGE" >>$GITHUB_OUTPUT
echo "version=${{ inputs.chainlinkVersion }}" >>$GITHUB_OUTPUT
echo "upgrade_version=${{ inputs.chainlinkVersion }}" >>$GITHUB_OUTPUT
echo "upgrade_image=$READ_CL_IMAGE" >>$GITHUB_OUTPUT
fi
if [[ "${{ matrix.tests.type }}" == "upgrade" ]]; then
if [[ "${{ inputs.chainlinkImageUpdate }}" == "QA_ECR" ]]; then
echo "image=${{ env.CHAINLINK_IMAGE }}" >>$GITHUB_OUTPUT
elif [[ "${{ inputs.chainlinkImageUpdate }}" == "public.ecr.aws/chainlink/chainlink" ]]; then
echo "image=public.ecr.aws/chainlink/chainlink" >>$GITHUB_OUTPUT
fi
echo "version=${{ inputs.chainlinkVersionUpdate }}" >>$GITHUB_OUTPUT
fi
- name: Setup GAP for Grafana
uses: smartcontractkit/.github/actions/setup-gap@d316f66b2990ea4daa479daa3de6fc92b00f863e # [email protected]
with:
# aws inputs
aws-region: ${{ secrets.AWS_REGION }}
aws-role-arn: ${{ secrets.AWS_OIDC_IAM_ROLE_VALIDATION_PROD_ARN }}
api-gateway-host: ${{ secrets.AWS_API_GW_HOST_GRAFANA }}
# other inputs
duplicate-authorization-header: "true"
- name: Prepare Base64 TOML config
env:
SELECTED_NETWORKS: ${{ matrix.tests.network }}
UPGRADE_VERSION: ${{ steps.determine-build.outputs.upgrade_version }}
UPGRADE_IMAGE: ${{ steps.determine-build.outputs.upgrade_image }}
RUN_ID: ${{ github.run_id }}
TEST_LOG_COLLECT: "true"
LOGSTREAM_LOG_TARGETS: ${{ vars.LOGSTREAM_LOG_TARGETS }}
run: |
# load reusable functions
source ./.github/scripts/functions.sh
selected_networks=$(convert_to_toml_array "$SELECTED_NETWORKS")
if [ -n "$TEST_LOG_COLLECT" ]; then
test_log_collect=true
else
test_log_collect=false
fi
log_targets=$(convert_to_toml_array "$LOGSTREAM_LOG_TARGETS")
cat << EOF > config.toml
[Network]
selected_networks=$selected_networks
[ChainlinkImage]
version="$OLD_VERSION"
[ChainlinkUpgradeImage]
version="$UPGRADE_VERSION"
[Logging]
test_log_collect=$test_log_collect
run_id="$RUN_ID"
[Logging.LogStream]
log_targets=$log_targets
EOF
BASE64_CONFIG_OVERRIDE=$(cat config.toml | base64 -w 0)
echo ::add-mask::$BASE64_CONFIG_OVERRIDE
echo "BASE64_CONFIG_OVERRIDE=$BASE64_CONFIG_OVERRIDE" >> $GITHUB_ENV
- name: Run Tests
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/run-tests@2967f2287bd3f3ddbac7b476e9568993df01796e # v2.3.27
if: ${{ matrix.tests.enabled == true }}
with:
test_config_override_base64: ${{ env.BASE64_CONFIG_OVERRIDE }}
test_command_to_run: cd ./integration-tests && go test -timeout 60m -count=1 -json -test.parallel=${{ matrix.tests.nodes }} ${{ matrix.tests.command }} 2>&1 | tee /tmp/gotest.log | gotestloghelper -ci -singlepackage -hidepassingtests=false -hidepassinglogs
test_download_vendor_packages_command: cd ./integration-tests && go mod download
test_suite: ${{ matrix.tests.suite }}
cl_repo: ${{ steps.determine-build.outputs.image }}
cl_image_tag: ${{ steps.determine-build.outputs.version }}
aws_registries: ${{ secrets.QA_AWS_ACCOUNT_NUMBER }}
artifacts_location: ./integration-tests/${{ matrix.tests.suite }}/logs
publish_check_name: Automation On Demand Results ${{ matrix.tests.name }}
token: ${{ secrets.GITHUB_TOKEN }}
go_mod_path: ./integration-tests/go.mod
QA_AWS_REGION: ${{ secrets.QA_AWS_REGION }}
QA_AWS_ROLE_TO_ASSUME: ${{ secrets.QA_AWS_ROLE_TO_ASSUME }}
QA_KUBECONFIG: ${{ secrets.QA_KUBECONFIG }}
DEFAULT_CHAINLINK_IMAGE: ${{ steps.determine-build.outputs.image }}
DEFAULT_CHAINLINK_UPGRADE_IMAGE: ${{ steps.determine-build.outputs.upgrade_image }}
DEFAULT_LOKI_TENANT_ID: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
DEFAULT_LOKI_ENDPOINT: https://${{ secrets.GRAFANA_INTERNAL_HOST }}/loki/api/v1/push
DEFAULT_LOKI_BASIC_AUTH: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
DEFAULT_GRAFANA_BASE_URL: "http://localhost:8080/primary"
DEFAULT_GRAFANA_DASHBOARD_URL: "/d/ddf75041-1e39-42af-aa46-361fe4c36e9e/ci-e2e-tests-logs"
DEFAULT_GRAFANA_BEARER_TOKEN: ${{ secrets.GRAFANA_INTERNAL_URL_SHORTENER_TOKEN }}
DEFAULT_PYROSCOPE_SERVER_URL: ${{ matrix.tests.pyroscope_env == '' && '' || !startsWith(github.ref, 'refs/tags/') && '' || secrets.QA_PYROSCOPE_INSTANCE }} # Avoid sending blank envs https://github.com/orgs/community/discussions/25725
DEFAULT_PYROSCOPE_KEY: ${{ secrets.QA_PYROSCOPE_KEY }}
DEFAULT_PYROSCOPE_ENVIRONMENT: ${{ matrix.tests.pyroscope_env }}
DEFAULT_PYROSCOPE_ENABLED: ${{ matrix.tests.pyroscope_env == '' || !startsWith(github.ref, 'refs/tags/') && 'false' || 'true' }}
- name: Upload test log
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: failure()
with:
name: test-log-${{ matrix.tests.name }}
path: /tmp/gotest.log
retention-days: 7
continue-on-error: true
- name: Collect Metrics
if: always()
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d9da21a2747016b3e13de58c7d4115a3d5c97935 # v3.0.1
with:
id: automation-on-demand-tests-${{ matrix.tests.id }}
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }}
this-job-name: Automation On Demand ${{ matrix.tests.name }} Test
test-results-file: '{"testType":"go","filePath":"/tmp/gotest.log"}'
continue-on-error: true