-
Notifications
You must be signed in to change notification settings - Fork 18
174 lines (145 loc) · 4.78 KB
/
e2e-tests.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
# Workflow for running E2E tests for PRs and pushes to the main branch for
# napari hub frontend code.
name: E2E Tests
on:
push:
branches:
- main
paths:
- .github/workflows/e2e-tests.yml
- 'frontend/**'
pull_request:
branches:
- '**'
paths:
- .github/workflows/e2e-tests.yml
- 'frontend/**'
defaults:
run:
working-directory: frontend/
env:
FIXTURES_CACHE_KEY: e2e-fixtures-${{ github.run_id }}-${{ github.run_attempt }}
jobs:
e2e-setup:
name: E2E Setup
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.5.x
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
# cache both yarn-lock and node_modules
- name: Setup Yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: |
**/node_modules
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# --prefer-offline forces yarn to use cache if available
- name: Install dependencies with yarn
# if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --prefer-offline --frozen-lockfile
- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: playwright-${{ hashFiles('**/yarn.lock') }}
- name: Install playwright
# if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Setting up local build cache
uses: actions/cache@v3
with:
path: frontend/.next
key: local-build-${{ hashFiles('**/next.config.js') }}-${{ hashFiles('frontend/src') }}-${{ hashFiles('**/yarn.lock') }}
- name: Build frontend for local testing
# if: steps.prod-build-cache.outputs.cache-hit != 'true'
run: yarn build
- name: Setting up fixture cache
uses: actions/cache@v3
with:
path: frontend/e2e/fixtures
key: ${{ env.FIXTURES_CACHE_KEY }}
- name: Fetch fixture data
env:
ENV: local
run: node scripts/fetch-e2e-fixtures
e2e:
name: E2E tests ${{ matrix.browser }} ${{ matrix.shardCurrent }} / ${{ matrix.shardTotal }}
runs-on: ubuntu-latest
needs: e2e-setup
concurrency:
group: ${{ github.ref }}-${{ matrix.browser }}-${{ matrix.shardCurrent }}-${{ matrix.shardTotal }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
# browser: [chrome, firefox, safari]
browser: [chrome]
shardCurrent: [1, 2, 3, 4, 5]
shardTotal: [5]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.5.x
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
# cache both yarn-lock and node_modules
- name: Load yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: |
**/node_modules
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Load cached playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: playwright-${{ hashFiles('**/yarn.lock') }}
- name: Load cached local build
uses: actions/cache@v3
with:
path: frontend/.next
key: local-build-${{ hashFiles('**/next.config.js') }}-${{ hashFiles('frontend/src') }}-${{ hashFiles('**/yarn.lock') }}
- name: Start server on port 8080
run: yarn start &
env:
API_URL: https://api.staging.napari-hub.org
E2E: true
- name: Load fixtures cache
uses: actions/cache@v3
with:
path: frontend/e2e/fixtures
key: ${{ env.FIXTURES_CACHE_KEY }}
- name: Run E2E Tests
env:
BROWSER: ${{ matrix.browser }}
ENV: local
run: yarn e2e:ci --shard ${{ matrix.shardCurrent }}/${{ matrix.shardTotal }}
- name: Upload artifacts
if: ${{ failure() }}
uses: actions/[email protected]
with:
name: e2e-artifacts
path: frontend/e2e/report
retention-days: 1