Repository navigation
170 lines (164 loc) · 7.18 KB
/
Copy pathci.yml
File metadata and controls
170 lines (164 loc) · 7.18 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
name: CI
on:
pull_request:
push:
branches:
- main
workflow_call:
permissions:
contents: read
concurrency:
# Reusable calls inherit the caller's workflow name, so deployments never cancel CI.
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
extension-build:
name: Build production extension
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Build production ZIP with its authenticated SDK
env:
MDBASE_ENV: production
run: pnpm --filter @mdbase-reader/extension package
- name: Keep source and generated manifests clean
run: test -z "$(git status --porcelain)"
check:
name: Lint, typecheck, test and build
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
cache: pnpm
- run: pnpm run check:release-downloads && pnpm run test:release-downloads
- run: pnpm install --frozen-lockfile
# Tests build against the production-pinned SDK unless an environment is selected.
- run: pnpm check
- run: node --test scripts/performance-report.test.mjs
- name: Install Chromium for PDF touch regression tests
run: pnpm --filter @mdbase-reader/app exec playwright install --with-deps chromium
- name: Verify extension shared-session writes across separate bundles
run: pnpm --filter @mdbase-reader/extension test:browser
- name: Verify PDF gestures and mobile highlight persistence
run: pnpm --filter @mdbase-reader/app test:pdf-touch
- name: Verify library keyboard navigation and restored article highlights
run: pnpm --filter @mdbase-reader/app test:library-article
- name: Verify mobile library filters and article accessibility
run: pnpm --filter @mdbase-reader/app test:mobile-library
- name: Verify imported SVG rendering in the HTML sandbox
run: pnpm --filter @mdbase-reader/app test:html-svg
- name: Verify private feedback with sample data and intercepted delivery
env:
VITE_MDBASE_FEEDBACK_URL: http://127.0.0.1:8891/v1/feedback
VITE_MDBASE_ENV: lab
run: |
pnpm --filter @mdbase-reader/app build
pnpm --filter @mdbase-reader/app exec vite preview --host 127.0.0.1 --port 8891 --strictPort > "$RUNNER_TEMP/reader-feedback-preview.log" 2>&1 &
preview_pid=$!
trap 'kill "$preview_pid" 2>/dev/null || true' EXIT
ready=0
for attempt in {1..30}; do
kill -0 "$preview_pid" 2>/dev/null || exit 1
if curl --max-time 2 --fail --silent http://127.0.0.1:8891/ >/dev/null; then
ready=1
break
fi
sleep 1
done
test "$ready" -eq 1
pnpm --filter @mdbase-reader/app test:feedback
# Generated manifests are committed for production; building for it must leave the tree clean.
- run: pnpm build
env:
MDBASE_ENV: production
- name: Record production bundle sizes
id: performance_sizes
continue-on-error: true
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: node scripts/performance-report.mjs apps/reader/dist "$RUNNER_TEMP/reader-sizes.json"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.performance_sizes.outcome == 'success'
continue-on-error: true
with:
name: performance-reader-sizes
path: ${{ runner.temp }}/reader-sizes.json
retention-days: 90
if-no-files-found: error
- name: Publish size history
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.performance_sizes.outcome == 'success'
continue-on-error: true
env:
OPS_BENCHMARK_TOKEN: ${{ secrets.OPS_BENCHMARK_TOKEN }}
run: |
if [ -z "$OPS_BENCHMARK_TOKEN" ]; then
echo '::warning::Performance upload skipped: OPS_BENCHMARK_TOKEN is not configured.'
exit 0
fi
curl --fail --silent --show-error --max-time 20 --output /dev/null \
-H "Authorization: Bearer $OPS_BENCHMARK_TOKEN" -H 'Content-Type: application/json' \
--data-binary "@$RUNNER_TEMP/reader-sizes.json" https://ops-ingest.mdbase.dev/v1/benchmarks
- name: Verify generated files are committed
run: |
if [ -n "$(git status --porcelain)" ]; then
git status --short
git diff
echo "::error::The build changed tracked or unignored files. Regenerate and commit them."
exit 1
fi
deploy-lab:
name: Deploy Reader to lab
needs: check
if: github.workflow == 'CI' && github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
timeout-minutes: 15
concurrency:
group: deploy-reader-lab
cancel-in-progress: false
environment:
name: reader-lab
url: https://lab.mdbase-reader.pages.dev/
env:
MDBASE_ENV: lab
steps:
# Lab deploys are automatic; without credentials they are skipped
# visibly rather than turning every main build red.
- name: Check Cloudflare credentials
id: credentials
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
if [ -n "$CLOUDFLARE_API_TOKEN" ]; then
echo "configured=true" >>"$GITHUB_OUTPUT"
else
echo "::warning::Lab deploy skipped: the reader-lab environment has no CLOUDFLARE_API_TOKEN (Cloudflare Pages: Edit). Deploy locally with pnpm deploy:dev."
echo "configured=false" >>"$GITHUB_OUTPUT"
fi
- if: steps.credentials.outputs.configured == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- if: steps.credentials.outputs.configured == 'true'
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- if: steps.credentials.outputs.configured == 'true'
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
cache: pnpm
- if: steps.credentials.outputs.configured == 'true'
run: pnpm install --frozen-lockfile
- if: steps.credentials.outputs.configured == 'true'
run: pnpm deploy:dev
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}