1 Commits

Author SHA1 Message Date
david 178aad7884 feat: update CI/CD to use Bun
Pull Request / unit-tests (pull_request) Failing after 1m25s
Pull Request / acceptance-tests (pull_request) Has been skipped
Pull Request / analyze-bump-type (pull_request) Has been skipped
- 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
2026-04-01 00:20:49 -07:00
5 changed files with 61 additions and 54 deletions
+10 -10
View File
@@ -9,7 +9,7 @@ jobs:
unit-tests: unit-tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: node:20-alpine image: oven/bun:alpine
options: --user root options: --user root
steps: steps:
@@ -17,10 +17,10 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install dependencies - name: Install dependencies
run: npm ci run: bun install
- name: Run unit tests - name: Run unit tests
run: npm run test:run run: bun test
acceptance-tests: acceptance-tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -37,16 +37,16 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Node.js - name: Setup Bun
uses: actions/setup-node@v4 uses: oven/setup-bun@v2
with: with:
node-version: '20' bun-version: latest
- name: Install dependencies - name: Install dependencies
run: npm ci run: bun install
- name: Generate Prisma client - name: Generate Prisma client
run: npx prisma generate run: bun x prisma generate
env: env:
DATABASE_URL: postgresql://user:pass@localhost:5432/dummy DATABASE_URL: postgresql://user:pass@localhost:5432/dummy
@@ -54,10 +54,10 @@ jobs:
run: | run: |
# Create SQLite database file # Create SQLite database file
mkdir -p prisma mkdir -p prisma
npx prisma migrate deploy bun x prisma migrate deploy
- name: Run acceptance tests - name: Run acceptance tests
run: npm run test:acceptance run: bun run test:acceptance
env: env:
DATABASE_PROVIDER: sqlite DATABASE_PROVIDER: sqlite
DATABASE_URL: file:./prisma/ci.db DATABASE_URL: file:./prisma/ci.db
+8 -3
View File
@@ -63,6 +63,11 @@ jobs:
fi fi
fi fi
- name: Setup Bun
uses: oven/setup-bun@v2
with:
bun-version: latest
- name: Bump version - name: Bump version
id: version id: version
run: | run: |
@@ -70,10 +75,10 @@ jobs:
echo "Bumping version: $BUMP" echo "Bumping version: $BUMP"
# Run the bump script # Run the bump script
node scripts/bump-version.js "$BUMP" --yes bun run scripts/bump-version.js "$BUMP" --yes
# Get new version # 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" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION" echo "New version: $NEW_VERSION"
@@ -123,7 +128,7 @@ jobs:
docker run --rm \ docker run --rm \
-e DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" \ -e DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" \
${{ env.IMAGE_NAME }}-test:${{ steps.version.outputs.new_version }} \ ${{ env.IMAGE_NAME }}-test:${{ steps.version.outputs.new_version }} \
npm run test:run bun test
- name: Build production image - name: Build production image
if: steps.commit.outputs.committed == 'true' if: steps.commit.outputs.committed == 'true'
-25
View File
@@ -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
+30 -3
View File
@@ -9,11 +9,12 @@ EuchreCamp is a Next.js 14+ application for managing Euchre tournaments and trac
### Key Technologies ### Key Technologies
- **Next.js 14+** (App Router) - **Next.js 14+** (App Router)
- **TypeScript** - **TypeScript**
- **Prisma ORM** (SQLite) - **Prisma ORM** (SQLite/PostgreSQL)
- **Tailwind CSS** - **Tailwind CSS**
- **Better Auth** (Authentication) - **Better Auth** (Authentication)
- **Vitest** (Unit Testing) - **Bun** (Package Manager & Test Runner)
- **Playwright** (Acceptance Testing) - **Playwright** (Acceptance Testing)
- **Vitest** (Legacy - migrated to Bun test runner)
## Architecture Patterns ## Architecture Patterns
@@ -37,13 +38,39 @@ EuchreCamp is a Next.js 14+ application for managing Euchre tournaments and trac
## Common Tasks ## 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 ### Admin User Creation
To create an admin user, use the provided scripts: To create an admin user, use the provided scripts:
**Option 1: Using Better Auth API (Recommended)** **Option 1: Using Better Auth API (Recommended)**
```bash ```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. This creates the admin user `david@dhg.lol` with password `adminadmin` using Better Auth's internal API.
+13 -13
View File
@@ -1,9 +1,9 @@
# Multi-stage build for EuchreCamp Next.js application # Multi-stage build for EuchreCamp Next.js application
# Stage 1: Builder # 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++ RUN apk add --no-cache python3 make g++
# Set working directory # Set working directory
@@ -13,21 +13,21 @@ WORKDIR /app
COPY package*.json ./ COPY package*.json ./
# Install dependencies (including dev dependencies for building) # Install dependencies (including dev dependencies for building)
RUN npm ci RUN bun install
# Copy source code # Copy source code
COPY . . COPY . .
# Generate Prisma client (with dummy PostgreSQL DATABASE_URL for build-time generation) # 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 # 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) # Build the application (with dummy DATABASE_URL for static page generation and git commit)
ARG GIT_COMMIT=unknown 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) # 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 # Install dependencies
RUN apk add --no-cache python3 make g++ git RUN apk add --no-cache python3 make g++ git
@@ -39,16 +39,16 @@ WORKDIR /app
COPY package*.json ./ COPY package*.json ./
# Install ALL dependencies (including dev dependencies for testing) # Install ALL dependencies (including dev dependencies for testing)
RUN npm ci RUN bun install
# Copy source code # Copy source code
COPY . . COPY . .
# Generate Prisma client # 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 # Stage 3: Production runner
FROM node:20-alpine AS runner FROM oven/bun:alpine AS runner
# Install dumb-init for proper signal handling # Install dumb-init for proper signal handling
RUN apk add --no-cache dumb-init 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/.next ./.next
COPY --from=builder --chown=euchre:euchre /app/public ./public 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.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 COPY --from=builder --chown=euchre:euchre /app/prisma ./prisma
# Install only production dependencies # Install only production dependencies
RUN npm ci --omit=dev RUN bun install --production
# Generate Prisma client # Generate Prisma client
# Note: We need to set DATABASE_URL even for generation because prisma.config.ts requires it # 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 # Switch to non-root user
USER euchre USER euchre
@@ -86,4 +86,4 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
# Start command # Start command
ENTRYPOINT ["dumb-init", "--"] ENTRYPOINT ["dumb-init", "--"]
CMD ["npm", "start"] CMD ["bun", "run", "start"]