-
Notifications
You must be signed in to change notification settings - Fork 18
201 lines (172 loc) · 6.84 KB
/
Copy pathci.yml
File metadata and controls
201 lines (172 loc) · 6.84 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
# BitTorrented.com CI Pipeline
# Enforces TDD with mandatory test passing
# Deployment is handled by DigitalOcean App Platform (auto-deploy on push)
name: CI Pipeline
on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master, develop]
env:
NODE_VERSION: '24'
# Run the action SDKs themselves (actions/checkout, actions/setup-node, etc.)
# on Node 24 instead of their bundled Node 20. Silences the deprecation
# warnings until those actions ship v5 releases.
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
jobs:
# Job 1: Lint and Type Check
lint:
name: Lint & Type Check
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
# Version is read from package.json "packageManager" field
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
NODE_ENV: development
- name: Run ESLint
run: pnpm lint
- name: Run TypeScript type check
run: pnpm tsc --noEmit
# Job 2: Run Tests (MANDATORY - blocks deployment)
test:
name: Run Tests
runs-on: ubuntu-latest
timeout-minutes: 25
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
# Version is read from package.json "packageManager" field
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
# ffmpeg install is the single most common red build in this repo, and it
# has never once been about the change under test. It fails the whole CI
# Pipeline, and the droplet deploy triggers on that -- so an unrelated flake
# silently stops bittorrented.com deploying at all.
#
# Two independent paths, because each one alone has broken a deploy.
#
# The distro mirror stalls; and this action resolves `release` by scraping a
# version out of an upstream readme, which failed with "Failed to read
# version from readme" and took the droplet deploy down with it. Neither
# failure has anything to do with the change being tested.
#
# So: try the prebuilt binary, fall back to apt, then assert ffmpeg is
# actually there. A flake in one path no longer stops a deploy, and losing
# both still fails loudly rather than running tests that spawn ENOENT.
- name: Install ffmpeg
id: ffmpeg
uses: FedericoCarboni/setup-ffmpeg@v3
continue-on-error: true
- name: Install ffmpeg (fallback)
if: steps.ffmpeg.outcome != 'success'
run: |
command -v ffmpeg >/dev/null && exit 0
sudo apt-get update && sudo apt-get install -y ffmpeg
- name: Verify ffmpeg
run: ffmpeg -version
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
NODE_ENV: development
- name: Run Vitest tests
run: pnpm test
env:
NODE_ENV: test
REDIS_URL: redis://localhost:6379
SUPABASE_URL: ${{ secrets.SUPABASE_URL || 'https://test.supabase.co' }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlRlc3QiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlRlc3QiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' }}
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL || 'https://test.supabase.co' }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlRlc3QiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' }}
- name: Upload coverage report
uses: codecov/codecov-action@v7
if: always()
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
# Job 3: Build Application
build:
name: Build Application
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [lint, test]
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
# Version is read from package.json "packageManager" field
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
NODE_ENV: development
- name: Build application
run: pnpm build
env:
NODE_ENV: production
SUPABASE_URL: ${{ secrets.SUPABASE_URL || 'https://test.supabase.co' }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlRlc3QiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' }}
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL || 'https://test.supabase.co' }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlRlc3QiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' }}
- name: Upload build artifacts
uses: actions/upload-artifact@v7
if: success()
with:
name: build-output
path: .next
retention-days: 7
if-no-files-found: ignore
# Job 4: Security Audit
security:
name: Security Audit
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
# Version is read from package.json "packageManager" field
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
NODE_ENV: development
- name: Run security audit
run: pnpm audit --audit-level=critical || true
continue-on-error: true