forked from ipfs/ipfs-webui
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (132 loc) · 5.41 KB
/
test-e2e.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
on:
workflow_call:
jobs:
test-build:
name: 'test:build'
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18.14.0
cache: 'npm'
- name: Cache test-build output
uses: actions/cache@v4
id: test-build-cache
with:
path: build
key: test-build-${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'public', 'src/**', '*.js', '*.ts') }}
restore-keys: |
test-build-${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'public', 'src/**', '*.js', '*.ts') }}
- name: Cache node_modules
uses: actions/cache@v4
id: test-npm-cache
with:
path: node_modules
key: test-npm-${{ runner.os }}-${{ github.sha }}-${{ hashFiles('package.json', 'package-lock.json', 'public', 'src/**', 'patches/**', '*.js', '*.ts') }}
restore-keys: |
test-npm-${{ runner.os }}-${{ github.sha }}-${{ hashFiles('package.json', 'package-lock.json', 'public', 'src/**', 'patches/**', '*.js', '*.ts') }}
- name: Install dependencies
if: steps.test-npm-cache.outputs.cache-hit != 'true'
run: npm ci --prefer-offline --no-audit --progress=false
# This is required to ensure that our code is instrumented with coverage details
- name: Run test build
if: steps.test-build-cache.outputs.cache-hit != 'true'
run: npm run test:build
test-e2e:
name: 'test:e2e'
runs-on: ubuntu-latest
needs: [test-build]
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shardTotal: [10]
steps:
- uses: actions/[email protected]
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18.14.0
cache: 'npm'
- name: Cache test-build output
uses: actions/cache@v4
id: test-build-cache
with:
path: build
key: test-build-${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'public', 'src/**', '*.js', '*.ts') }}
restore-keys: |
test-build-${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'public', 'src/**', '*.js', '*.ts') }}
# We don't want to re-install dependencies for every sharded run
- name: Cache node_modules
uses: actions/cache@v4
id: test-npm-cache
with:
path: node_modules
key: test-npm-${{ runner.os }}-${{ github.sha }}-${{ hashFiles('package.json', 'package-lock.json', 'public', 'src/**', 'patches/**', '*.js', '*.ts') }}
restore-keys: |
test-npm-${{ runner.os }}-${{ github.sha }}-${{ hashFiles('package.json', 'package-lock.json', 'public', 'src/**', 'patches/**', '*.js', '*.ts') }}
- name: Install dependencies
if: steps.test-npm-cache.outputs.cache-hit != 'true'
run: npm ci --prefer-offline --no-audit --progress=false
# Cache playwright binaries
- uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
- run: npm ci
- run: npx playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Cache nyc_output dir
uses: actions/cache@v4
id: nyc_output-cache
with:
path: ./.nyc_output
key: nyc_output-${{ runner.os }}-${{ github.sha }}
restore-keys: |
nyc_output-${{ runner.os }}-${{ github.sha }}
- name: Run repeated-E2E against Kubo
if: github.ref != 'refs/heads/main' # only run duplicated e2e tests on PRs
run: npm run test:e2e -- --repeat-each 10 --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} # run each test 10 times to ensure no flakiness
- name: Run non-repeated-E2E against Kubo
if: github.ref == 'refs/heads/main' # run non-duplicated tests on non-PRs
run: npm run test:e2e -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Store Artifacts from Failed Tests
if: failure()
uses: actions/upload-artifact@v3
with:
name: test-results
path: test-results/
retention-days: 7
e2e-coverage: # since we run coverage in shards and some files may not contain coverage, we cache the .nyc_output directory
name: 'e2e-coverage'
runs-on: ubuntu-latest
needs: [test-e2e]
steps:
- uses: actions/[email protected]
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18.14.0
cache: 'npm'
- name: Cache nyc_output dir
uses: actions/cache@v4
id: nyc_output-cache
with:
path: ./.nyc_output
key: nyc_output-${{ runner.os }}-${{ github.sha }}
restore-keys: |
nyc_output-${{ runner.os }}-${{ github.sha }}
- name: Generate nyc coverage report
id: coverage
run: npx nyc report --reporter=lcov
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: e2e_tests # optional
name: e2e-coverage # optional
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)