-
Notifications
You must be signed in to change notification settings - Fork 30
366 lines (303 loc) · 11.1 KB
/
ci.yml
File metadata and controls
366 lines (303 loc) · 11.1 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Cancel in-progress runs when a new commit is pushed to the same PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
# Optional repo/org variables for runner migration:
# - RUNNER_DEFAULT_LABEL=blacksmith-2vcpu-ubuntu-2404
# - RUNNER_LARGE_LABEL=blacksmith-8vcpu-ubuntu-2404
jobs:
changes:
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
timeout-minutes: 5
outputs:
kilocode_backend: ${{ steps.filter.outputs.kilocode_backend }}
cloud_agent: ${{ steps.filter.outputs.cloud_agent }}
cloud_agent_next: ${{ steps.filter.outputs.cloud_agent_next }}
workspace_matrix: ${{ steps.workspaces.outputs.matrix }}
steps:
- uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
- name: Detect changes
id: filter
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
with:
filters: |
kilocode_backend:
- 'src/**'
- 'packages/db/**'
- 'packages/encryption/**'
- 'packages/trpc/**'
- 'packages/worker-utils/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'tsconfig.json'
- 'tsconfig.*.json'
- 'next.config.mjs'
- 'jest.config.ts'
- 'postcss.config.mjs'
- 'sentry.*'
cloud_agent:
- 'cloud-agent/**'
cloud_agent_next:
- 'cloud-agent-next/**'
- name: Detect changed workspaces with tests
id: workspaces
run: |
matrix=$(scripts/changed-workspaces.sh --exclude cloud-agent --exclude cloud-agent-next)
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
typecheck:
needs: changes
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
timeout-minutes: 15
steps:
- uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
with:
lfs: true
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Typecheck
run: scripts/typecheck-all.sh
lint:
needs: changes
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
timeout-minutes: 15
steps:
- uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
with:
lfs: true
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build trpc types
run: pnpm --filter @kilocode/trpc run build
- name: Lint
run: scripts/lint-all.sh
format-check:
needs: changes
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
timeout-minutes: 15
steps:
- uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
with:
lfs: true
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Format check
run: |
pnpm run format:check || {
echo "::error::oxfmt formatting check failed. Please run 'pnpm run format' locally and commit the changes before pushing."
exit 1
}
drizzle-check:
needs: changes
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
timeout-minutes: 15
steps:
- uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
with:
lfs: true
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Drizzle check
run: pnpm drizzle check
env:
POSTGRES_URL: postgresql://unused:unused@localhost:5432/unused
test:
needs: [changes, typecheck, lint, format-check, drizzle-check]
if: needs.changes.outputs.kilocode_backend == 'true'
runs-on: ${{ vars.RUNNER_LARGE_LABEL || 'ubuntu-24.04-8core' }}
timeout-minutes: 30
services:
postgres:
image: pgvector/pgvector:pg16
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
NODE_ENV: test
POSTGRES_URL: postgresql://postgres:postgres@localhost:5432/postgres
POSTGRES_CONNECT_TIMEOUT: 30000
POSTGRES_MAX_QUERY_TIME: 30000
JEST_MAX_WORKERS: 4
steps:
- uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
with:
lfs: true
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Dependency cycle check
run: pnpm run dependency-cycle-check
- name: Run tests
run: pnpm run test
build:
needs: [changes, typecheck, lint, format-check, drizzle-check]
if: needs.changes.outputs.kilocode_backend == 'true'
runs-on: ${{ vars.RUNNER_LARGE_LABEL || 'ubuntu-24.04-8core' }}
timeout-minutes: 30
steps:
- uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
with:
lfs: true
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Cache Next.js build
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: Setup Vercel ENV
run: |
pnpm install --global vercel@latest
vercel link --project=kilocode-app --token=${{ secrets.VERCEL_TOKEN }} --yes
vercel env pull .env.production.local --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build application
env:
NODE_ENV: production
SENTRY_AUTH_TOKEN: ''
NODE_OPTIONS: '--max-old-space-size=8192'
run: pnpm run build
cloud-agent:
needs: [changes, typecheck, lint, format-check, drizzle-check]
if: needs.changes.outputs.cloud_agent == 'true'
runs-on: ${{ vars.RUNNER_LARGE_LABEL || 'ubuntu-24.04-8core' }}
timeout-minutes: 15
steps:
- uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
with:
lfs: true
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
cache: 'pnpm'
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build wrapper bundle
working-directory: cloud-agent/wrapper
run: bun run build.ts
- name: Run cloud-agent tests
run: pnpm --filter cloud-agent test:all
cloud-agent-next:
needs: [changes, typecheck, lint, format-check, drizzle-check]
if: needs.changes.outputs.cloud_agent_next == 'true'
runs-on: ${{ vars.RUNNER_LARGE_LABEL || 'ubuntu-24.04-8core' }}
timeout-minutes: 15
steps:
- uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
with:
lfs: true
ref: ${{ github.head_ref }}
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
cache: 'pnpm'
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build wrapper bundle
working-directory: cloud-agent-next/wrapper
run: bun run build.ts
- name: Run cloud-agent-next tests
run: pnpm --filter cloud-agent-next test:all
workspace-tests:
needs: [changes, typecheck, lint, format-check, drizzle-check]
if: ${{ needs.changes.outputs.workspace_matrix != '[]' }}
strategy:
fail-fast: false
matrix:
workspace: ${{ fromJson(needs.changes.outputs.workspace_matrix) }}
name: test (${{ matrix.workspace.name }})
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
timeout-minutes: 15
steps:
- uses: useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b # v1
with:
lfs: true
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm --filter ${{ matrix.workspace.name }} test