forked from OffchainLabs/arbitrum-token-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (177 loc) · 6.06 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
name: Build, Test
on:
pull_request:
branches: ["master"]
push:
branches: ["master"]
workflow_dispatch:
env:
NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
check-files:
name: Check files
outputs:
run_tests: ${{ steps.check-files.outputs.run_tests }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
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 != yarn.lock ]]; then
echo "run_tests=false" >> $GITHUB_OUTPUT
else
echo "run_tests=true" >> $GITHUB_OUTPUT
break
fi
done
shell: bash
install:
name: "Install"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main
build:
name: "Build"
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Restore node_modules
uses: OffchainLabs/actions/node-modules/restore@main
- name: Build
run: yarn build
- 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@v3
- name: Restore node_modules
uses: OffchainLabs/actions/node-modules/restore@main
- name: Restore build artifacts
uses: ./.github/actions/build-artifacts/restore
- name: Start UI and Test
run: yarn start-server-and-test 'dev' http://localhost:3000 'yarn test:ci'
audit:
name: "Audit"
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Restore node_modules
uses: OffchainLabs/actions/node-modules/restore@main
- name: Run audit
run: yarn audit:ci
check-formatting:
name: "Check Formatting"
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Restore node_modules
uses: OffchainLabs/actions/node-modules/restore@main
- name: Check formatting with Prettier
run: yarn prettier:check
test-e2e:
name: "Test E2E"
runs-on: ubuntu-latest
needs: [install, check-files]
if: needs.check-files.outputs.run_tests == 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Chown workspace
run: chown -R $(whoami) .
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # pin@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f03ac48505955848960e80bbb68046aa35c7b9e7 # pin@v1
- name: Cache Docker layers
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # pin@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-
- name: Make .e2e.env
uses: SpicyPizza/[email protected]
with:
envkey_PRIVATE_KEY_CUSTOM: ${{ secrets.E2E_PRIVATE_KEY }}
envkey_PRIVATE_KEY_USER: ${{ secrets.E2E_PRIVATE_KEY_USER }}
envkey_NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
envkey_SKIP_METAMASK_SETUP: true
envkey_NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL: http://geth:8545
envkey_NEXT_PUBLIC_LOCAL_ARBITRUM_RPC_URL: http://sequencer:8547
directory: ./packages/arb-token-bridge-ui/
file_name: .e2e.env
- name: Make .env
uses: SpicyPizza/[email protected]
with:
envkey_NEXT_PUBLIC_IS_E2E_TEST: true
envkey_NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
directory: ./packages/arb-token-bridge-ui/
file_name: .env
- name: Make synpress .env
uses: SpicyPizza/[email protected]
with:
envkey_CYPRESS_GROUP: medium-resolution
envkey_DISPLAY_HEIGHT: 768
envkey_DISPLAY_WIDTH: 1366
envkey_SE_SCREEN_HEIGHT: 768
envkey_SE_SCREEN_WIDTH: 1366
file_name: medium-res.env
- name: Set up the local node
uses: OffchainLabs/actions/run-nitro-test-node@main
- name: Restore node_modules
uses: OffchainLabs/actions/node-modules/restore@main
- name: Run e2e tests
run: |
docker-compose -f docker-compose.ci.yml --env-file medium-res.env up --build --exit-code-from synpress
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
DOCKER_DEFAULT_PLATFORM: linux/amd64
- name: Archive e2e artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # pin@v2
if: failure() || success()
with:
name: e2e-artifacts-docker
path: |
docker/videos
docker/videos-ci
docker/screenshots
continue-on-error: false
clean-up:
name: "Clean Up"
runs-on: ubuntu-latest
needs: [test-ui, test-e2e]
if: always()
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install gh-actions-cache
run: gh extension install actions/gh-actions-cache
- name: Delete build artifacts
run: gh actions-cache delete build-artifacts-${{ github.run_id }}-${{ github.run_attempt }} --confirm