-
Notifications
You must be signed in to change notification settings - Fork 45
319 lines (284 loc) · 12.3 KB
/
reusable-e2e-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
name: Reusable e2e tests workflow
on:
workflow_dispatch:
inputs:
e2eBranch:
description: "Name of the e2e target branch"
type: string
required: false
default: "main"
parachainDocker:
description: "Name of the parachain docker reference"
type: string
required: false
default: "mangatasolutions/mangata-node:latest"
skipBuild:
description: "Skip build phase"
type: string
required: false
default: 'false'
globalVersion:
description: "Set Mangata node version."
type: string
required: true
mangataTypesVersion:
description: "Set @mangata-finance/types version"
type: string
default: ""
required: false
workflow_call:
inputs:
e2eBranch:
description: "Name of the e2e target branch"
type: string
required: false
default: "main"
parachainDocker:
description: "Name of the parachain docker reference"
type: string
required: false
default: "mangatasolutions/mangata-node:latest"
skipBuild:
description: "Skip build phase"
type: string
required: false
default: 'false'
globalVersion:
description: "Set Mangata node version."
type: string
required: true
permissions:
contents: write
id-token: write
deployments: write
checks: write
jobs:
setup-report:
runs-on: [ubuntu-latest]
outputs:
testmo-run-id: ${{ steps.setTestRun.outputs.testmo-run-id }}
steps:
- name: Install testmo
run: npm install --no-save @testmo/testmo-cli
- name: Add url
run: |
npx testmo automation:resources:add-field --name git --type string \
--value ${GITHUB_SHA:0:7} --resources resources.json
RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
npx testmo automation:resources:add-link --name build \
--url $RUN_URL --resources resources.json
- name: Create test run
run: |
npx testmo automation:run:create \
--instance https://mangata-finance.testmo.net \
--project-id 2 \
--name "BE tests from node-repo" \
--resources resources.json \
--source "BE-e2e-regression" > testmo-run-id.txt
ID=$(cat testmo-run-id.txt)
echo "testmo-run-id=$ID" >> $GITHUB_OUTPUT
echo "ID=$ID" >> $GITHUB_ENV
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
id: setTestRun
e2e-test-matrix:
needs: [setup-report]
strategy:
fail-fast: false
matrix:
include:
- command: "yarn test-parallel --max-workers=10"
fast: false
- command: "yarn test-sequential-no-bootstrap"
fast: false
- command: "yarn test-seqgasless"
fast: false
- command: "yarn test-maintenance"
fast: true
- command: "yarn test-bootstrap"
fast: false
- command: "yarn test-rewards-bootstrap"
fast: false
- command: "yarn test-parallel-autocompound"
fast: true
- command: "yarn test-sequential-autocompound"
fast: true
- command: "yarn test-poolliquidity"
fast: true
- command: "yarn test-governance"
fast: true
- command: "yarn test-multiswap"
fast: false
- command: "yarn test-experimentalStaking"
fast: true
- command: "yarn test-crowdloan"
fast: false
- command: "yarn test-sdk"
fast: true
runs-on: [e2e-gke]
timeout-minutes: 180
env:
API_URL: "ws://127.0.0.1:9946"
TEST_PALLET_ADDRESS: ${{ secrets.E2E_TEST_PALLET_ADDRESS }}
E2E_TREASURY_PALLET_ADDRESS: ${{ secrets.E2E_TREASURY_PALLET_ADDRESS }}
E2E_XYK_PALLET_ADDRESS: ${{ secrets.E2E_XYK_PALLET_ADDRESS }}
E2E_TREASURY_BURN_PALLET_ADDRESS: ${{ secrets.E2E_TREASURY_BURN_PALLET_ADDRESS }}
TEST_SUDO_NAME: "//Alice"
MANGATA_NODE_VERSION: ${{ inputs.globalVersion }}
E2EBRANCHNAME: "main"
PARACHAIN_DOCKER_IMAGE: ${{ inputs.parachainDocker || format('mangatasolutions/mangata-node:{0}', inputs.globalVersion) }}
steps:
- uses: actions/checkout@v4
- name: Adapt if fast runtime
if: ${{ !contains(env.PARACHAIN_DOCKER_IMAGE, 'fast') && matrix.fast == true }}
run: echo "PARACHAIN_DOCKER_IMAGE=${{ env.PARACHAIN_DOCKER_IMAGE }}-fast" >> $GITHUB_ENV
- name: Download node Docker image
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-build') && inputs.skipBuild != 'true' }}
run: docker pull ${{ env.PARACHAIN_DOCKER_IMAGE }}
- name: E2E- Get branch name
id: branch-name
uses: tj-actions/[email protected]
- name: Current branch name for generating types
run: |
echo "MANGATA_TYPES_VERSION=${{ steps.branch-name.outputs.current_branch }}" | sed -E 's@[/\.]@-@g' >> $GITHUB_ENV
- name: E2E- Calculate if run e2e feature branch or main.
run: |
echo DEFAULT: E2E test will run with: $E2EBRANCHNAME
echo "Running on: ${{ steps.branch-name.outputs.current_branch }}"
if [ -n "$(git ls-remote --heads https://github.com/mangata-finance/mangata-e2e.git ${{ steps.branch-name.outputs.current_branch }} --force --quiet)" ]; then echo "E2EBRANCHNAME=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV; echo "MATCH - OK" ; elif [ -n "$(git ls-remote --heads https://github.com/mangata-finance/mangata-e2e.git ${{ github.base_ref }} --force --quiet)" ]; then echo "E2EBRANCHNAME=${{ github.base_ref }}" >> $GITHUB_ENV; echo "MATCH - OK" ; fi
- name: Decide if main - branch or parameter
# if we have something in e2eBranch - override E2EBranchName, else -> E2EBRANCHNAME , that
# by default will be main.
run: echo "E2EBRANCHNAME=${{ inputs.e2eBranch || env.E2EBRANCHNAME }}" >> $GITHUB_ENV
- name: Checkout tests
uses: actions/checkout@v4
with:
repository: mangata-finance/mangata-e2e
ref: "${{ env.E2EBRANCHNAME }}"
path: e2eTests
- uses: actions/setup-node@v3
with:
node-version: '18.18.2'
- name: Replace parachain docker image reference in config
working-directory: devops/parachain-launch
run: sed -i 's+mangatasolutions/mangata-node:.*+${{ env.PARACHAIN_DOCKER_IMAGE }}+g' config.yml
- name: Install e2e tests dependencies
working-directory: e2eTests
run: yarn install
- name: Install @mangata-finance/types deps
run: |
if [[ -n "${{ github.event.inputs.mangataTypesVersion }}" ]]; then
yarn add @mangata-finance/types@${{ github.event.inputs.mangataTypesVersion }}
else
yarn add @mangata-finance/types@${{ env.MANGATA_TYPES_VERSION }}
fi
- name: Run parachain launch
working-directory: devops/parachain-launch
run: npx @open-web3/parachain-launch generate config.yml
- name: Remove obsolete node run args from generated docker-compose.yml
working-directory: devops/parachain-launch/output
run: sed -i '/ws-external/d' docker-compose.yml
- run: docker ps --no-trunc
- name: Start mangata-node parachain
working-directory: devops/parachain-launch/output
run: docker-compose up -d --build
- run: docker ps --no-trunc
- name: Sleep for 2 minutes
run: sleep 120s
- name: Run tests
working-directory: e2eTests
run: ${{ matrix.command }}
env:
NODE_OPTIONS: --max_old_space_size=12288
- name: Test Report
uses: dorny/[email protected]
continue-on-error: true
if: success() || failure() # run this step even if previous step failed
with:
name: E2E report ${{ matrix.command }} # Name of the check run which will be created
path: e2eTests/reports/*.xml # Path to test results
reporter: jest-junit # Format of test results
- name: Submit results to the testmo-run
continue-on-error: true
if: always()
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
run: |
npm install --no-save @testmo/testmo-cli
npx testmo automation:run:submit-thread \
--instance https://mangata-finance.testmo.net \
--run-id ${{needs.setup-report.outputs.testmo-run-id}} \
--results e2eTests/reports/*.xml
- name: collect_docker_logs
if: failure()
uses: jwalton/[email protected]
with:
dest: "./logs"
- name: Prepare backup snapshots on workflow failure
if: failure()
env:
OUTPUT_DIR: devops/parachain-launch/output
run: |
# Set MATRIX_COMMAND_PATH to be used as a directory name to store specifc test run snapshots
echo "MATRIX_COMMAND_PATH=$(echo ${{ matrix.command }} | sed 's/[^a-zA-Z0-9]/-/g')" >> $GITHUB_ENV
# Archive logs
tar cvzf ${OUTPUT_DIR}/logs.tgz ./logs
# Generate image snapshots
docker commit $(docker ps | grep parachain-2110-0 | awk '{print $1}') mangata_test_run/mangata_alice_1
docker save --output=${OUTPUT_DIR}/mangata_alice_1.tar mangata_test_run/mangata_alice_1
docker commit $(docker ps | grep parachain-2110-1 | awk '{print $1}') mangata_test_run/mangata_bob_1
docker save --output=${OUTPUT_DIR}/mangata_bob_1.tar mangata_test_run/mangata_bob_1
# Generate volume snapshots
docker run -v output_parachain-2110-0:/volume --rm --log-driver none loomchild/volume-backup backup > ${OUTPUT_DIR}/mangata_alice_1_volume.tar.bz2
docker run -v output_parachain-2110-1:/volume --rm --log-driver none loomchild/volume-backup backup > ${OUTPUT_DIR}/mangata_bob_1_volume.tar.bz2
- uses: google-github-actions/auth@v1
if: failure()
with:
workload_identity_provider: '${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}'
service_account: '${{ secrets.GCP_SERVICE_ACCOUNT }}'
- name: Upload node storage data to GCP bucket
if: failure()
uses: google-github-actions/[email protected]
with:
process_gcloudignore: false
path: devops/parachain-launch/output
destination: mangata-node-ci-cache/${{ github.sha }}/${{ env.MATRIX_COMMAND_PATH }}
- name: Add GCP bucket URL link for stored node data on job failure
if: failure()
run: echo '[GCP Bucket link](https://console.cloud.google.com/storage/browser/mangata-node-ci-cache/${{ github.sha }}/${{ env.MATRIX_COMMAND_PATH }})' >> $GITHUB_STEP_SUMMARY
- name: Stop previous parachain if running
working-directory: devops/parachain-launch/output
run: |
docker kill $(docker ps -q) 2>/dev/null && echo $?
docker-compose down -v
test-complete:
needs: [setup-report, e2e-test-matrix]
if: always()
runs-on: ubuntu-latest
steps:
- name: Install testmo
run: npm install --no-save @testmo/testmo-cli
- name: Complete test run
run: |
npx testmo automation:run:complete \
--instance https://mangata-finance.testmo.net \
--run-id ${{needs.setup-report.outputs.testmo-run-id}} \
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
continue-on-error: true
slack-notify-nook:
needs: [e2e-test-matrix]
if: failure()
runs-on: ubuntu-latest
steps:
- name: Slack Notification - Error
uses: bryannice/[email protected]
env:
SLACK_INCOMING_WEBHOOK: ${{ secrets.BNB_E2E_NOTIFICATION_WEBHOOK }}
SLACK_TITLE: 'bnb e2e test execution - NOOK'
SLACK_COLOR: "#ff0011"
SLACK_MESSAGE: 'Test failures [ ${{ env.E2EBRANCHNAME }} - ${{ env.PARACHAIN_DOCKER_IMAGE }} ] testmo report: https://mangata-finance.testmo.net/automation/runs/view/${{needs.setup-report.outputs.testmo-run-id}}'
GITHUB_REF: 'https://mangata-finance.github.io/mangata-node/${{ github.run_number }}'