-
Notifications
You must be signed in to change notification settings - Fork 17
350 lines (297 loc) · 11.2 KB
/
e2e-tests.yaml
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
name: 'e2e test'
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [main]
paths:
- idea/api-gateway/**
- idea/common/**
- idea/indexer/**
- idea/frontend/**
- idea/test-balance/**
- idea/tests/**
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
KUBE_NAMESPACE: test-env
DOCKER_BUILDKIT: 1
REACT_APP_NODE_ADDRESS: ${{ secrets.REACT_APP_NODE_ADDRESS }}
REACT_APP_API_URL: ${{ secrets.REACT_APP_API_URL }}
REACT_APP_WASM_COMPILER_URL: ${{ secrets.REACT_APP_WASM_COMPILER_URL }}
REACT_APP_DEFAULT_NODES_URL: ${{ secrets.REACT_APP_DEFAULT_NODES_URL }}
REACT_APP_RRT: ''
REACT_APP_HCAPTCHA_SITE_KEY: ${{ secrets.REACT_APP_HCAPTCHA_SITE_KEY }}
NIGHTLY_TOOLCHAIN_VERSION: ${{ vars.NIGHTLY_TOOLCHAIN_VERSION }}
jobs:
build-frontend-pkg:
runs-on: ubuntu-latest
environment: staging
# Declare outputs for next steps
outputs:
frontend_changed: ${{ steps.check_file_changed.outputs.frontend_changed }}
steps:
- uses: actions/checkout@v2
with:
# Checkout as many commits as needed for the diff
fetch-depth: 2
- shell: pwsh
id: check_file_changed
run: |
# Diff HEAD with the previous commit
$diff = git diff --name-only HEAD^ HEAD
# Check if a file under frontend/ has changed (added, modified, deleted)
$SourceDiffFrontend = $diff | Where-Object { $_ -match '^idea/frontend/' }
$HasDiffFrontend = $SourceDiffFrontend.Length -gt 0
# Set the output
Write-Host "::set-output name=frontend_changed::$HasDiffFrontend"
- name: Cancel previous workflow runs
if: steps.check_file_changed.outputs.frontend_changed == 'True'
uses: styfle/cancel-workflow-action@0.4.0
with:
access_token: ${{ github.token }}
- if: steps.check_file_changed.outputs.frontend_changed == 'True'
uses: c-hive/gha-yarn-cache@v2.1.0
- name: Setup NodeJS
if: steps.check_file_changed.outputs.frontend_changed == 'True'
uses: actions/setup-node@v2
with:
node-version: 18
cache: yarn
- name: Install dependencies
if: steps.check_file_changed.outputs.frontend_changed == 'True'
uses: borales/actions-yarn@v3.0.0
with:
cmd: install
- name: Build frontend pkg
if: steps.check_file_changed.outputs.frontend_changed == 'True'
run: sudo yarn build:frontend
wait-previous-run:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Wait previous run
uses: mktcode/consecutive-workflow-action@v1 # please read security note
with:
token: ${{ secrets.GITHUB_TOKEN }}
build-and-push-gear-node-image:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [wait-previous-run]
environment: dev
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the github container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Gear node Docker image
uses: docker/build-push-action@master
with:
file: k8s/gear-node/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-node:dev
# build-and-push-gear-vara-node-image:
# if: github.event.pull_request.draft == false
# runs-on: ubuntu-latest
# needs: [wait-previous-run]
# environment: dev
# permissions:
# contents: read
# packages: write
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2
# - name: Log in to the github container registry
# uses: docker/login-action@master
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Build and push Data Storage Docker image
# uses: docker/build-push-action@master
# with:
# file: k8s/vara-node/Dockerfile
# push: true
# tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-vara-node:dev
build-and-push-indexer-image:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [wait-previous-run]
environment: dev
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the github container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Indexer Docker image
uses: docker/build-push-action@master
with:
file: idea/indexer/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-indexer:dev
build-and-push-api-gateway-image:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [wait-previous-run]
environment: dev
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the github container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Api Gateway Docker image
uses: docker/build-push-action@master
with:
file: idea/api-gateway/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-api-gateway:dev
build-and-push-test-balance-image:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [wait-previous-run]
environment: dev
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the github container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Test Balance Docker image
uses: docker/build-push-action@master
with:
file: idea/test-balance/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-test-balance:dev
purge-k8s-test-env:
if: github.event.pull_request.draft == false
needs:
[
build-and-push-indexer-image,
build-and-push-api-gateway-image,
build-and-push-test-balance-image,
build-and-push-gear-node-image,
wait-previous-run,
]
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Restart RabbitMQ
uses: sergeyfilyanin/kubectl-aws-eks@master
with:
args: rollout restart deployment rabbitmq -n $KUBE_NAMESPACE
- name: Check RabbitMQ
uses: sergeyfilyanin/kubectl-aws-eks@master
with:
args: rollout status deployment rabbitmq -n $KUBE_NAMESPACE --timeout=120s
- name: Deploy to k8s
uses: sergeyfilyanin/kubectl-aws-eks@master
with:
args: rollout restart deployment gear-node api-gateway-testenv frontend-nginx-testenv postgres-testenv postgres-testbalance-testenv -n $KUBE_NAMESPACE
- name: Check k8s deployments
uses: sergeyfilyanin/kubectl-aws-eks@master
with:
args: get deployment -o name -n $KUBE_NAMESPACE | xargs -n1 -t kubectl rollout status -n $KUBE_NAMESPACE --timeout=120s
- name: Deploy to k8s indexer
uses: sergeyfilyanin/kubectl-aws-eks@master
with:
args: rollout restart deployment test-balance-testenv indexer-testenv -n $KUBE_NAMESPACE
- name: Check k8s deployment test-balance-testenv
uses: sergeyfilyanin/kubectl-aws-eks@master
with:
args: rollout status deployment test-balance-testenv -n $KUBE_NAMESPACE --timeout=120s
- name: Check k8s deployment indexer
uses: sergeyfilyanin/kubectl-aws-eks@master
with:
args: rollout status deployment indexer-testenv -n $KUBE_NAMESPACE --timeout=120s
run-e2e-tests:
if: github.event.pull_request.draft == false
needs: [purge-k8s-test-env, wait-previous-run]
runs-on: ubuntu-latest
environment: dev
env:
RUSTUP_HOME: /tmp/rustup_home
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install NodeJS 18.x
uses: actions/setup-node@v2.1.5
with:
node-version: 18.x
- name: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
- name: "Install: Nightly toolchain"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-unknown-unknown
components: llvm-tools-preview
- name: "Install: Show specific nightly version"
if: ${{ env.NIGHTLY_TOOLCHAIN_VERSION != '' }}
run: echo $NIGHTLY_TOOLCHAIN_VERSION | sed 's/-/ - /g'
- name: "Install: Specific nightly toolchain"
if: ${{ env.NIGHTLY_TOOLCHAIN_VERSION != '' }}
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-${{ env.NIGHTLY_TOOLCHAIN_VERSION }}
target: wasm32-unknown-unknown
components: llvm-tools-preview
- name: "Install: Pin to specific nightly toolchain"
if: ${{ env.NIGHTLY_TOOLCHAIN_VERSION != '' }}
run: |
rm -rf $RUSTUP_HOME/toolchains/nightly-x86_64-unknown-linux-gnu
ln -s $RUSTUP_HOME/toolchains/nightly-$NIGHTLY_TOOLCHAIN_VERSION-x86_64-unknown-linux-gnu $RUSTUP_HOME/toolchains/nightly-x86_64-unknown-linux-gnu
- name: Build test programs
working-directory: api/programs
run: cargo build --release
- name: Copy built programs
run: |
cp api/programs/target/wasm32-unknown-unknown/release/test_meta* idea/tests/wasm-test
cp api/programs/test-meta/test_meta.meta.txt idea/tests/wasm-test/meta.txt
- name: Prepare&Run Tests
timeout-minutes: 7
working-directory: idea/tests
env:
API_ENDPOINT: ${{ secrets.API_ADDRESS_URL_TEST }}
WS_PROVIDER: ${{ secrets.WS_PROVIDER_URL_TEST }}
WS_PROVIDER_VARA: ${{ secrets.WS_PROVIDER_VARA_URL_TEST }}
TEST_ENV: ${{ secrets.TEST_ENV }}
run: yarn test