Skip to content

Commit 83353e0

Browse files
authored
fix(ci): e2e coverage (#2142)
* tests(e2e): coverage for separate shard runs * test(e2e): cache test-build
1 parent 670ba7c commit 83353e0

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

.github/workflows/test-e2e.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,48 @@ on:
22
workflow_call:
33

44
jobs:
5+
test-build:
6+
name: 'test:build'
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/[email protected]
10+
11+
- name: Setup node
12+
uses: actions/[email protected]
13+
with:
14+
node-version: 18.14.0
15+
16+
- name: Cache bigger downloads
17+
uses: actions/[email protected]
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+
uses: actions/[email protected]
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
542

643
test-e2e:
744
name: 'test:e2e'
845
runs-on: ubuntu-latest
46+
needs: [test-build]
947
strategy:
1048
fail-fast: false
1149
matrix:
@@ -35,10 +73,29 @@ jobs:
3573
- name: Install playwright browsers
3674
run: npx playwright install --with-deps
3775

76+
- name: Cache test-build output
77+
uses: actions/[email protected]
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+
3885
# This is required to ensure that our code is instrumented with coverage details
3986
- name: Run test build
87+
if: steps.test-build-cache.outputs.cache-hit != 'true'
4088
run: npm run test:build
4189

90+
- name: Cache nyc_output dir
91+
uses: actions/[email protected]
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+
4299
- name: Run repeated-E2E against Kubo
43100
if: github.ref != 'refs/heads/main' # only run duplicated e2e tests on PRs
44101
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:
47104
if: github.ref == 'refs/heads/main' # run non-duplicated tests on non-PRs
48105
run: npm run test:e2e -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
49106

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+
- uses: actions/[email protected]
113+
114+
- name: Setup node
115+
uses: actions/[email protected]
116+
with:
117+
node-version: 18.14.0
118+
119+
- name: Cache bigger downloads
120+
uses: actions/[email protected]
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+
uses: actions/[email protected]
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+
50142
- name: Generate nyc coverage report
51143
id: coverage
52144
run: npx nyc report --reporter=lcov

config-overrides.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ function webpackOverride (config) {
110110
const REACT_APP_ENV = process.env.REACT_APP_ENV ?? process.env.NODE_ENV ?? 'development'
111111
if (REACT_APP_ENV === 'test') {
112112
config.module.rules = modifyBabelLoaderRuleForTest(config.module.rules)
113+
config.devtool = 'inline-source-map'
113114
} else if (REACT_APP_ENV === 'development') {
114115
config.optimization = {
115116
...config.optimization,

0 commit comments

Comments
 (0)