-
Notifications
You must be signed in to change notification settings - Fork 8
171 lines (147 loc) · 5.74 KB
/
Copy pathci-web.yml
File metadata and controls
171 lines (147 loc) · 5.74 KB
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
# Checks the web build: lint, types, unit tests, the static export, and the
# Playwright suite that drives it in a real browser.
#
# This is the one that runs on every push and pull request, because it is the
# one that covers the whole application. The pipeline is WebAssembly and the
# frontend is a static export, so a browser exercises the same code the
# desktop app runs -- the desktop job exists to prove the Tauri shell around it
# still builds, not to test the pipeline a second time.
name: CI (web)
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
concurrency:
# A newer push makes an in-flight run irrelevant. Not applied to `main`,
# where every commit's result is worth keeping.
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
group: ci-web-${{ github.ref }}
permissions:
contents: read
jobs:
check:
name: Lint, types and unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
cache: npm
# Both lockfiles. Keyed on the root one alone, the Playwright
# install in the e2e job is uncached on every run.
cache-dependency-path: |
package-lock.json
e2e-web/package-lock.json
node-version: lts/*
- run: npm ci
- name: Lint
run: npm run check
- name: Typecheck
run: npx tsc --noEmit
- name: Unit tests
run: npm test -- --ci
- name: Check versions.json is present and well formed
# Not `npm run wasm:versions:check`, which was here and wrong.
# That regenerates the file from sibling *fork checkouts*
# (`../LibRaw`, `../Radiance`, `../hdrgen`) and compares -- a tool for
# whoever rebuilt the artifacts, run from the tree they were built in.
# CI has no such checkouts and should not: cloning three forks to
# re-derive a committed file would be checking the clone, not the
# build. The real check belongs with the rebuild job in #244, which
# has those sources by construction.
#
# What is worth checking here is that the file the Settings page reads
# actually shipped and parses, since an export missing it renders fine
# and simply stops saying which Radiance produced your luminance map.
run: |
node -e "
const v = require('./public/wasm/versions.json');
const tools = Object.keys(v.tools ?? {});
if (tools.length === 0) { throw new Error('versions.json lists no tools'); }
for (const [name, tool] of Object.entries(v.tools)) {
if (!tool.version) { throw new Error(name + ' has no version'); }
}
console.log('versions.json describes ' + tools.length + ' tools:', tools.join(', '));
"
build:
name: Static export
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
cache: npm
# Both lockfiles. Keyed on the root one alone, the Playwright
# install in the e2e job is uncached on every run.
cache-dependency-path: |
package-lock.json
e2e-web/package-lock.json
node-version: lts/*
- run: npm ci
- run: npm run build
- name: Check the export is actually servable
# A static export with no index.html 404s at the root, which is the
# first thing a visitor sees and the last thing a build log mentions.
run: |
test -f out/index.html
test -f out/home-page.html
test -f out/wasm/versions.json
test -f out/wasm/hdrgen.wasm
- uses: actions/upload-artifact@v7
with:
name: web-build
path: out
retention-days: 7
e2e:
name: End-to-end (${{ matrix.project }})
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# WebKit first in the list and first in the config, deliberately.
# Safari implements no part of the File System Access API, so it takes
# the plain file-input and download path -- which is the path this
# application ships to everyone.
project: [webkit, chromium]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
cache: npm
# Both lockfiles. Keyed on the root one alone, the Playwright
# install in the e2e job is uncached on every run.
cache-dependency-path: |
package-lock.json
e2e-web/package-lock.json
node-version: lts/*
- name: Reuse the export from the build job
# Rather than rebuilding per browser. It is the same bytes either way,
# and this is the artifact that would actually be deployed.
uses: actions/download-artifact@v8
with:
name: web-build
path: out
# `working-directory` rather than `npm --prefix`. `--prefix` moves where
# npm resolves packages, not the working directory, so Playwright looked
# for its config at the repository root, found none, and reported
# `Available projects: ""`.
- name: Install
run: npm ci
working-directory: e2e-web
- name: Install browsers
run: npx playwright install --with-deps ${{ matrix.project }}
working-directory: e2e-web
- name: Run
run: npx playwright test --project=${{ matrix.project }}
working-directory: e2e-web
- if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: playwright-report-${{ matrix.project }}
path: |
e2e-web/playwright-report
e2e-web/test-results
retention-days: 7