-
Notifications
You must be signed in to change notification settings - Fork 45
318 lines (278 loc) · 11.4 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
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
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
runs-on: [self-hosted, compile]
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@v3 ####IDK, but this is neccesary for reports
- 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: 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: E2E- Get target branch.
run: |
echo "This job name branch is: ${{ steps.branch-name.outputs.current_branch }}"
- 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: E2E- Get target branch.
run: |
echo "${{ env.E2EBRANCHNAME }}"
- name: Checkout tests
uses: actions/checkout@v3
with:
repository: mangata-finance/mangata-e2e
ref: "${{ env.E2EBRANCHNAME }}"
path: e2eTests
- uses: actions/setup-node@v3
with:
node-version: '18.16.1'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
- name: Print parachain docker image reference
run: |
echo ${{ env.PARACHAIN_DOCKER_IMAGE }}
- 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
# TODO: remove cache clean later
run: yarn cache clean; yarn
- name: Run parachain launch
working-directory: devops/parachain-launch
run: npx @open-web3/parachain-launch generate config.yml
- name: Docker ps
run: docker ps --no-trunc
- name: Docker network ls
run: docker network ls
- 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
- name: Start mangata-node parachain
working-directory: devops/parachain-launch/output
run: docker-compose up -d --build
- name: Docker ps
run: docker ps --no-trunc
- name: Sleep for 2 minutes
run: sleep 120s #close buffers of videos.
- name: Run tests
working-directory: e2eTests
run: ${{ matrix.command }}
- 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/junit-*.xml # Path to test results
reporter: jest-junit # Format of test results
- name: Install testmo
if: always()
run: npm install --no-save @testmo/testmo-cli
- name: Submit results to the testmo-run
if: always()
run: |
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
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
continue-on-error: true
- name: Collect docker logs on failure
if: failure()
uses: jwalton/[email protected]
with:
dest: "./logs"
- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./logs
- name: Create images snapshots
if: failure()
run: |
docker commit $(docker ps | grep parachain-2110-1 | awk '{print $1}') mangata_test_run/mangata_bob_1
docker save --output=/tmp/mangata_bob_1.tar mangata_test_run/mangata_bob_1
docker commit $(docker ps | grep parachain-2110-0 | awk '{print $1}') mangata_test_run/mangata_alice_1
docker save --output=/tmp/mangata_alice_1.tar mangata_test_run/mangata_alice_1
- name: Upload logs and docker images to GitHub
if: failure()
uses: actions/[email protected]
with:
name: logsAndImages
path: |
./logs.tgz
/tmp/mangata_bob_1.tar
/tmp/mangata_alice_1.tar
- 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
- name: Fix permissions on self-hosted runner
if: always()
run: chown -R 1100:1100 $GITHUB_WORKSPACE
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 }}'