-
Notifications
You must be signed in to change notification settings - Fork 50
419 lines (359 loc) · 13.3 KB
/
Copy pathci.yml
File metadata and controls
419 lines (359 loc) · 13.3 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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
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_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 pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: '.nvmrc'
- name: Detect changes
id: filter
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
with:
filters: |
kilocode_backend:
- 'apps/web/src/**'
- 'apps/web/.env'
- 'apps/web/.env.test'
- 'apps/web/.env.development.local.example'
- '.env.local.example'
- 'apps/web/package.json'
- 'apps/web/tsconfig.json'
- 'apps/web/tsconfig.*.json'
- 'apps/web/next.config.mjs'
- 'apps/web/jest.config.ts'
- 'apps/web/postcss.config.mjs'
- 'apps/web/sentry.*'
- 'packages/db/**'
- 'packages/encryption/**'
- 'packages/trpc/**'
- 'packages/worker-utils/**'
- 'services/deploy-infra/builder/**'
- 'package.json'
- 'pnpm-lock.yaml'
cloud_agent_next:
- 'services/cloud-agent-next/**'
- name: Detect changed workspaces with tests
id: workspaces
run: |
matrix=$(scripts/changed-workspaces.sh --exclude services/cloud-agent-next --exclude apps/web)
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-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Plugin shared-schemas sync check
run: bash scripts/sync-plugin-shared.sh --check
- name: Plugin openclaw peer-dep pin check
run: bash scripts/check-plugin-openclaw-pin.sh
- 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-file: '.nvmrc'
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-file: '.nvmrc'
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-file: '.nvmrc'
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
redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis-http:
image: hiett/serverless-redis-http:0.0.10
env:
SRH_MODE: env
SRH_TOKEN: example_token
SRH_CONNECTION_STRING: redis://redis:6379
options: >-
--health-cmd "wget -qO- http://127.0.0.1:80/ >/dev/null || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 8079:80
env:
NODE_ENV: test
POSTGRES_URL: postgresql://postgres:postgres@localhost:5432/postgres
POSTGRES_CONNECT_TIMEOUT: 30000
POSTGRES_MAX_QUERY_TIME: 30000
UPSTASH_REDIS_REST_URL: http://localhost:8079
UPSTASH_REDIS_REST_TOKEN: example_token
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-file: '.nvmrc'
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
- name: Run builder Postgres repository tests
run: pnpm --filter kilo-deploy-builder test:postgres
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-file: '.nvmrc'
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 }}/apps/web/.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 dummy build env
working-directory: apps/web
run: cp .env.test .env.production.local
- name: Build application
env:
NODE_ENV: production
VERCEL_ENV: production
NEXTAUTH_URL: https://ci-build.invalid
POSTGRES_URL: postgres://unused:unused@localhost:5432/unused
UPSTASH_REDIS_REST_URL: https://redis.test.invalid
UPSTASH_REDIS_REST_TOKEN: dummy-test-redis-token
SENTRY_AUTH_TOKEN: ''
NODE_OPTIONS: '--max-old-space-size=8192'
run: pnpm run build
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-file: '.nvmrc'
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: services/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-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm --filter ${{ matrix.workspace.name }} test
notify-main-failure:
if: ${{ always() && github.ref == 'refs/heads/main' && contains(join(needs.*.result, ','), 'failure') }}
needs:
[typecheck, lint, format-check, drizzle-check, test, build, cloud-agent-next, workspace-tests]
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
timeout-minutes: 5
steps:
- name: Notify Slack
continue-on-error: true
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
webhook: ${{ secrets.DEPLOY_NOTIFY_SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":red_circle: CI failed on main"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Commit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|`${{ github.sha }}`>"
},
{
"type": "mrkdwn",
"text": "*Author:*\n${{ github.actor }}"
}
]
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow run>"
}
]
}
]
}