forked from neonevm/neon-tests
-
Notifications
You must be signed in to change notification settings - Fork 3
324 lines (317 loc) · 12.9 KB
/
basic.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
name: "Basic&EVM tests"
run-name: Basic&EVM tests / ${{ github.event.pull_request.title || github.event_name }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
schedule:
- cron: "0 1 * * 0,1,2,3,4"
- cron: "0 2 * * 0,1,2,3,4"
pull_request:
types: [ opened, reopened, synchronize ]
workflow_dispatch:
inputs:
network:
type: choice
default: terraform
required: true
description: "Stand name"
options:
- terraform
- night-stand
- devnet
- mainnet
numprocesses:
type: choice
default: 8
required: true
description: "Number of parallel jobs"
options:
- 2
- 4
- 8
- 12
- auto
generate_cost_report:
type: boolean
default: false
required: false
description: "Create cost report"
pytest_k:
type: string
default: "test_"
required: false
description: "Filter tests by name: pytest -k ..."
pytest_m:
type: string
default: ""
required: false
description: "Filter tests by mark: pytest -m ..."
env:
NETWORK: ${{ github.event.inputs.network || 'terraform' }}
NUMPROCESSES: ${{ github.event.inputs.numprocesses || 8 }}
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
DEVNET_SOLANA_URL: "${{ secrets.SOLANA_URL }}"
FAUCET_URL: "${{ secrets.DEVNET_FAUCET_URL }}"
IMAGE: ${{ github.repository_owner }}/neon_tests
DOCKER_HUB_ORG_NAME: ${{ github.repository_owner }}
GENERATE_COST_REPORT: ${{ github.event.inputs.generate_cost_report || 'false' }}
jobs:
pre-commit-check:
name: Pre-commit hook validation
runs-on: ["self-hosted", "k8s-prod"]
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: pre-commit/action@v3.0.1
timeout-minutes: 3
dockerize:
name: Dockerize neon tests
runs-on: ["self-hosted", "k8s-prod"]
needs: pre-commit-check
steps:
- uses: actions/checkout@v4
- name: Dockerize neon tests
if: ${{ github.ref_name != 'develop'}}
uses: ./.github/actions/dockerize-neon-tests
with:
image_tag: ${{ github.sha }}
docker_username: ${{ secrets.DOCKER_USERNAME }}
docker_password: ${{ secrets.DOCKER_PASSWORD }}
image_name: ${{ env.IMAGE }}
docker_hub_org_name: ${{ env.DOCKER_HUB_ORG_NAME }}
- name: "Define image tag"
id: image_tag
uses: ./.github/actions/define-image-tag
outputs:
tag: ${{ steps.image_tag.outputs.tag }}
prepare-env-proxy:
name: Prepare environment for proxy tests
runs-on: ["self-hosted", "k8s-prod"]
needs: pre-commit-check
if: always()
steps:
- uses: hashicorp/setup-terraform@v3
- uses: actions/setup-node@v4
with:
node-version: 16
- name: Setup `terraform` by cron schedule
id: setup_terraform_stand
if: github.event.schedule=='0 1 * * 0,1,2,3,4'
run: |
echo "NETWORK=terraform" >> $GITHUB_ENV
- name: Setup `devnet` by cron schedule
if: github.event.schedule=='0 2 * * 0,1,2,3,4'
run: |
echo "NETWORK=devnet" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: "Prepare terraform stand"
id: prepare_terraform
if: ${{ env.NETWORK == 'terraform' }}
timeout-minutes: 15
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_DEFAULT_REGION: ${{secrets.AWS_DEFAULT_REGION}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
HCLOUD_TOKEN: ${{secrets.HCLOUD_TOKEN}}
TFSTATE_BUCKET: ${{vars.TFSTATE_BUCKET}}
TFSTATE_KEY: ${{vars.TFSTATE_KEY_PREFIX}}-${{ github.run_number }}
TFSTATE_REGION: ${{vars.TFSTATE_REGION}}
uses: ./.github/actions/create-tf-stand
with:
ci_stands_key_hcloud: ${{ secrets.CI_STANDS_KEY_HCLOUD }}
outputs:
proxy_ip: ${{ steps.prepare_terraform.outputs.proxy_ip }}
solana_ip: ${{ steps.prepare_terraform.outputs.solana_ip }}
network: ${{ env.NETWORK }}
run-evm-tests:
name: Run EVM tests
runs-on: ["self-hosted", "k8s-prod"]
needs:
- dockerize
env:
DOCKER_PROJECT_NAME: "evm-tests-${{ github.run_number }}-${{ github.run_attempt }}"
outputs:
test-group : ${{ steps.step_fail.outputs.FAILED_TEST_GROUP }}
steps:
- uses: actions/checkout@v4
if: ${{ env.NETWORK != 'devnet' }}
with:
fetch-depth: 0
- name: Install python requirements
if: ${{ env.NETWORK != 'devnet' }}
uses: ./.github/actions/python-requirements
- name: Set evm image tag
if: ${{ env.NETWORK != 'devnet' }}
id: share
run: |
env_tag=$(python3 ./clickfile.py infra get-stand-param \
--current_branch "${{ github.ref_name }}" \
--head_branch "${{ github.head_ref }}" \
--base_branch "${{ github.base_ref }}" \
--param "evm_tag")
evm_branch=$(python3 ./clickfile.py infra get-stand-param \
--current_branch "${{ github.ref_name }}" \
--head_branch "${{ github.head_ref }}" \
--base_branch "${{ github.base_ref }}" \
--param "evm_branch")
echo "evm_tag=$env_tag"
echo "evm_tag=$env_tag" >> $GITHUB_OUTPUT
echo "evm_branch=$evm_branch"
echo "evm_branch=$evm_branch" >> $GITHUB_OUTPUT
- name: Run tests
if: ${{ env.NETWORK != 'devnet' }}
env:
NEON_TESTS_IMAGE: ${{ env.IMAGE }}:${{ needs.dockerize.outputs.tag }}
EVM_LOADER_IMAGE: ${{ github.repository_owner }}/evm_loader:${{ steps.share.outputs.evm_tag }}
run: |
curl -O https://raw.githubusercontent.com/${{ github.repository_owner }}/neon-evm/${{ steps.share.outputs.evm_branch }}/ci/docker-compose-ci.yml
docker-compose -p ${{env.DOCKER_PROJECT_NAME}} -f docker-compose-ci.yml pull
docker-compose -p ${{env.DOCKER_PROJECT_NAME}} -f docker-compose-ci.yml up -d
docker exec -i ${{env.DOCKER_PROJECT_NAME}}-tests-1 bash -c "python3 clickfile.py run evm --numprocesses 8 --network docker_net --case \"${{ github.event.inputs.pytest_k}}\" --marker \"${{ github.event.inputs.pytest_m}}\""
- name: Set failed test group to evm
id: step_fail
if: failure()
run: echo "FAILED_TEST_GROUP=evm" >> $GITHUB_OUTPUT
- name: "Generate allure report"
if: always() && env.NETWORK != 'devnet'
uses: ./.github/actions/generate-allure-report
with:
container: ${{env.DOCKER_PROJECT_NAME}}-tests-1
network: docker_net
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
tests_name: evm
- name: Stop and remove containers
env:
NEON_TESTS_IMAGE: ${{ env.IMAGE }}:${{ needs.dockerize.outputs.tag }}
EVM_LOADER_IMAGE: ${{ github.repository_owner }}/evm_loader:${{ steps.share.outputs.evm_tag }}
if: always() && env.NETWORK != 'devnet'
run: |
docker-compose -p ${{env.DOCKER_PROJECT_NAME}} -f docker-compose-ci.yml down
- name: Cancel the build if job failed
if: failure()
uses: "andymckay/cancel-action@0.4"
run-proxy-tests:
name: Run basic tests
needs:
- dockerize
- prepare-env-proxy
runs-on: ["self-hosted", "k8s-prod"]
env:
SOLANA_IP: ${{ needs.prepare-env-proxy.outputs.solana_ip }}
PROXY_IP: ${{ needs.prepare-env-proxy.outputs.proxy_ip }}
NETWORK: ${{ needs.prepare-env-proxy.outputs.network }}
CONTAINER: basic-tests-${{ github.run_id }}
if: |
always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
outputs:
test-group: ${{ steps.step_fail.outputs.FAILED_TEST_GROUP }}
steps:
- uses: actions/checkout@v4
- name: Run docker container
run: |
docker pull ${{ env.IMAGE }}:${{ needs.dockerize.outputs.tag }}
docker run -i -d -e CI -e GITHUB_RUN_ID -e GITHUB_WORKFLOW \
-e ETH_BANK_PRIVATE_KEY_MAINNET=${{ secrets.ETH_BANK_PRIVATE_KEY_MAINNET }} \
-e BANK_PRIVATE_KEY_MAINNET=${{ secrets.BANK_PRIVATE_KEY_MAINNET }} \
-e BANK_PRIVATE_KEY=${{ secrets.BANK_PRIVATE_KEY }} \
-e DEVNET_SOLANA_URL \
-e SOLANA_IP -e PROXY_IP \
--name=${{ env.CONTAINER }} ${{ env.IMAGE }}:${{ needs.dockerize.outputs.tag }} /bin/bash
- name: Run basic proxy tests
timeout-minutes: 60
run: |
if [ "${{ github.event.schedule }}" == "0 1 * * 0,1,2,3,4" ]; then
CMD="python3 ./clickfile.py run basic_extended --network ${{ env.NETWORK }} --numprocesses ${{ env.NUMPROCESSES }} --case \"${{ github.event.inputs.pytest_k}}\" --marker \"${{ github.event.inputs.pytest_m}}\""
else
CMD="python3 ./clickfile.py run basic --network ${{ env.NETWORK }} --numprocesses ${{ env.NUMPROCESSES }} --case \"${{ github.event.inputs.pytest_k}}\" --marker \"${{ github.event.inputs.pytest_m}}\""
fi
if [[ "${{ env.GENERATE_COST_REPORT }}" == "true" ]]; then
CMD="$CMD --cost_reports_dir reports/cost_reports"
fi
docker exec -i ${{ env.CONTAINER }} /bin/bash -c "export DEVNET_FAUCET_URL=${{ env.FAUCET_URL }} && $CMD"
- name: Set failed test group to basic
if: failure()
id: step_fail
run: echo "FAILED_TEST_GROUP=basic" >> $GITHUB_OUTPUT
- name: Copy cost reports from container
if: ${{ env.GENERATE_COST_REPORT == 'true' }}
run: |
mkdir -p ./reports/cost_reports/ && \
docker cp ${{ env.CONTAINER }}:/opt/neon-tests/reports/cost_reports/. ./reports/cost_reports/
- name: Upload cost reports as artifacts
if: ${{ env.GENERATE_COST_REPORT == 'true' }}
uses: actions/upload-artifact@v4
with:
name: cost-reports
path: reports/cost_reports/**.json
- name: Save Cost Reports to cost_reports.md and echo to Summary
if: ${{ env.GENERATE_COST_REPORT == 'true' }}
run: |
docker exec -i -e NETWORK=${{ env.NETWORK }} ${{ env.CONTAINER }} \
python3 ./clickfile.py dapps save_dapps_cost_report_to_md \
--directory reports/cost_reports && \
docker exec -i ${{ env.CONTAINER }} cat cost_reports.md >> $GITHUB_STEP_SUMMARY
- name: "Generate allure report"
if: always()
uses: ./.github/actions/generate-allure-report
with:
container: ${{ env.CONTAINER }}
network: ${{ env.NETWORK }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
tests_name: basic
- name: Remove docker container
if: always()
run: docker rm -f ${{ env.CONTAINER }}
destroy:
name: Destroy stand
runs-on: ["self-hosted", "k8s-prod"]
needs: [ prepare-env-proxy, run-proxy-tests]
if: always() && needs.prepare-env-proxy.outputs.network == 'terraform'
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
- uses: actions/setup-node@v4
with:
node-version: 16
- name: "Destroy stand"
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_DEFAULT_REGION: ${{secrets.AWS_DEFAULT_REGION}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
HCLOUD_TOKEN: ${{secrets.HCLOUD_TOKEN}}
TFSTATE_BUCKET: ${{vars.TFSTATE_BUCKET}}
TFSTATE_KEY: ${{vars.TFSTATE_KEY_PREFIX}}-${{ github.run_number }}
TFSTATE_REGION: ${{vars.TFSTATE_REGION}}
PROXY_IP: ${{ needs.prepare-env-proxy.outputs.proxy_ip }}
SOLANA_IP: ${{ needs.prepare-env-proxy.outputs.solana_ip }}
uses: ./.github/actions/destroy-tf-stand
with:
ci_stands_key_hcloud: ${{ secrets.CI_STANDS_KEY_HCLOUD }}
send-notification:
name: Send notification on failure
if: failure() && github.ref_name == 'develop'
needs:
- run-proxy-tests
- run-evm-tests
runs-on: ["self-hosted", "k8s-prod"]
steps:
- uses: actions/checkout@v4
- name: Install python requirements
id: requirements
uses: ./.github/actions/python-requirements
- name: Notify on failure
run: |
proxy_tests="${{ needs.run-proxy-tests.outputs.test-group }}"
evm_tests="${{ needs.run-evm-tests.outputs.test-group }}"
FAILED_TEST_GROUP="${proxy_tests:-evm_tests}"
python3 ./clickfile.py send-notification -u ${{ secrets.SLACK_QA_CHANNEL_URL }} \
-b ${{ env.BUILD_URL }} --network ${{ env.NETWORK }} --test-group $FAILED_TEST_GROUP