-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (88 loc) · 3.93 KB
/
Copy pathsite.yml
File metadata and controls
97 lines (88 loc) · 3.93 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
# Builds the landing site on a pull request, so `check-prose` (site/scripts,
# run by `pnpm build`) is a gate rather than a report. Before this file the
# check only ran after a merge: ci.yml's `make lint test` never reaches site/,
# and deploy-site.yml runs on push to main alone.
#
# A file of its own rather than a job in ci.yml because path filtering in
# Actions lives on the trigger, not on the job — ci.yml runs on everything
# and cannot carry a `paths:` without narrowing all of it.
#
# README.md and scripts/install.sh are in the paths because check-prose reads
# both by name, so either can turn this red with site/ untouched.
name: site
on:
push:
branches: [main]
paths:
- "site/**"
- "README.md"
- "scripts/install.sh"
- ".github/workflows/site.yml"
pull_request:
paths:
- "site/**"
- "README.md"
- "scripts/install.sh"
- ".github/workflows/site.yml"
permissions:
contents: read
jobs:
build-and-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install the toolchain from mise.toml
uses: jdx/mise-action@v4
# mise-action caches the tools it installs, but not the pnpm store;
# cache it separately, keyed on the lockfile. site/ is its own pnpm
# workspace, so it needs its own key — ci.yml's hashes web/ and relay/.
- name: Locate the pnpm store
id: pnpm-store
run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
- name: Cache the pnpm store
uses: actions/cache@v6
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-store-site-${{ runner.os }}-${{ hashFiles('site/pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-site-${{ runner.os }}-
- name: Install the site's dependencies
working-directory: site
run: pnpm install --frozen-lockfile
# Build before lint, which looks backwards and is not: `lint` is
# tsc --noEmit, and src/routeTree.gen.ts is gitignored and written by the
# router's vite plugin, so on a fresh checkout there is no copy to typecheck
# against and tsc fails on `Cannot find module './routeTree.gen'`. The build
# is also what check-prose reads — it scans the prerendered dist/client.
#
# Three attempts because the prerender step fetches each route out of a
# vite preview server on an ephemeral port and loses a race with it often
# enough to matter: measured at 1 build in 8, 3 in 12 and 4 in 6, failing
# as `connect ETIMEDOUT ::1:<port>` and `ECONNREFUSED 127.0.0.1:<port>` on
# the port nothing is listening on yet. A required check that red-lights at
# that rate teaches people to press re-run without reading, and then it
# stops catching anything.
#
# Every measurement was macOS, and the error shapes are macOS-flavoured, so
# this may be precautionary here — see the note in the commit. It is a
# workaround for a flake and not a licence for a broken build: each attempt
# announces itself, so a real failure reads as three real failures. Drop it
# if the runs stay green without it, or when the prerender's own retryCount
# is set in vite.config.ts and fixes this where it happens.
- name: Build the site
working-directory: site
run: |
for attempt in 1 2 3; do
echo "::group::Build attempt $attempt of 3"
if pnpm build; then
echo "::endgroup::"
exit 0
fi
echo "::endgroup::"
echo "::warning::Site build attempt $attempt of 3 failed. If the log above ends in a prerender fetch error, it is the port race; anything else is real."
done
echo "::error::Site build failed three times. Three failures is not the flake — read the first attempt's log."
exit 1
- name: Lint the site
working-directory: site
run: pnpm lint