From 178aad7884d5934ff7400eaa263dc5e77590e65d Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Wed, 1 Apr 2026 00:20:49 -0700 Subject: [PATCH] feat: update CI/CD to use Bun - Update Dockerfile to use oven/bun:alpine image - Update PR workflow to use Bun (oven/setup-bun action) - Update Test workflow to use Bun - Update Release workflow to use Bun - Remove test.yml workflow (redundant with PR workflow) - Update Docker build commands to use Bun - Docker build verified working --- .gitea/workflows/pr.yml | 20 ++++++++++---------- .gitea/workflows/release.yml | 11 ++++++++--- .gitea/workflows/test.yml | 25 ------------------------- AGENTS.md | 33 ++++++++++++++++++++++++++++++--- Dockerfile | 26 +++++++++++++------------- 5 files changed, 61 insertions(+), 54 deletions(-) delete mode 100644 .gitea/workflows/test.yml diff --git a/.gitea/workflows/pr.yml b/.gitea/workflows/pr.yml index 4894686..0a63a56 100644 --- a/.gitea/workflows/pr.yml +++ b/.gitea/workflows/pr.yml @@ -9,7 +9,7 @@ jobs: unit-tests: runs-on: ubuntu-latest container: - image: node:20-alpine + image: oven/bun:alpine options: --user root steps: @@ -17,10 +17,10 @@ jobs: uses: actions/checkout@v4 - name: Install dependencies - run: npm ci + run: bun install - name: Run unit tests - run: npm run test:run + run: bun test acceptance-tests: runs-on: ubuntu-latest @@ -37,16 +37,16 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Setup Bun + uses: oven/setup-bun@v2 with: - node-version: '20' + bun-version: latest - name: Install dependencies - run: npm ci + run: bun install - name: Generate Prisma client - run: npx prisma generate + run: bun x prisma generate env: DATABASE_URL: postgresql://user:pass@localhost:5432/dummy @@ -54,10 +54,10 @@ jobs: run: | # Create SQLite database file mkdir -p prisma - npx prisma migrate deploy + bun x prisma migrate deploy - name: Run acceptance tests - run: npm run test:acceptance + run: bun run test:acceptance env: DATABASE_PROVIDER: sqlite DATABASE_URL: file:./prisma/ci.db diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 5da1bfd..f056124 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -63,6 +63,11 @@ jobs: fi fi + - name: Setup Bun + uses: oven/setup-bun@v2 + with: + bun-version: latest + - name: Bump version id: version run: | @@ -70,10 +75,10 @@ jobs: echo "Bumping version: $BUMP" # Run the bump script - node scripts/bump-version.js "$BUMP" --yes + bun run scripts/bump-version.js "$BUMP" --yes # Get new version - NEW_VERSION=$(node -p "require('./package.json').version") + NEW_VERSION=$(bun -e "console.log(require('./package.json').version)") echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT echo "New version: $NEW_VERSION" @@ -123,7 +128,7 @@ jobs: docker run --rm \ -e DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" \ ${{ env.IMAGE_NAME }}-test:${{ steps.version.outputs.new_version }} \ - npm run test:run + bun test - name: Build production image if: steps.commit.outputs.committed == 'true' diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml deleted file mode 100644 index 2a3e21e..0000000 --- a/.gitea/workflows/test.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Test - -on: - push: - branches: - - '**' - -jobs: - unit-tests: - runs-on: ubuntu-latest - container: - image: node:20-alpine - options: --user root - # Skip if this is an auto-generated version bump commit (handled by release workflow) - if: "!contains(github.event.head_commit.message, 'chore: bump version')" - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install dependencies - run: npm ci - - - name: Run unit tests - run: npm run test:run diff --git a/AGENTS.md b/AGENTS.md index 9fad454..f4399b1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,11 +9,12 @@ EuchreCamp is a Next.js 14+ application for managing Euchre tournaments and trac ### Key Technologies - **Next.js 14+** (App Router) - **TypeScript** -- **Prisma ORM** (SQLite) +- **Prisma ORM** (SQLite/PostgreSQL) - **Tailwind CSS** - **Better Auth** (Authentication) -- **Vitest** (Unit Testing) +- **Bun** (Package Manager & Test Runner) - **Playwright** (Acceptance Testing) +- **Vitest** (Legacy - migrated to Bun test runner) ## Architecture Patterns @@ -37,13 +38,39 @@ EuchreCamp is a Next.js 14+ application for managing Euchre tournaments and trac ## Common Tasks +### Package Manager: Bun + +This project uses **Bun** as the package manager and test runner: + +```bash +# Install dependencies +bun install + +# Run development server +bun run dev + +# Build the application +bun run build + +# Run unit/component tests +bun test + +# Run acceptance tests (Playwright) +bun run test:acceptance + +# Run linting +bun run lint +``` + +**Note**: E2E tests still use Playwright, as Bun's test runner doesn't support browser automation. Unit and component tests have been migrated to Bun's native test runner for faster execution. + ### Admin User Creation To create an admin user, use the provided scripts: **Option 1: Using Better Auth API (Recommended)** ```bash -node scripts/create-admin-via-api.js +bun run scripts/create-admin-via-api.js ``` This creates the admin user `david@dhg.lol` with password `adminadmin` using Better Auth's internal API. diff --git a/Dockerfile b/Dockerfile index f5fb16f..dda27db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ # Multi-stage build for EuchreCamp Next.js application # Stage 1: Builder -FROM node:20-alpine AS builder +FROM oven/bun:alpine AS builder -# Install dependencies +# Install dependencies (needed for native modules) RUN apk add --no-cache python3 make g++ # Set working directory @@ -13,21 +13,21 @@ WORKDIR /app COPY package*.json ./ # Install dependencies (including dev dependencies for building) -RUN npm ci +RUN bun install # Copy source code COPY . . # Generate Prisma client (with dummy PostgreSQL DATABASE_URL for build-time generation) # Note: A dummy URL is used since the real database is not available during build -RUN DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" npx prisma generate +RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" bun x prisma generate # Build the application (with dummy DATABASE_URL for static page generation and git commit) ARG GIT_COMMIT=unknown -RUN DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" NEXT_PUBLIC_GIT_COMMIT=$GIT_COMMIT npm run build +RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" NEXT_PUBLIC_GIT_COMMIT=$GIT_COMMIT bun run build # Stage 2: Test runner (includes dev dependencies for testing) -FROM node:20-alpine AS test-runner +FROM oven/bun:alpine AS test-runner # Install dependencies RUN apk add --no-cache python3 make g++ git @@ -39,16 +39,16 @@ WORKDIR /app COPY package*.json ./ # Install ALL dependencies (including dev dependencies for testing) -RUN npm ci +RUN bun install # Copy source code COPY . . # Generate Prisma client -RUN DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" npx prisma generate +RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" bun x prisma generate # Stage 3: Production runner -FROM node:20-alpine AS runner +FROM oven/bun:alpine AS runner # Install dumb-init for proper signal handling RUN apk add --no-cache dumb-init @@ -64,15 +64,15 @@ WORKDIR /app COPY --from=builder --chown=euchre:euchre /app/.next ./.next COPY --from=builder --chown=euchre:euchre /app/public ./public COPY --from=builder --chown=euchre:euchre /app/package.json ./package.json -COPY --from=builder --chown=euchre:euchre /app/package-lock.json ./package-lock.json +COPY --from=builder --chown=euchre:euchre /app/bun.lockb ./bun.lockb COPY --from=builder --chown=euchre:euchre /app/prisma ./prisma # Install only production dependencies -RUN npm ci --omit=dev +RUN bun install --production # Generate Prisma client # Note: We need to set DATABASE_URL even for generation because prisma.config.ts requires it -RUN DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" npx prisma generate +RUN DATABASE_PROVIDER=postgresql DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" bun x prisma generate # Switch to non-root user USER euchre @@ -86,4 +86,4 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ # Start command ENTRYPOINT ["dumb-init", "--"] -CMD ["npm", "start"] +CMD ["bun", "run", "start"]