-
-
Notifications
You must be signed in to change notification settings - Fork 282
295 lines (281 loc) · 10.6 KB
/
Copy pathci.yml
File metadata and controls
295 lines (281 loc) · 10.6 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
E2E_CLOUD_PRO_EMAIL: ${{ secrets.E2E_CLOUD_PRO_EMAIL }}
E2E_CLOUD_PRO_PASSWORD: ${{ secrets.E2E_CLOUD_PRO_PASSWORD }}
# Least-privilege default; jobs that need more (e.g. packages: write) opt in per-job.
permissions:
contents: read
jobs:
downloader:
name: Downloader (Go)
runs-on: ubuntu-latest
if: github.repository == 'saltbo/zpan'
defaults:
run:
working-directory: cmd
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: cmd/go.mod
cache-dependency-path: cmd/go.sum
- name: Check formatting
run: |
files="$(gofmt -l .)"
if [ -n "$files" ]; then
echo "$files"
exit 1
fi
- name: Test with coverage threshold
run: bash scripts/test-coverage.sh
- name: Install live downloader engines
run: sudo apt-get update && sudo apt-get install -y aria2 qbittorrent-nox
working-directory: .
- name: Verify live downloads
run: LIVE_DOWNLOAD_VERIFY=1 go test ./pkg/downloaders -run 'TestLive(DownloadThreeSourceTypes|QBittorrentDownloadTorrentURL)' -count=1 -v
check:
name: Typecheck & Test
runs-on: ubuntu-latest
if: github.repository == 'saltbo/zpan'
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- uses: actions/setup-go@v6
with:
go-version-file: cmd/go.mod
cache-dependency-path: cmd/go.sum
- run: pnpm install --frozen-lockfile
- run: pnpm lint
- run: pnpm lint:arch
- run: pnpm lint:http
- run: pnpm lint:spec
- run: pnpm typecheck
- run: pnpm openapi:client:check
- run: pnpm exec vitest run --project unit --coverage --coverage.reportsDirectory=coverage/unit
- uses: codecov/codecov-action@v5
if: always()
with:
files: coverage/unit/coverage-final.json
flags: unit
disable_search: true
fail_ci_if_error: false
handle_no_reports_found: true
- run: pnpm exec vitest run --project integration --coverage --coverage.reportsDirectory=coverage/integration
- uses: codecov/codecov-action@v5
if: always()
with:
files: coverage/integration/coverage-final.json
flags: integration
disable_search: true
fail_ci_if_error: false
handle_no_reports_found: true
- run: mkdir -p dist
- run: pnpm test:cf
docker-smoke:
name: Docker image smoke test
runs-on: ubuntu-latest
if: github.repository == 'saltbo/zpan'
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- name: Build & start the stack
run: docker compose -f docker-compose.yml up -d --build --wait --wait-timeout 300
- name: Assert server health from host
run: curl --fail --retry 5 --retry-delay 3 --retry-connrefused http://localhost:8222/api/health
- name: Dump logs on failure
if: failure()
run: docker compose -f docker-compose.yml logs --no-color
- name: Tear down
if: always()
run: docker compose -f docker-compose.yml down -v
docker-dev:
name: Docker dev image
runs-on: ubuntu-latest
needs: [check, docker-smoke]
# Publish the bleeding-edge `:dev` image only for green pushes to main on the
# canonical repo — never on PRs or forks. `:latest` stays pinned to releases.
if: github.repository == 'saltbo/zpan' && github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@v4
- name: Build & push server image
uses: docker/build-push-action@v7
with:
context: .
push: true
# Dev images are amd64-only to skip slow arm64 QEMU emulation
# (native better-sqlite3/sharp). Releases stay multi-arch.
platforms: linux/amd64
build-args: |
APP_VERSION=dev
APP_COMMIT=${{ github.sha }}
tags: ghcr.io/${{ github.repository }}:dev
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build & push CLI image
uses: docker/build-push-action@v7
with:
context: .
target: cli
push: true
# Dev images are amd64-only (see server image above). Releases stay multi-arch.
platforms: linux/amd64
build-args: |
APP_VERSION=dev
APP_COMMIT=${{ github.sha }}
tags: ghcr.io/${{ github.repository }}:dev-cli
cache-from: type=gha
cache-to: type=gha,mode=max
cf-deploy-dry-run:
name: CF deploy dry-run
runs-on: ubuntu-latest
if: github.repository == 'saltbo/zpan'
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Build
env:
ZPAN_APP_VERSION: ci-dry-run
run: pnpm build
# --dry-run compiles the Worker and validates wrangler.toml + the
# vite-plugin deploy config (assets dir, queues, bindings) without
# contacting Cloudflare, so it needs no secrets and runs on fork PRs.
# Guards the deploy regressions a unit test can't: a dropped build step
# (#417) or an unprovisioned binding added to wrangler.toml.
- name: Validate Cloudflare deploy config
run: pnpm exec wrangler deploy --dry-run
e2e-node:
name: E2E (Node)
runs-on: ubuntu-latest
needs: check
env:
BETTER_AUTH_SECRET: ci-test-secret-that-is-at-least-32-chars
E2E_CLOUD_BUSINESS_EMAIL_NODE: ${{ secrets.E2E_CLOUD_BUSINESS_EMAIL_NODE }}
E2E_CLOUD_BUSINESS_PASSWORD_NODE: ${{ secrets.E2E_CLOUD_BUSINESS_PASSWORD_NODE }}
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Run E2E
run: |
E2E_APP_PORT=5185 \
E2E_BASE_URL=http://localhost:5185 \
E2E_LOCAL_BASE_URL=http://localhost:5185 \
E2E_S3_MOCK=1 \
E2E_STORAGE_ENDPOINT=http://127.0.0.1:9191 \
E2E_STORAGE_BUCKET=e2e-test \
E2E_STORAGE_REGION=auto \
E2E_STORAGE_ACCESS_KEY=e2e-access-key \
E2E_STORAGE_SECRET_KEY=e2e-secret-key \
BETTER_AUTH_URL=http://localhost:5185 \
TRUSTED_ORIGINS=http://localhost:5185 \
pnpm e2e --project=desktop --grep-invert "Cloud store|Cloud licensing|Archive jobs|Site announcements"
- name: Install cloudflared
if: env.E2E_CLOUD_BUSINESS_EMAIL_NODE != '' && env.E2E_CLOUD_BUSINESS_PASSWORD_NODE != ''
run: |
curl -L --fail --output cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
chmod +x cloudflared
- name: Run cloud E2E
if: env.E2E_CLOUD_BUSINESS_EMAIL_NODE != '' && env.E2E_CLOUD_BUSINESS_PASSWORD_NODE != ''
run: |
ZPAN_CLOUD_URL=https://zpan-cloud-staging.saltbo.workers.dev \
VITE_ZPAN_CLOUD_URL=https://zpan-cloud-staging.saltbo.workers.dev \
CLOUDFLARED_BIN=./cloudflared \
pnpm e2e:cloud -- --runtime node
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report-node
path: playwright-report/
retention-days: 7
e2e-cf:
name: E2E (CF Workers)
runs-on: ubuntu-latest
needs: check
env:
BETTER_AUTH_SECRET: ci-test-secret-that-is-at-least-32-chars
E2E_CLOUD_BUSINESS_EMAIL_CF: ${{ secrets.E2E_CLOUD_BUSINESS_EMAIL_CF }}
E2E_CLOUD_BUSINESS_PASSWORD_CF: ${{ secrets.E2E_CLOUD_BUSINESS_PASSWORD_CF }}
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Prepare local D1
run: pnpm exec wrangler d1 migrations apply DB --local
- name: Prepare CF E2E env
run: |
cat > .dev.vars <<'EOF'
BETTER_AUTH_SECRET=ci-test-secret-that-is-at-least-32-chars
BETTER_AUTH_URL=http://localhost:5185
TRUSTED_ORIGINS=http://localhost:5185
ZPAN_CLOUD_URL=https://zpan-cloud-staging.saltbo.workers.dev
VITE_ZPAN_CLOUD_URL=https://zpan-cloud-staging.saltbo.workers.dev
E2E_STORAGE_ENDPOINT=http://127.0.0.1:9191
E2E_STORAGE_BUCKET=e2e-test
E2E_STORAGE_REGION=auto
E2E_STORAGE_ACCESS_KEY=e2e-access-key
E2E_STORAGE_SECRET_KEY=e2e-secret-key
EOF
- name: Run E2E
run: |
E2E_RUNTIME=cf \
E2E_APP_PORT=5185 \
E2E_BASE_URL=http://localhost:5185 \
E2E_LOCAL_BASE_URL=http://localhost:5185 \
E2E_S3_MOCK=1 \
E2E_STORAGE_ENDPOINT=http://127.0.0.1:9191 \
E2E_STORAGE_BUCKET=e2e-test \
E2E_STORAGE_REGION=auto \
E2E_STORAGE_ACCESS_KEY=e2e-access-key \
E2E_STORAGE_SECRET_KEY=e2e-secret-key \
BETTER_AUTH_URL=http://localhost:5185 \
TRUSTED_ORIGINS=http://localhost:5185 \
pnpm e2e --project=desktop --grep-invert "Cloud store|Cloud licensing|Archive jobs|Site announcements"
- name: Install cloudflared
if: env.E2E_CLOUD_BUSINESS_EMAIL_CF != '' && env.E2E_CLOUD_BUSINESS_PASSWORD_CF != ''
run: |
curl -L --fail --output cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
chmod +x cloudflared
- name: Run cloud E2E
if: env.E2E_CLOUD_BUSINESS_EMAIL_CF != '' && env.E2E_CLOUD_BUSINESS_PASSWORD_CF != ''
run: |
ZPAN_CLOUD_URL=https://zpan-cloud-staging.saltbo.workers.dev \
VITE_ZPAN_CLOUD_URL=https://zpan-cloud-staging.saltbo.workers.dev \
CLOUDFLARED_BIN=./cloudflared \
pnpm e2e:cloud:cf
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report-cf
path: playwright-report/
retention-days: 7