Skip to content

Commit 16dd0ee

Browse files
committed
ci: install Bun and run build before tests
The Bun migration requires Bun to compile TypeScript to Node.js-compatible JavaScript. Update all CI jobs to: - Install Bun via curl - Run `bun install && bun run build` to create dist/ folder - Tests and e2e scripts can then use the compiled JS with Node.js The published npm package still works with Node.js only - Bun is only needed at build time.
1 parent 6b69726 commit 16dd0ee

1 file changed

Lines changed: 39 additions & 16 deletions

File tree

.gitlab-ci.yml

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,12 @@ cli:node:smoke:
170170
GIT_STRATEGY: fetch
171171
before_script:
172172
- corepack enable || true
173+
- apk add --no-cache bash curl unzip
174+
- curl -fsSL https://bun.sh/install | bash
175+
- export BUN_INSTALL="$HOME/.bun" && export PATH="$BUN_INSTALL/bin:$PATH"
173176
script:
174-
- node -v && npm -v
175-
- npm --prefix cli install --no-audit --no-fund
177+
- node -v && npm -v && bun --version
178+
- cd cli && bun install && bun run build && cd ..
176179
- node ./cli/dist/bin/postgres-ai.js --help
177180
- node ./cli/dist/bin/postgres-ai.js mon status --help
178181
- node ./cli/dist/bin/postgres-ai.js mon targets list --help
@@ -203,13 +206,18 @@ cli:node:tests:
203206
before_script:
204207
- corepack enable || true
205208
- apt-get update
206-
- apt-get install -y --no-install-recommends postgresql postgresql-client && rm -rf /var/lib/apt/lists/*
209+
- apt-get install -y --no-install-recommends postgresql postgresql-client unzip && rm -rf /var/lib/apt/lists/*
210+
# Install Bun
211+
- curl -fsSL https://bun.sh/install | bash
212+
- export BUN_INSTALL="$HOME/.bun" && export PATH="$BUN_INSTALL/bin:$PATH"
207213
# initdb refuses to run as root; run CLI tests as an unprivileged user
208214
- useradd -m -s /bin/bash pgtest || true
209215
- chown -R pgtest:pgtest "$CI_PROJECT_DIR"
210-
- su - pgtest -c "cd \"$CI_PROJECT_DIR\" && node -v && npm -v && npm --prefix cli ci"
216+
# Install Bun for pgtest user
217+
- su - pgtest -c "curl -fsSL https://bun.sh/install | bash"
218+
- su - pgtest -c "cd \"$CI_PROJECT_DIR/cli\" && export PATH=\"\$HOME/.bun/bin:\$PATH\" && bun install"
211219
script:
212-
- su - pgtest -c "cd \"$CI_PROJECT_DIR\" && npm --prefix cli test"
220+
- su - pgtest -c "cd \"$CI_PROJECT_DIR/cli\" && export PATH=\"\$HOME/.bun/bin:\$PATH\" && bun test"
213221
rules:
214222
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
215223

@@ -222,7 +230,10 @@ cli:npm:publish:
222230
NPM_CONFIG_FUND: "false"
223231
before_script:
224232
- corepack enable || true
225-
- node -v && npm -v
233+
# Install Bun for build step
234+
- curl -fsSL https://bun.sh/install | bash
235+
- export BUN_INSTALL="$HOME/.bun" && export PATH="$BUN_INSTALL/bin:$PATH"
236+
- node -v && npm -v && bun --version
226237
script:
227238
- |
228239
set -euo pipefail
@@ -260,10 +271,12 @@ cli:npm:publish:
260271
261272
echo "Publishing postgresai@${NPM_VERSION} to dist-tag ${DIST_TAG}"
262273
cd cli
263-
npm ci --no-audit --no-fund
274+
# Use bun for faster install and build
275+
export BUN_INSTALL="$HOME/.bun" && export PATH="$BUN_INSTALL/bin:$PATH"
276+
bun install
264277
# Make the git tag the source of truth without committing version bumps.
265278
npm version --no-git-tag-version "$NPM_VERSION"
266-
npm run build
279+
bun run build
267280
npm publish --dry-run --tag "$DIST_TAG" --access public
268281
npm publish --tag "$DIST_TAG" --access public
269282
@@ -399,9 +412,12 @@ cli:node:e2e:dind:
399412
PGAI_TAG: ${CI_COMMIT_REF_SLUG}
400413
before_script:
401414
- corepack enable || true
402-
- apk add --no-cache bash docker-cli docker-compose openssl postgresql-client
403-
- node -v && npm -v && docker version
404-
- npm --prefix cli install --no-audit --no-fund
415+
- apk add --no-cache bash curl unzip docker-cli docker-compose openssl postgresql-client
416+
# Install Bun
417+
- curl -fsSL https://bun.sh/install | bash
418+
- export BUN_INSTALL="$HOME/.bun" && export PATH="$BUN_INSTALL/bin:$PATH"
419+
- node -v && npm -v && bun --version && docker version
420+
- cd cli && bun install && bun run build && cd ..
405421
# Pull images from GitLab Container Registry
406422
- echo "$CI_REGISTRY_PASSWORD" | docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" --password-stdin
407423
- |
@@ -440,9 +456,12 @@ cli:node:full:dind:
440456
PGAI_TAG: ${CI_COMMIT_REF_SLUG}
441457
before_script:
442458
- corepack enable || true
443-
- apk add --no-cache bash git docker-cli docker-compose openssl postgresql-client
444-
- node -v && npm -v && docker version
445-
- npm --prefix cli install --no-audit --no-fund
459+
- apk add --no-cache bash curl unzip git docker-cli docker-compose openssl postgresql-client
460+
# Install Bun
461+
- curl -fsSL https://bun.sh/install | bash
462+
- export BUN_INSTALL="$HOME/.bun" && export PATH="$BUN_INSTALL/bin:$PATH"
463+
- node -v && npm -v && bun --version && docker version
464+
- cd cli && bun install && bun run build && cd ..
446465
# Pull images from GitLab Container Registry
447466
- echo "$CI_REGISTRY_PASSWORD" | docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" --password-stdin
448467
- |
@@ -490,8 +509,12 @@ cli:node:integration:
490509
GIT_STRATEGY: fetch
491510
before_script:
492511
- corepack enable || true
493-
- node -v && npm -v
494-
- npm --prefix cli install --no-audit --no-fund
512+
- apk add --no-cache bash curl unzip
513+
# Install Bun
514+
- curl -fsSL https://bun.sh/install | bash
515+
- export BUN_INSTALL="$HOME/.bun" && export PATH="$BUN_INSTALL/bin:$PATH"
516+
- node -v && npm -v && bun --version
517+
- cd cli && bun install && bun run build && cd ..
495518
script:
496519
- |
497520
set -euo pipefail

0 commit comments

Comments
 (0)