-
Notifications
You must be signed in to change notification settings - Fork 17
343 lines (289 loc) · 10.7 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
name: 'Gear Idea: e2e test'
on:
pull_request:
types: [synchronize, labeled, opened, reopened, ready_for_review]
branches: [main]
paths:
- idea/api-gateway/**
- idea/common/**
- idea/indexer/**
- idea/frontend/**
- idea/test-balance/**
- idea/tests/**
- idea/meta-storage/**
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 }}
BINARYEN_VERSION: version_111
jobs:
check-labels:
if: contains(github.event.pull_request.labels.*.name, 'A2-mergeoncegreen')
runs-on: ubuntu-latest
steps:
- run: echo "Condition passed"
build-frontend-pkg:
runs-on: ubuntu-latest
needs: [check-labels]
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/[email protected]
with:
access_token: ${{ github.token }}
- if: steps.check_file_changed.outputs.frontend_changed == 'True'
uses: c-hive/[email protected]
- 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/[email protected]
with:
cmd: install
- name: Install additional dependencies rollup-linux-x64-gnu
if: steps.check_file_changed.outputs.frontend_changed == 'True'
run : sudo yarn add @rollup/rollup-linux-x64-gnu
- name: Build frontend pkg
if: steps.check_file_changed.outputs.frontend_changed == 'True'
run: sudo yarn build:frontend
build-and-push-gear-node-image:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [check-labels]
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-indexer-image:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [check-labels]
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: [check-labels]
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-meta-storage-image:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [check-labels]
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 Meta Storage Docker image
uses: docker/build-push-action@master
with:
file: idea/meta-storage/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-meta-storage:dev
build-and-push-test-balance-image:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [check-labels]
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-meta-storage-image,
build-and-push-test-balance-image,
build-and-push-gear-node-image
]
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 postgres-meta-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 meta-storage -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
- name: Check k8s deployment meta-storage
uses: sergeyfilyanin/kubectl-aws-eks@master
with:
args: rollout status deployment meta-storage -n $KUBE_NAMESPACE --timeout=120s
run-e2e-tests:
if: github.event.pull_request.draft == false
needs: [purge-k8s-test-env]
runs-on: ubuntu-latest
environment: dev
env:
RUSTUP_HOME: /tmp/rustup_home
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install NodeJS 20.x
uses: actions/[email protected]
with:
node-version: 20.x
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: "Prepare: Build test programs"
working-directory: api/programs
run: cargo build --release
- name: "Prepare: Copy built programs"
run: cp api/programs/target/wasm32-unknown-unknown/release/* idea/tests/wasm-test
- name: "Prepare: Build test programs"
working-directory: idea/tests/programs
run: cargo build --release
- name: "Install dependencies"
run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
- name: "Build: @gear-js/common"
run: yarn build:common
- name: "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