-
Notifications
You must be signed in to change notification settings - Fork 203
286 lines (246 loc) · 9.31 KB
/
build-test.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
name: Build, Test
on:
pull_request:
branches: ["master"]
types:
- opened
- edited
- synchronize
push:
branches: ["master"]
workflow_dispatch:
merge_group:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
# github.workflow: name of the workflow
# github.event.pull_request.number || github.ref: pull request number or branch name if not a pull request
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID }}
THE_GRAPH_NETWORK_API_KEY: ${{ secrets.THE_GRAPH_NETWORK_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IS_HOTFIX: ${{ contains(github.event.pull_request.title, 'hotfix') }}
jobs:
check-is-hotfix:
name: Check if PR is hotfix
runs-on: ubuntu-latest
outputs:
is_hotfix: ${{ steps.check-is-hotfix.outputs.is_hotfix }}
steps:
- name: Make IS_HOTFIX env var global
id: check-is-hotfix
run: |
echo "is_hotfix=${{ env.IS_HOTFIX }}" >> $GITHUB_OUTPUT
check-files:
name: Check files
outputs:
run_tests: ${{ steps.check-files.outputs.run_tests }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
# run tests only if specific files are changed
- name: Check modified files
id: check-files
run: |
echo "=============== list modified files ==============="
files=`git diff --name-only HEAD^ HEAD`
echo "$files"
for file in $files; do
if [[ $file != packages/* ]] && ! [[ $file =~ .*\.(lock|yml)$ ]]; then
# if not in packages/ and does not end with .lock or .yml
echo "run_tests=false" >> $GITHUB_OUTPUT
elif [[ $file == .github/ISSUE_TEMPLATE/* ]]; then
echo "run_tests=false" >> $GITHUB_OUTPUT
elif [[ $file =~ .*\.(md|svg|png|webp|gif|txt)$ ]]; then
echo "run_tests=false" >> $GITHUB_OUTPUT
else
echo "run_tests=true" >> $GITHUB_OUTPUT
break
fi
done
shell: bash
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
- name: Build
run: yarn build
env:
NEXT_PUBLIC_IS_E2E_TEST: true
NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID }}
THE_GRAPH_NETWORK_API_KEY: ${{ secrets.THE_GRAPH_NETWORK_API_KEY }}
- name: Cache build artifacts
uses: ./.github/actions/build-artifacts/cache
test-ui:
name: "Test UI"
runs-on: ubuntu-latest
needs: [build, check-files]
if: needs.check-files.outputs.run_tests == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
- name: Restore build artifacts
uses: ./.github/actions/build-artifacts/restore
- name: Start UI and Test
run: yarn start-server-and-test 'start' http://127.0.0.1:3000 'yarn test:ci'
audit:
name: "Audit"
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
- name: Run audit
run: yarn audit:ci
check-formatting:
name: "Check Formatting"
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
- name: Check formatting with Prettier
run: yarn prettier:check
- name: Check formatting with ESLint
run: yarn lint
load-e2e-files:
name: "Load e2e files"
runs-on: ubuntu-latest
needs: [check-is-hotfix]
if: needs.check-is-hotfix.outputs.is_hotfix == 'false'
outputs:
matrix: ${{ steps.set-matrix.outputs.e2eFiles }}
steps:
- name: Checkout
uses: actions/checkout@v4
- id: set-matrix
run: echo "e2eFiles=$(node .github/workflows/formatSpecfiles.js | jq . --compact-output)" >> $GITHUB_OUTPUT
test-e2e:
name: "Test E2E ${{ (matrix.test.type == 'cctp' && 'CCTP') || (matrix.test.orbitTest == '1' && 'with L3') || '' }} - ${{ matrix.test.name }}"
runs-on: ubuntu-latest
needs: [build, check-files, check-is-hotfix, load-e2e-files]
if: needs.check-files.outputs.run_tests == 'true' && needs.check-is-hotfix.outputs.is_hotfix == 'false'
strategy:
fail-fast: false # If one test fails, let the other tests run
matrix:
test: ${{ fromJson(needs.load-e2e-files.outputs.matrix) }}
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: false
swap-storage: true
- name: Checkout
uses: actions/checkout@v4
- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
- name: Restore build artifacts
uses: ./.github/actions/build-artifacts/restore
- name: Install cypress
run: yarn cypress install
- name: Install linux dependencies
run: |
sudo apt-get install --no-install-recommends -y \
fluxbox \
xvfb
- name: Run xvfb and fluxbox
run: |
Xvfb :0 -screen 0 1366x768x24 -listen tcp -ac &
fluxbox &
env:
DISPLAY: :0.0
- name: Run nitro testnode
if: matrix.test.type == 'regular'
uses: OffchainLabs/actions/run-nitro-test-node@a20a76172ce524832ac897bef2fa10a62ed81c29
with:
nitro-testnode-ref: aab133aceadec2e622f15fa438f6327e3165392d
l3-node: ${{ matrix.test.orbitTest == '1' }}
no-l3-token-bridge: ${{ matrix.test.orbitTest == '0' }}
- name: Run e2e tests via cypress-io/github-action
uses: cypress-io/github-action@8d3918616d8ac34caa2b49afc8b408b6a872a6f5 # [email protected]
with:
start: yarn start
command: "yarn test:e2e${{ (matrix.test.type == 'cctp' && ':cctp') || (matrix.test.orbitTest == '1' && ':orbit') || '' }} --browser chromium"
wait-on: http://127.0.0.1:3000
wait-on-timeout: 120
spec: ./packages/arb-token-bridge-ui/tests/e2e/specs/*
env:
DISPLAY: :0.0
TEST_FILE: ${{ matrix.test.file }}
SKIP_METAMASK_SETUP: true
CYPRESS_RECORD_VIDEO: ${{ matrix.test.recordVideo }}
PRIVATE_KEY_CUSTOM: ${{ secrets.E2E_PRIVATE_KEY }}
PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }}
PRIVATE_KEY_CCTP: ${{ secrets.E2E_PRIVATE_KEY_CCTP }}
NEXT_PUBLIC_IS_E2E_TEST: true
NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://127.0.0.1:8545
NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://127.0.0.1:8547
NEXT_PUBLIC_LOCAL_L3_RPC_URL: http://127.0.0.1:3347
- name: Archive e2e artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-artifacts-pull-request-${{ github.event.pull_request.number }}-commit-${{ github.sha }}-${{ matrix.test.name }}-${{ matrix.test.type }}-${{ matrix.test.orbitTest }}
path: |
./packages/arb-token-bridge-ui/cypress/videos
./packages/arb-token-bridge-ui/cypress/screenshots
if-no-files-found: 'ignore'
continue-on-error: true
- name: Throw error if tests failed
if: steps.e2e-run.outputs.status == 'failed'
run: exit 1
test-e2e-success:
name: "Test E2E Success"
runs-on: ubuntu-latest
needs: [test-e2e]
if: always()
steps:
- name: E2E Succeeded
if: needs.test-e2e.result == 'success' || needs.test-e2e.result == 'skipped'
run: echo "nice"
- name: E2E Failed
if: needs.test-e2e.result != 'success' && needs.test-e2e.result != 'skipped'
run: exit 1
clean-up:
name: "Clean Up"
runs-on: ubuntu-latest
needs: [test-ui]
if: always()
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install gh-actions-cache
run: gh extension install actions/gh-actions-cache
- name: Delete build artifacts
run: |
if gh actions-cache list | grep build-artifacts-${{ github.run_id }}-${{ github.run_attempt }}
then
gh actions-cache delete build-artifacts-${{ github.run_id }}-${{ github.run_attempt }} --confirm
fi
shell: bash