2
2
workflow_call :
3
3
4
4
jobs :
5
+ test-build :
6
+ name : ' test:build'
7
+ runs-on : ubuntu-latest
8
+ steps :
9
+
10
+
11
+ - name : Setup node
12
+
13
+ with :
14
+ node-version : 18.14.0
15
+
16
+ - name : Cache bigger downloads
17
+
18
+ id : cache
19
+ with :
20
+ path : ${{ github.workspace }}/.cache
21
+ key : ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }}
22
+ restore-keys : |
23
+ ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }}
24
+ ${{ runner.os }}-
25
+
26
+ - name : Install dependencies
27
+ run : npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm
28
+
29
+ - name : Cache test-build output
30
+
31
+ id : test-build-cache
32
+ with :
33
+ path : build
34
+ key : test-build-${{ runner.os }}-${{ github.sha }}
35
+ restore-keys : |
36
+ test-build-${{ runner.os }}-${{ github.sha }}
37
+
38
+ # This is required to ensure that our code is instrumented with coverage details
39
+ - name : Run test build
40
+ if : steps.test-build-cache.outputs.cache-hit != 'true'
41
+ run : npm run test:build
5
42
6
43
test-e2e :
7
44
name : ' test:e2e'
8
45
runs-on : ubuntu-latest
46
+ needs : [test-build]
9
47
strategy :
10
48
fail-fast : false
11
49
matrix :
@@ -35,10 +73,29 @@ jobs:
35
73
- name : Install playwright browsers
36
74
run : npx playwright install --with-deps
37
75
76
+ - name : Cache test-build output
77
+
78
+ id : test-build-cache
79
+ with :
80
+ path : build
81
+ key : test-build-${{ runner.os }}-${{ github.sha }}
82
+ restore-keys : |
83
+ test-build-${{ runner.os }}-${{ github.sha }}
84
+
38
85
# This is required to ensure that our code is instrumented with coverage details
39
86
- name : Run test build
87
+ if : steps.test-build-cache.outputs.cache-hit != 'true'
40
88
run : npm run test:build
41
89
90
+ - name : Cache nyc_output dir
91
+
92
+ id : nyc_output-cache
93
+ with :
94
+ path : ./.nyc_output
95
+ key : nyc_output-${{ runner.os }}-${{ github.sha }}
96
+ restore-keys : |
97
+ nyc_output-${{ runner.os }}-${{ github.sha }}
98
+
42
99
- name : Run repeated-E2E against Kubo
43
100
if : github.ref != 'refs/heads/main' # only run duplicated e2e tests on PRs
44
101
run : npm run test:e2e -- --repeat-each 10 --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} # run each test 10 times to ensure no flakiness
@@ -47,6 +104,41 @@ jobs:
47
104
if : github.ref == 'refs/heads/main' # run non-duplicated tests on non-PRs
48
105
run : npm run test:e2e -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
49
106
107
+ e2e-coverage : # since we run coverage in shards and some files may not contain coverage, we cache the .nyc_output directory
108
+ name : ' e2e-coverage'
109
+ runs-on : ubuntu-latest
110
+ needs : [test-e2e]
111
+ steps :
112
+
113
+
114
+ - name : Setup node
115
+
116
+ with :
117
+ node-version : 18.14.0
118
+
119
+ - name : Cache bigger downloads
120
+
121
+ id : cache
122
+ with :
123
+ path : ${{ github.workspace }}/.cache
124
+ key : ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }}
125
+ restore-keys : |
126
+ ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }}
127
+ ${{ runner.os }}-
128
+
129
+
130
+ - name : Install dependencies
131
+ run : npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm
132
+
133
+ - name : Cache nyc_output dir
134
+
135
+ id : nyc_output-cache
136
+ with :
137
+ path : ./.nyc_output
138
+ key : nyc_output-${{ runner.os }}-${{ github.sha }}
139
+ restore-keys : |
140
+ nyc_output-${{ runner.os }}-${{ github.sha }}
141
+
50
142
- name : Generate nyc coverage report
51
143
id : coverage
52
144
run : npx nyc report --reporter=lcov
0 commit comments