-
Notifications
You must be signed in to change notification settings - Fork 345
414 lines (385 loc) · 16.3 KB
/
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
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
name: "@Libraries • Tests"
run-name: "@Libraries • Tests triggered by ${{ github.event_name == 'workflow_dispatch' && inputs.login || github.actor }} ${{ format('on ref {0}', github.ref_name) }}"
on:
push:
branches:
- main
- develop
- release
- hotfix
workflow_dispatch:
inputs:
since_branch:
description: The branch that turborepo will check when diffing.
default: "develop"
ref:
description: the branch which triggered this workflow
required: false
login:
description: The GitHub username that triggered the workflow
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name != 'develop' && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
test-docs:
name: "Test Docs"
runs-on: ubuntu-latest
outputs:
fail: ${{ steps.diff.outputs.diff }}
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ (github.event_name == 'workflow_dispatch' && (inputs.ref || github.ref_name)) || github.sha }}
base: ${{ inputs.since_branch }}
- name: Setup the toolchain
uses: ./tools/actions/composites/setup-toolchain
- name: Install dependencies
run: pnpm i --filter="!./apps/**"
- name: run doc
run: pnpm doc:ljs
- name: get diff
id: diff
run: |
diff=$(git diff --exit-code > /dev/null && echo 0 || echo 1)
echo "diff=$diff" >> $GITHUB_OUTPUT
exit $diff
test-common-tools:
name: "Test common-tools"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
runs-on: ubuntu-latest
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ (github.event_name == 'workflow_dispatch' && (inputs.ref || github.ref_name)) || github.sha }}
base: ${{ inputs.since_branch }}
- name: Setup the toolchain
uses: ./tools/actions/composites/setup-toolchain
- name: TurboRepo local caching server
id: turborepo-cache-server
uses: ./tools/actions/turborepo-s3-cache
with:
server-token: "yolo"
cleanup-cache-folder: "true"
aws-access-key: ${{ secrets.AWS_S3_CACHE_ACCESS_KEY }}
aws-secret-key: ${{ secrets.AWS_S3_CACHE_SECRET_KEY }}
- name: Install dependencies
run: pnpm i -F "live-common-tools..." -F "ledger-live"
- name: build common-tools
run: pnpm turbo run build --filter="live-common-tools"
test-cli:
name: "Test CLI"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
outputs:
fail: ${{ steps.diff.outputs.diff }}
test-fail: ${{ steps.test.outcome }}
runs-on: ubuntu-latest
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ (github.event_name == 'workflow_dispatch' && (inputs.ref || github.ref_name)) || github.sha }}
base: ${{ inputs.since_branch }}
- name: Setup the toolchain
uses: ./tools/actions/composites/setup-toolchain
- name: TurboRepo local caching server
id: turborepo-cache-server
uses: ./tools/actions/turborepo-s3-cache
with:
server-token: "yolo"
cleanup-cache-folder: "true"
aws-access-key: ${{ secrets.AWS_S3_CACHE_ACCESS_KEY }}
aws-secret-key: ${{ secrets.AWS_S3_CACHE_SECRET_KEY }}
- name: Install dependencies
run: pnpm i -F "live-cli..." -F "ledger-live"
- name: build cli
run: pnpm build:cli
- name: lint cli
run: pnpm lint --filter="live-cli" -- --quiet
- name: typecheck cli
run: pnpm typecheck --filter="live-cli"
- name: test cli
id: test
run: pnpm run test --filter="live-cli"
- name: get diff
id: diff
run: |
diff=$(git diff --exit-code > /dev/null && echo 0 || echo 1)
echo "diff=$diff" >> $GITHUB_OUTPUT
exit $diff
test-libraries:
name: "Test Libraries"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
CI_OS: ubuntu-latest
runs-on: [ledger-live-4xlarge-linux]
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ (github.event_name == 'workflow_dispatch' && (inputs.ref || github.ref_name)) || github.sha }}
base: ${{ inputs.since_branch }}
fetch-depth: 0
- name: Setup the toolchain
uses: ./tools/actions/composites/setup-toolchain
# - uses: actions/setup-python@v4
# with:
# python-version: "3.10"
# - uses: ruby/setup-ruby@v1
# with:
# ruby-version: 2.6
- name: TurboRepo local caching server
id: turborepo-cache-server
uses: ./tools/actions/turborepo-s3-cache
with:
server-token: "yolo"
cleanup-cache-folder: "true"
aws-access-key: ${{ secrets.AWS_S3_CACHE_ACCESS_KEY }}
aws-secret-key: ${{ secrets.AWS_S3_CACHE_SECRET_KEY }}
- name: Install dependencies
run: pnpm i --filter="!./apps/**"
- name: Build and Test affected libraries
id: test-libs
run: pnpm run test --continue --filter="!./apps/**" --filter="!./libs/ui/**" --filter="!./tools/**" --filter="!live-common-tools" --filter="!ledger-live...[${{ inputs.since_branch && format('origin/{0}', inputs.since_branch) || 'HEAD^1' }}]" --api="http://127.0.0.1:${{ steps.turborepo-cache-server.outputs.port }}" --token="yolo" --team="foo"
shell: bash
- name: (On Failure) Upload live-common snapshots and source
uses: actions/upload-artifact@v3
if: failure()
with:
name: live-common-src
path: |
libs/ledger-live-common/src
- uses: actions/github-script@v6
if: always()
with:
script: |
const fs = require("fs");
fs.writeFileSync("summary-tests.txt", "${{ steps.test-libs.outcome }}", "utf-8");
- uses: actions/upload-artifact@v3
if: always()
with:
name: outputs
path: ${{ github.workspace }}/summary-tests.txt
test-ui:
name: "Test UI Libs"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
CI_OS: ubuntu-latest
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ (github.event_name == 'workflow_dispatch' && (inputs.ref || github.ref_name)) || github.sha }}
base: ${{ inputs.since_branch }}
fetch-depth: 0
- name: Setup the toolchain
uses: ./tools/actions/composites/setup-toolchain
# - uses: actions/setup-python@v4
# with:
# python-version: "3.10"
- uses: ruby/setup-ruby@v1
if: ${{ matrix.os == 'macos-latest' }}
with:
ruby-version: 2.6
- name: TurboRepo local caching server
id: turborepo-cache-server
uses: ./tools/actions/turborepo-s3-cache
with:
server-token: "yolo"
cleanup-cache-folder: "true"
aws-access-key: ${{ secrets.AWS_S3_CACHE_ACCESS_KEY }}
aws-secret-key: ${{ secrets.AWS_S3_CACHE_SECRET_KEY }}
- name: Install dependencies
run: pnpm i --filter="./libs/ui/**"
- name: Build and Test affected libraries
id: test-ui
run: pnpm run test --continue --filter="./libs/ui/**" --filter="!ledger-live...[${{ inputs.since_branch && format('origin/{0}', inputs.since_branch) || 'HEAD^1' }}]" --api="http://127.0.0.1:${{ steps.turborepo-cache-server.outputs.port }}" --token="yolo" --team="foo"
shell: bash
- name: (On Failure) Upload react-ui test results
uses: actions/upload-artifact@v3
if: failure()
with:
name: ${{ format('react-ui-test-results-{0}', matrix.os) }}
path: |
libs/ui/tests/react.spec.js-snapshots/
libs/ui/test-results/
- uses: actions/github-script@v6
if: always()
with:
script: |
const fs = require("fs");
fs.writeFileSync("summary-ui-${{ matrix.os }}.txt", "${{ steps.test-ui.outcome }}", "utf-8");
- uses: actions/upload-artifact@v3
if: always()
with:
name: outputs
path: ${{ github.workspace }}/summary-ui-${{ matrix.os }}.txt
codecheck-libraries:
name: "Codecheck Libraries"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
CI_OS: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: LedgerHQ/ledger-live/tools/actions/composites/checkout-merge@develop
with:
ref: ${{ (github.event_name == 'workflow_dispatch' && (inputs.ref || github.ref_name)) || github.sha }}
base: ${{ inputs.since_branch }}
fetch-depth: 0
- name: Setup the toolchain
uses: ./tools/actions/composites/setup-toolchain
# - uses: actions/setup-python@v4
# with:
# python-version: "3.10"
# - uses: ruby/setup-ruby@v1
# with:
# ruby-version: 2.6
- name: TurboRepo local caching server
id: turborepo-cache-server
uses: ./tools/actions/turborepo-s3-cache
with:
server-token: "yolo"
cleanup-cache-folder: "true"
aws-access-key: ${{ secrets.AWS_S3_CACHE_ACCESS_KEY }}
aws-secret-key: ${{ secrets.AWS_S3_CACHE_SECRET_KEY }}
- name: Install dependencies
run: pnpm i --filter="!./apps/**"
- name: Lint affected libraries
id: lint-libs
run: pnpm lint --continue --filter="!./apps/**" --filter="!./tools/**" --filter="!live-common-tools" --filter="!ledger-live...[${{ inputs.since_branch && format('origin/{0}', inputs.since_branch) || 'HEAD^1' }}]" --api="http://127.0.0.1:${{ steps.turborepo-cache-server.outputs.port }}" --token="yolo" --team="foo" -- --quiet
- name: Typecheck affected libraries
id: typecheck-libs
run: pnpm typecheck --continue --filter="!./apps/**" --filter="!./tools/**" --filter="!live-common-tools" --filter="!ledger-live...[${{ inputs.since_branch && format('origin/{0}', inputs.since_branch) || 'HEAD^1' }}]" --api="http://127.0.0.1:${{ steps.turborepo-cache-server.outputs.port }}" --token="yolo" --team="foo"
- uses: actions/github-script@v6
if: always()
with:
script: |
const fs = require("fs");
fs.writeFileSync("summary-typecheck.txt", "${{ steps.typecheck-libs.outcome }}", "utf-8");
fs.writeFileSync("summary-lint.txt", "${{ steps.lint-libs.outcome }}", "utf-8");
- uses: actions/upload-artifact@v3
if: always()
with:
name: outputs
path: |
${{ github.workspace }}/summary-typecheck.txt
${{ github.workspace }}/summary-lint.txt
report:
needs: [test-cli, test-docs, test-libraries, test-ui, codecheck-libraries, test-common-tools]
if: always() && !cancelled() && github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: outputs
- uses: actions/github-script@v6
name: build summary
with:
script: |
const fs = require("fs");
const resultTests = fs.readFileSync("${{ github.workspace }}/summary-tests.txt", "utf-8");
const resultLint = fs.readFileSync("${{ github.workspace }}/summary-lint.txt", "utf-8");
const resultTypecheck = fs.readFileSync("${{ github.workspace }}/summary-typecheck.txt", "utf-8");
const resultUILinux = fs.readFileSync("${{ github.workspace }}/summary-ui-ubuntu-latest.txt", "utf-8");
const resultUImacOS = fs.readFileSync("${{ github.workspace }}/summary-ui-macos-latest.txt", "utf-8");
const resultUIWindows = fs.readFileSync("${{ github.workspace }}/summary-ui-windows-latest.txt", "utf-8");
const statuses = {
doc: {
pass: ${{ needs.test-docs.outputs.fail != '1' }},
status: "${{ needs.test-docs.result }}",
},
tool: {
pass: ${{ needs.test-common-tools.result == 'success' }},
status: "${{ needs.test-common-tools.result }}",
},
cli: {
pass: ${{ needs.test-cli.outputs.test-fail == 'success' && needs.test-cli.outputs.fail != '1' }},
status: "${{ needs.test-cli.result }}",
},
codecheck: {
pass: ${{ needs.codecheck-libraries.result == 'success' }},
status: "${{ needs.codecheck-libraries.result }}",
},
tests: {
pass: ${{ needs.test-libraries.result == 'success' }},
status: "${{ needs.test-libraries.result }}",
},
lint: {
pass: resultLint == 'success',
status: resultLint,
},
typecheck: {
pass: resultTypecheck == 'success',
status: resultTypecheck,
},
ui: {
mac: {
pass: resultUImacOS == 'success',
status: resultUImacOS,
},
linux: {
pass: resultUILinux == 'success',
status: resultUILinux,
},
windows: {
pass: resultUIWindows == 'success',
status: resultUIWindows,
}
},
};
const summary = `### Test documentation files
${statuses.doc.pass ? "Documentation files are fine" : "Documentation files are outdated"}
- ${statuses.doc.pass ? "✅" : "❌"} **Test documentation files** ended with status \`${statuses.doc.status}\`
### Test CLI
${statuses.cli.pass ? "CLI tests are successful" : "CLI tests did not end successfully"}
- ${statuses.cli.pass ? "✅" : "❌"} **CLI tests** ended with status \`${statuses.cli.status}\`
### Codecheck Libraries
${statuses.codecheck.pass ? "Codecheck was successfull" : "Codecheck failed"}
- ${statuses.codecheck.pass ? "✅" : "❌"} **Codecheck** ended with status \`${statuses.codecheck.status}\`
| Lint | Typecheck |
| :--: | :--: |
| ${statuses.lint.pass ? "✅" : "❌"} (${statuses.lint.status}) | ${statuses.typecheck.pass ? "✅" : "❌"} (${statuses.typecheck.status}) |
### Test Libraries
${statuses.tests.pass ? "All tests are fine" : "Some tests failed"}
- ${statuses.tests.pass ? "✅" : "❌"} **Test Libs** ended with status \`${statuses.tests.status}\`
### Test UI Design System
| Linux (🤖) | macOS (🍏) | windows (🪟) |
| :--: | :--: | :--: |
| ${statuses.ui.linux.pass ? "✅" : "❌"} (${statuses.ui.linux.status}) | ${statuses.ui.mac.pass ? "✅" : "❌"} (${statuses.ui.mac.status}) | ${statuses.ui.windows.pass ? "✅" : "❌"} (${statuses.ui.windows.status}) |
### Common Tools
${statuses.tool.pass ? "Common Tools are fine" : "Common Tools tests failed"}
- ${statuses.tool.pass ? "✅" : "❌"} **Common Tools* tests* ended with status \`${statuses.tool.status}\`
`;
const actions = [];
if (${{ needs.test-docs.outputs.fail == '1' }}) {
actions.push({
// 20 chars max
label: "Regen. Doc Files",
// 20 chars max
identifier: "regen_doc",
// 40 chars max
description: "Will regenerate doc files for ljs",
});
}
const output = {
summary,
actions
};
fs.writeFileSync("summary.json", JSON.stringify(output), "utf-8");
- uses: actions/upload-artifact@v3
name: Upload output
with:
path: ${{ github.workspace }}/summary.json
name: summary.json