-
Notifications
You must be signed in to change notification settings - Fork 8
134 lines (117 loc) · 4.4 KB
/
ci.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
name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
# Playwright headless browsers running in CI get low confidence scores, causing flaky e2e tests. Lower the confidence score threshold for CI testing.
MIN_CONFIDENCE_SCORE: 0
# Staging Cloudflare credentials and IDs for e2e tests
CLOUDFLARE_API_TOKEN: '${{ secrets.CLOUDFLARE_API_TOKEN }}'
CLOUDFLARE_ZONE_ID: '${{ secrets.CLOUDFLARE_ZONE_ID }}'
CLOUDFLARE_RULESET_ID: '${{ secrets.CLOUDFLARE_RULESET_ID }}'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Install pnpm'
uses: pnpm/action-setup@ebcfd6995dade4b0104ac774445cef8b3b4635b0
with:
version: 8
- name: 'Cache'
uses: actions/cache@v4
with:
path: node_modules
key: nodemodules-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: nodemodules-
- name: Install packages
run: pnpm install --frozen-lockfile --prefer-offline
- name: Lint
run: pnpm lint
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Install pnpm'
uses: pnpm/action-setup@ebcfd6995dade4b0104ac774445cef8b3b4635b0
with:
version: 8
- name: 'Cache'
uses: actions/cache@v4
with:
path: node_modules
key: nodemodules-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: nodemodules-
- name: Install packages
run: pnpm install --frozen-lockfile --prefer-offline
- name: Run unit tests
run: pnpm test
e2e:
name: Playwright e2e tests
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3]
shardTotal: [3]
steps:
- uses: actions/checkout@v4
- name: 'Install pnpm'
uses: pnpm/action-setup@ebcfd6995dade4b0104ac774445cef8b3b4635b0
with:
version: 8
- name: Cache node modules
uses: actions/cache@v4
with:
path: node_modules
key: nodemodules-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: nodemodules-
- name: Install node modules
run: pnpm install --prefer-offline --frozen-lockfile
- name: Get installed Playwright version (used in cache key)
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(node -e "process.stdout.write(require('@playwright/test/package.json').version)")" >> $GITHUB_ENV
- name: Cache Playwright browser binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Playwright browsers binaries if cache missed
run: pnpm playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
# Ubuntu needs extra stuff to run webkit tests, alternative is using a Playwright docker container but
# that is slower in CI.
- name: If browser binaries cache hit, install just webkit dependencies
run: pnpm playwright install-deps webkit
if: steps.playwright-cache.outputs.cache-hit == 'true'
- name: Cache Next build
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('src/*') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-
- name: Build website
run: pnpm build
- name: Run Playwright tests
run: pnpm playwright test --grep-invert CHROME_ONLY --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
# Some tests are only run on Chrome, marked with CHROME_ONLY in their name
- name: Run Chrome-only Playwright tests
run: pnpm playwright test --grep CHROME_ONLY --project='chromium'
if: matrix.shardIndex == 1
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-${{ matrix.shardIndex }}
path: playwright-report/
retention-days: 30