Files
zpan/.github/workflows/ci.yml
T
2026-06-08 14:08:32 -04:00

191 lines
6.7 KiB
YAML

name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
E2E_CLOUD_PRO_EMAIL: ${{ secrets.E2E_CLOUD_PRO_EMAIL }}
E2E_CLOUD_PRO_PASSWORD: ${{ secrets.E2E_CLOUD_PRO_PASSWORD }}
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
- run: go test ./...
- 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 ./internal/engine -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 typecheck
- run: pnpm openapi:downloader: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
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|Archive jobs|Site announcements"
- name: Install cloudflared
run: |
curl -L --fail --output cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
chmod +x cloudflared
- name: Run cloud E2E
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|Archive jobs|Site announcements"
- name: Install cloudflared
run: |
curl -L --fail --output cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
chmod +x cloudflared
- name: Run cloud E2E
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