-
Notifications
You must be signed in to change notification settings - Fork 12
355 lines (309 loc) · 10.7 KB
/
build-binaries.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
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
351
352
353
354
355
name: Build binaries
on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main
permissions:
id-token: write
contents: read
checks: write
env:
WAILS_VERSION: v2.8.0
NODE_VERSION: 18.12.0
GO_VERSION: 1.21.7
jobs:
download-frontend:
name: Download frontend dependencies
runs-on: macos-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
cache-dependency-path: frontend/yarn.lock
- name: Verify if frontend modules are cached
uses: actions/cache@v3
id: cache-frontend-modules
with:
path: frontend/node_modules
key: node-modules-cache-${{ runner.os }}-${{ hashFiles('frontend/yarn.lock') }}
enableCrossOsArchive: true
- name: Install missing frontend dependencies
if: steps.cache-frontend-modules.outputs.cache-hit != 'true'
working-directory: frontend
run: yarn install --frozen-lockfile
- name: Check lint
working-directory: frontend
run: yarn lint:check
- name: Check formatting
working-directory: frontend
run: yarn format:check
# TEMPORARY SOLUTION
# See https://github.com/vegaprotocol/vegawallet-desktop/issues/619
hash-frontend:
needs: download-frontend
name: Hash frontend
runs-on: macos-latest
outputs:
for-mainnet: ${{ steps.for-mainnet.outputs.hash }}
for-fairground: ${{ steps.for-fairground.outputs.hash }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Generate hash for mainnet
id: for-mainnet
run: python3 ./ci/deterministic-hash.py mainnet >> "$GITHUB_OUTPUT"
- name: Generate hash for fairground
id: for-fairground
run: python3 ./ci/deterministic-hash.py fairground >> "$GITHUB_OUTPUT"
build-frontend:
needs: hash-frontend
name: Build frontend
runs-on: macos-latest
strategy:
matrix:
network:
- mainnet
- fairground
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Resolve cache key for compiled frontend
id: cache-key-compiled-frontend
shell: bash
run: |
[[ "${{ matrix.network }}" = 'mainnet' ]] && hash="${{ needs.hash-frontend.outputs.for-mainnet }}" || hash="${{ needs.hash-frontend.outputs.for-fairground }}"
echo "key=frontend-${{ matrix.network }}-$hash" >> "$GITHUB_OUTPUT"
- name: Verify if compiled frontend is cached
uses: actions/cache@v3
id: cache-compiled-frontend
with:
path: frontend/dist
key: ${{ steps.cache-key-compiled-frontend.outputs.key }}
enableCrossOsArchive: true
- name: Set up Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
if: steps.cache-compiled-frontend.outputs.cache-hit != 'true'
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
cache-dependency-path: frontend/yarn.lock
- name: Restore frontend node_modules from cache
uses: actions/cache/restore@v3
if: steps.cache-compiled-frontend.outputs.cache-hit != 'true'
with:
path: frontend/node_modules
key: node-modules-cache-${{ runner.os }}-${{ hashFiles('frontend/yarn.lock') }}
fail-on-cache-miss: true
- name: Build frontend
if: steps.cache-compiled-frontend.outputs.cache-hit != 'true'
working-directory: frontend
env:
VITE_FEATURE_MODE: ${{ matrix.network }}
run: yarn build
download-backend:
name: Download backend dependencies (${{ matrix.os }}, ${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- windows-latest
- ubuntu-latest
arch:
- amd64
- arm64
exclude:
- os: ubuntu-latest
arch: arm64
- os: windows-latest
arch: arm64
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Install missing Golang dependencies
run: go mod download
- name: Locate Wails on Windows
if: ${{ runner.os == 'Windows' }}
shell: bash
run: echo "WAILS_BIN=$(go env GOPATH)\bin\wails.exe" >> $GITHUB_ENV
- name: Locate Wails on Unix
if: ${{ runner.os != 'Windows' }}
shell: bash
run: echo "WAILS_BIN=$(go env GOPATH)/bin/wails" >> $GITHUB_ENV
- name: Verify if Wails is cached
uses: actions/cache@v3
id: cache-wails
with:
path: ${{ env.WAILS_BIN }}
key: wails-cache-${{ runner.os }}-${{ matrix.arch }}-${{ env.WAILS_VERSION }}
- name: Install Wails ${{ env.WAILS_VERSION }}
if: steps.cache-wails.outputs.cache-hit != 'true'
run: go install github.com/wailsapp/wails/v2/cmd/wails@${{ env.WAILS_VERSION }}
build-application:
needs:
- hash-frontend
- build-frontend
- download-backend
name: Build application (${{ matrix.network }}, ${{ matrix.os }}, ${{ matrix.arch }})
runs-on: ${{ matrix.os }}
env:
CGO_ENABLED: 1
strategy:
matrix:
os:
- macos-latest
- windows-latest
- ubuntu-latest
arch:
- amd64
- arm64
network:
- mainnet
- fairground
include:
- os: ubuntu-latest
platform: linux
- os: macos-latest
platform: darwin
- os: windows-latest
platform: windows
exclude:
- os: ubuntu-latest
arch: arm64
- os: windows-latest
arch: arm64
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install Wails dependencies for Linux
if: ${{ runner.os == 'linux' }}
run: |
sudo apt-get update
sudo apt-get install build-essential libgtk-3-dev libwebkit2gtk-4.0-dev
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Locate Wails on Windows
if: ${{ runner.os == 'Windows' }}
shell: bash
run: echo "WAILS_BIN=$(go env GOPATH)\bin\wails.exe" >> $GITHUB_ENV
- name: Locate Wails on Unix
if: ${{ runner.os != 'Windows' }}
shell: bash
run: echo "WAILS_BIN=$(go env GOPATH)/bin/wails" >> $GITHUB_ENV
- name: Restore Wails from cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WAILS_BIN }}
key: wails-cache-${{ runner.os }}-${{ matrix.arch }}-${{ env.WAILS_VERSION }}
fail-on-cache-miss: true
- name: Resolve cache key for compiled frontend
id: cache-key-compiled-frontend
shell: bash
run: |
[[ "${{ matrix.network }}" = 'mainnet' ]] && hash="${{ needs.hash-frontend.outputs.for-mainnet }}" || hash="${{ needs.hash-frontend.outputs.for-fairground }}"
echo "key=frontend-${{ matrix.network }}-$hash" >> "$GITHUB_OUTPUT"
- name: Restore compiled frontend from cache
uses: actions/cache/restore@v3
with:
path: frontend/dist
key: ${{ steps.cache-key-compiled-frontend.outputs.key }}
fail-on-cache-miss: true
enableCrossOsArchive: true
- name: Prepare ${{ matrix.network }} bundle
shell: bash
env:
WALLET_OPTIMIZED_FOR: ${{ matrix.network }}
run: ./prepare.sh
- name: Build binary for ${{ matrix.platform }}
env:
VITE_FEATURE_MODE: ${{ matrix.network }}
# -s to skip building the frontend because it has already been compiled
# in a previous job.
# -skipbindings to skip generating the bindings because it's already
# committed.
# -nosyncgomod Don't sync go.mod
run: wails build -s -skipbindings -nosyncgomod -platform=${{ matrix.platform }}/${{ matrix.arch }} -tags ${{ matrix.network }}
# This is done after the application has been compiled because the backend
# code embed the frontend within itself. Without it, it will raise an error:
#
# pattern frontend/dist: no matching files found
#
- name: Tests backend
if: ${{ matrix.arch == 'amd64' }}
run: go test -tags ${{ matrix.network }} -v ./...
e2e-test:
needs:
- download-frontend
- download-backend
name: Run end-to-end tests
runs-on: macos-latest
strategy:
matrix:
mode:
- dev
- mainnet
- fairground
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Locate Wails on macOS
shell: bash
run: echo "WAILS_BIN=$(go env GOPATH)/bin/wails" >> $GITHUB_ENV
- name: Restore Wails from cache
uses: actions/cache/restore@v3
with:
path: ${{ env.WAILS_BIN }}
key: wails-cache-${{ runner.os }}-amd64-${{ env.WAILS_VERSION }}
fail-on-cache-miss: true
- name: Set up Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
cache-dependency-path: frontend/yarn.lock
- name: Restore frontend node_modules from cache
uses: actions/cache/restore@v3
with:
path: frontend/node_modules
key: node-modules-cache-${{ runner.os }}-${{ hashFiles('frontend/yarn.lock') }}
fail-on-cache-miss: true
- name: Setup Playwright browsers
working-directory: frontend
run: yarn playwright install --with-deps chromium
- name: Run e2e tests - ${{ matrix.mode }} mode
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: frontend
run: yarn e2e:run:${{ matrix.mode }}
- name: Show test summary
if: success() || failure()
uses: dorny/test-reporter@v1
with:
name: UI Tests - ${{ matrix.mode }}
path: frontend/automation/test-results/junit-report/report.xml
reporter: java-junit
- name: Store test report
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.mode }}
path: frontend/automation/test-results