-
Notifications
You must be signed in to change notification settings - Fork 15
528 lines (479 loc) · 20.3 KB
/
Copy pathbuild.yml
File metadata and controls
528 lines (479 loc) · 20.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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
name: Build and Test
env:
HUSKY: '0'
on:
workflow_call:
inputs:
node-version:
required: true
type: string
description: 'Node.js version to use'
secrets:
VITE_SENTRY_FRONTEND_DSN:
required: false
description: 'Sentry DSN for frontend monitoring (proprietary only)'
VITE_CRISP_WEBSITE_ID:
required: false
description: 'Crisp Website ID for chat support (proprietary only)'
outputs:
api-artifact:
description: 'API build artifact name'
value: ${{ jobs.build-api.outputs.artifact-name }}
frontend-artifact:
description: 'Frontend build artifact name'
value: ${{ jobs.build-frontend.outputs.artifact-name }}
mcp-server-artifact:
description: 'MCP Server build artifact name'
value: ${{ jobs.build-mcp-server.outputs.artifact-name }}
cli-artifact:
description: 'CLI build artifact name'
value: ${{ jobs.build-cli.outputs.artifact-name }}
cli-version:
description: 'CLI version'
value: ${{ jobs.build-cli.outputs.version }}
cli-executables-artifact:
description: 'CLI executables artifact name'
value: ${{ jobs.build-cli.outputs.cli-executables-artifact }}
standard-samples-artifact:
description: 'Standard samples artifact name'
value: ${{ jobs.build-packages.outputs.standard-samples-artifact }}
jobs:
build-api:
runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }}
timeout-minutes: ${{ github.actor == 'dependabot[bot]' && 15 || 30 }}
outputs:
artifact-name: api-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }}
strategy:
matrix:
node-version: ['${{ inputs.node-version }}']
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Cache pnpm supply-chain verification
uses: actions/cache@v4
with:
path: ~/.cache/pnpm
key: pnpm-verify-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
- run: pnpm install --frozen-lockfile --prefer-offline
- name: Generate tsconfig
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
run: node scripts/select-tsconfig.mjs
- name: Build API
env:
NODE_ENV: production
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
run: ./node_modules/.bin/nx build api
- name: Test API
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
run: ./node_modules/.bin/nx test api
- run: cp apps/api/docker-package.json dist/apps/api/.
- run: cp package.json dist/apps/api/.
- run: cp pnpm-lock.yaml dist/apps/api/.
- run: cp tsconfig.base.effective.json dist/apps/api/.
- name: Upload API build artifacts
uses: actions/upload-artifact@v4
with:
name: api-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }}
path: dist/apps/api/
build-frontend:
runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }}
timeout-minutes: ${{ github.actor == 'dependabot[bot]' && 15 || 30 }}
outputs:
artifact-name: frontend-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }}
strategy:
matrix:
node-version: ['${{ inputs.node-version }}']
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Cache pnpm supply-chain verification
uses: actions/cache@v4
with:
path: ~/.cache/pnpm
key: pnpm-verify-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
- run: pnpm install --frozen-lockfile --prefer-offline
- name: Generate tsconfig
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
run: node scripts/select-tsconfig.mjs
- name: Generate Chakra types
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
run: pnpm chakra:typegen
- name: Typechecks
run: pnpm typecheck:frontend
- name: Test Frontend
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
run: ./node_modules/.bin/nx test frontend
- name: Build frontend
env:
NODE_ENV: production
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
VITE_SENTRY_FRONTEND_DSN: ${{ vars.PACKMIND_EDITION == 'proprietary' && !startsWith(github.ref, 'refs/tags/release/') && secrets.VITE_SENTRY_FRONTEND_DSN || '' }}
VITE_SENTRY_ENVIRONMENT: ${{ vars.PACKMIND_EDITION == 'proprietary' && !startsWith(github.ref, 'refs/tags/release/') && 'production' || '' }}
VITE_CRISP_WEBSITE_ID: ${{ vars.PACKMIND_EDITION == 'proprietary' && !startsWith(github.ref, 'refs/tags/release/') && secrets.VITE_CRISP_WEBSITE_ID || '' }}
run: ./node_modules/.bin/nx build frontend
- run: cp tsconfig.base.effective.json apps/frontend/build/client/.
- name: Upload Frontend build artifacts
uses: actions/upload-artifact@v4
with:
name: frontend-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }}
path: apps/frontend/build/client
build-mcp-server:
runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }}
timeout-minutes: ${{ github.actor == 'dependabot[bot]' && 15 || 30 }}
outputs:
artifact-name: mcp-server-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }}
strategy:
matrix:
node-version: ['${{ inputs.node-version }}']
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Cache pnpm supply-chain verification
uses: actions/cache@v4
with:
path: ~/.cache/pnpm
key: pnpm-verify-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
- run: pnpm install --frozen-lockfile --prefer-offline
- name: Generate tsconfig
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
run: node scripts/select-tsconfig.mjs
- name: Build MCP Server
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
run: ./node_modules/.bin/nx build mcp-server
- name: Test MCP Server
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
run: ./node_modules/.bin/nx test mcp-server
- run: cp tsconfig.base.effective.json dist/apps/mcp-server/.
- run: cp pnpm-lock.yaml dist/apps/mcp-server/.
- name: Upload MCP-Server build artifacts
uses: actions/upload-artifact@v4
with:
name: mcp-server-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }}
path: dist/apps/mcp-server/
build-packages:
runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }}
timeout-minutes: ${{ github.actor == 'dependabot[bot]' && 15 || 30 }}
outputs:
standard-samples-artifact: standard-samples-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }}
strategy:
matrix:
node-version: ['${{ inputs.node-version }}']
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Cache pnpm supply-chain verification
uses: actions/cache@v4
with:
path: ~/.cache/pnpm
key: pnpm-verify-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
- run: pnpm install --frozen-lockfile --prefer-offline
- name: Generate tsconfig
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
run: node scripts/select-tsconfig.mjs
- name: Build packages
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
run: ./node_modules/.bin/nx run-many -t build -p packages/*
- name: Test packages
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
run: ./node_modules/.bin/nx run-many -t test -p packages/* --passWithNoTests
- name: Upload standard samples artifacts
uses: actions/upload-artifact@v4
with:
name: standard-samples-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }}
path: dist/packages/standards/samples/generated/
if-no-files-found: ignore
build-cli:
runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }}
timeout-minutes: ${{ github.actor == 'dependabot[bot]' && 15 || 30 }}
outputs:
artifact-name: cli-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }}
cli-executables-artifact: cli-executables-${{ steps.get-version.outputs.version }}
version: ${{ steps.get-version.outputs.version }}
strategy:
matrix:
node-version: ['${{ inputs.node-version }}']
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.11"
- name: Get package version
id: get-version
run: echo "version=$(node -p "require('./apps/cli/package.json').version")" >> $GITHUB_OUTPUT
- name: Cache pnpm supply-chain verification
uses: actions/cache@v4
with:
path: ~/.cache/pnpm
key: pnpm-verify-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
- run: pnpm install --frozen-lockfile --prefer-offline
- name: Generate tsconfig
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
run: node scripts/select-tsconfig.mjs
- name: Build CLI
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
run: ./node_modules/.bin/nx build-publish packmind-cli
- name: Test CLI
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
run: ./node_modules/.bin/nx test packmind-cli
- name: Upload CLI build artifacts
uses: actions/upload-artifact@v4
with:
name: cli-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }}
path: dist/apps/cli/
- name: Build CLI executables for all platforms
run: |
echo "📦 Building CLI executables with embedded WASM files..."
bun --version
bun run apps/cli/bun-build.ts --target=all
- name: List built executables
run: |
echo "Built executables (with embedded WASM files):"
ls -lh dist/apps/cli-executables/
- name: Install dist CLI runtime dependencies
run: sh scripts/install-dist-cli-deps.sh
- name: Test executables
run: |
node dist/apps/cli/main.cjs --version
./dist/apps/cli-executables/packmind-cli-linux-x64 --version
- name: Upload CLI executables
uses: actions/upload-artifact@v4
with:
name: cli-executables-${{ steps.get-version.outputs.version }}
path: |
dist/apps/cli-executables/packmind-cli-linux-x64
dist/apps/cli-executables/packmind-cli-linux-arm64
dist/apps/cli-executables/packmind-cli-macos-arm64
dist/apps/cli-executables/packmind-cli-windows-x64.exe
dist/apps/cli-executables/packmind-cli-windows-arm64.exe
retention-days: 30
cli-e2e-tests:
runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }}
timeout-minutes: 20
env:
PACKMIND_INSTANCE_URL: http://localhost:4200
strategy:
matrix:
node-version: ['${{ inputs.node-version }}']
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Cache pnpm supply-chain verification
uses: actions/cache@v4
with:
path: ~/.cache/pnpm
key: pnpm-verify-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
- run: pnpm install --frozen-lockfile --prefer-offline
- name: Generate tsconfig
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
run: node scripts/select-tsconfig.mjs
- run: ./node_modules/.bin/nx run packmind-cli:build
- name: Install dist CLI runtime dependencies
run: sh scripts/install-dist-cli-deps.sh
- name: Fix CLI artifacts permissions
run: |
chmod +x dist/apps/cli/main.cjs || true
chmod -R +r dist/apps/cli/
ls -la dist/apps/cli/
- name: Start docker compose for CLI E2E tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 15
max_attempts: 3
retry_wait_seconds: 10
command: |
echo "Starting docker compose with COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}"
echo "Docker version:"
docker --version
docker compose version
echo "Starting containers..."
docker compose up -d --wait --wait-timeout 300
echo "Docker compose up completed. Container status:"
docker compose ps -a
docker ps -a --format 'table {{.Names}}\t{{.Status}}'
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
COMPOSE_PROJECT_NAME: cli-e2e-${{ github.run_number }}
CI: 'true'
APP_WEB_URL: ${{ env.PACKMIND_INSTANCE_URL }}
- name: Wait for services to be ready
env:
COMPOSE_PROJECT_NAME: cli-e2e-${{ github.run_number }}
PACKMIND_INSTANCE_URL: ${{ env.PACKMIND_INSTANCE_URL }}
run: |
echo "Waiting for API to be ready..."
timeout 60 bash -c "until curl -f ${PACKMIND_INSTANCE_URL}/api/v0/healthcheck > /dev/null 2>&1; do sleep 2; done"
- name: Run CLI E2E tests
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384 --no-experimental-strip-types'
run: ./node_modules/.bin/nx test cli-e2e-tests
- name: Install latest production CLI from registry
run: |
PROD_CLI_DIR="$(mktemp -d)"
cd "${PROD_CLI_DIR}"
pnpm init
# Throwaway install: only need the CLI binary resolvable to run --version.
# bcrypt/msgpackr-extract ship prebuilt binaries, so their build scripts
# are not required. Disable strictDepBuilds (default true in pnpm 11) to
# avoid ERR_PNPM_IGNORED_BUILDS here where there is no allowBuilds config.
pnpm add @packmind/cli --config.strictDepBuilds=false
CLI_BINARY_PATH="$(node -e "console.log(require.resolve('@packmind/cli'))")"
cd -
echo "Installed CLI version: $(node "${CLI_BINARY_PATH}" --version)"
echo "CLI_BINARY_PATH=${CLI_BINARY_PATH}" >> $GITHUB_ENV
- name: Run CLI E2E tests against production CLI
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
NODE_OPTIONS: '--max-old-space-size=16384'
CLI_BINARY_PATH: ${{ env.CLI_BINARY_PATH }}
run: ./node_modules/.bin/nx test cli-e2e-tests --skip-nx-cache
- name: Collect Docker container logs
if: always()
env:
COMPOSE_PROJECT_NAME: cli-e2e-${{ github.run_number }}
run: |
mkdir -p docker-logs-cli-e2e
echo "Looking for containers with prefix: ${COMPOSE_PROJECT_NAME}"
docker ps -a --format '{{.Names}}' | grep "^${COMPOSE_PROJECT_NAME}" || echo "No containers found"
for container in $(docker ps -a --format '{{.Names}}' | grep "^${COMPOSE_PROJECT_NAME}" || true); do
echo "Collecting logs for $container..."
docker logs "$container" > "docker-logs-cli-e2e/${container}.log" 2>&1 || true
done
echo "Collected logs:"
ls -la docker-logs-cli-e2e/ || echo "No logs collected"
- name: Upload Docker logs
if: always()
uses: actions/upload-artifact@v4
with:
name: docker-logs-cli-e2e-${{ github.run_number }}-${{ github.sha }}
path: docker-logs-cli-e2e/
if-no-files-found: ignore
- name: Cleanup Docker containers
if: always()
env:
COMPOSE_PROJECT_NAME: cli-e2e-${{ github.run_number }}
run: docker compose down -v --remove-orphans
e2e-tests:
runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }}
timeout-minutes: 15
strategy:
matrix:
node-version: ['${{ inputs.node-version }}']
steps:
- uses: actions/checkout@v4
- name: Start E2E test environment
uses: nick-fields/retry@v3
with:
timeout_minutes: 15
max_attempts: 3
retry_wait_seconds: 10
command: |
echo "Starting docker compose with COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}"
echo "Docker version:"
docker --version
docker compose version
echo "Starting containers..."
docker compose --profile=e2e up -d --wait-timeout 300
echo "Docker compose up completed. Container status:"
docker compose --profile=e2e ps -a
docker ps -a --format 'table {{.Names}}\t{{.Status}}'
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
COMPOSE_PROJECT_NAME: ci-${{ github.run_number }}
CI: 'true'
APP_WEB_URL: http://frontend:4200
- name: Wait for E2E tests to complete
env:
PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }}
COMPOSE_PROJECT_NAME: ci-${{ github.run_number }}
run: ./scripts/wait-for-e2e-tests.sh
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report-${{ github.run_number }}-${{ github.sha }}
path: apps/e2e-tests/playwright-report/
if-no-files-found: ignore
- name: Collect Docker container logs
if: always()
env:
COMPOSE_PROJECT_NAME: ci-${{ github.run_number }}
run: |
mkdir -p docker-logs
echo "Looking for containers with prefix: ${COMPOSE_PROJECT_NAME}"
docker ps -a --format '{{.Names}}' | grep "^${COMPOSE_PROJECT_NAME}" || echo "No containers found"
for container in $(docker ps -a --format '{{.Names}}' | grep "^${COMPOSE_PROJECT_NAME}" || true); do
echo "Collecting logs for $container..."
docker logs "$container" > "docker-logs/${container}.log" 2>&1 || true
done
echo "Collected logs:"
ls -la docker-logs/ || echo "No logs collected"
- name: Upload Docker logs
if: always()
uses: actions/upload-artifact@v4
with:
name: docker-logs-${{ github.run_number }}-${{ github.sha }}
path: docker-logs/
if-no-files-found: ignore
- name: Cleanup Docker containers
if: always()
env:
COMPOSE_PROJECT_NAME: ci-${{ github.run_number }}
run: docker compose --profile=e2e down -v --remove-orphans