b5b9f32a87
- Update justfile to use bun instead of npm for all commands - Fix broken test glob patterns in package.json and workflows - Fix npm run test:acceptance:cucumber:prod to use bun - Update pr.yml and release.yml unit test commands to use correct path format - Run 157 unit tests (was only running ~2 due to broken glob)
242 lines
6.6 KiB
Makefile
242 lines
6.6 KiB
Makefile
# justfile for Euchre Camp
|
|
# Automates development, testing, and deployment tasks.
|
|
# Designed for CI/CD pipelines and local development.
|
|
|
|
# --- Configuration ---
|
|
set dotenv-load
|
|
set positional-arguments
|
|
|
|
# Project name
|
|
PROJECT := "euchre-camp"
|
|
|
|
# Docker registry
|
|
REGISTRY := "docker.notsosm.art"
|
|
IMAGE_TAG := "latest"
|
|
|
|
# Get git commit hash (short version)
|
|
GIT_COMMIT := `git rev-parse --short HEAD`
|
|
|
|
# Image tag with git commit (use same format as GIT_COMMIT)
|
|
IMAGE_TAG_COMMIT := `git rev-parse --short HEAD`
|
|
|
|
# --- Variables ---
|
|
# Database
|
|
DB_CONTAINER := "euchre-camp-postgres"
|
|
DATABASE_URL := env_var_or_default("DATABASE_URL", "")
|
|
|
|
# --- Setup & Installation ---
|
|
|
|
# Install dependencies and setup environment
|
|
setup:
|
|
@echo "Installing dependencies..."
|
|
bun install
|
|
@echo "Setting up database..."
|
|
bun run db:setup-dev
|
|
@echo "Generating Prisma client..."
|
|
bun x prisma generate
|
|
|
|
# --- Development ---
|
|
|
|
# Start the development server
|
|
dev:
|
|
bun run dev
|
|
|
|
# Lint the codebase
|
|
lint:
|
|
bun run lint
|
|
|
|
# Type check the codebase
|
|
typecheck:
|
|
npx tsc --noEmit
|
|
|
|
# Format code (if prettier is available, otherwise just lint)
|
|
format:
|
|
npx prettier --write .
|
|
|
|
# --- Testing ---
|
|
|
|
# Run all tests (unit + acceptance)
|
|
test: test-unit test-acceptance
|
|
|
|
# Run unit tests
|
|
test-unit:
|
|
DATABASE_URL="postgresql://test:test@localhost:5432/test" bun test src/__tests__/unit/
|
|
|
|
# Run acceptance tests (Playwright)
|
|
test-acceptance:
|
|
@echo "Running acceptance tests..."
|
|
bun x playwright test e2e/
|
|
|
|
# Run Cucumber e2e tests
|
|
test-cucumber:
|
|
@echo "Clearing Next.js cache..."
|
|
rm -rf .next/
|
|
@echo "Running Cucumber e2e tests..."
|
|
bun run test:acceptance:cucumber
|
|
|
|
# Run Cucumber e2e tests against production build
|
|
test-cucumber-prod:
|
|
@echo "Clearing Next.js cache..."
|
|
rm -rf .next/
|
|
@echo "Building application for production..."
|
|
bun run build
|
|
@echo "Starting production server in background..."
|
|
bun run start > /tmp/next-prod.log 2>&1 &
|
|
SERVER_PID=$$!
|
|
@echo "Waiting for server to be ready..."
|
|
sleep 15
|
|
@echo "Running Cucumber e2e tests against production build..."
|
|
bun run test:acceptance:cucumber || true
|
|
@echo "Stopping production server..."
|
|
kill $$SERVER_PID 2>/dev/null || true
|
|
@echo "Tests completed."
|
|
|
|
# Run database migrations (Prisma)
|
|
migrate:
|
|
bun x prisma migrate dev
|
|
|
|
# Seed the database
|
|
seed:
|
|
bun run scripts/seed.js
|
|
|
|
# --- Docker ---
|
|
|
|
# Build the Docker image (standard build)
|
|
docker-build:
|
|
@echo "Building Docker image {{PROJECT}}:{{IMAGE_TAG}}..."
|
|
docker build --build-arg GIT_COMMIT={{GIT_COMMIT}} -t {{PROJECT}}:{{IMAGE_TAG}} .
|
|
|
|
docker-build-commit:
|
|
@echo "Building Docker image {{PROJECT}}:{{IMAGE_TAG_COMMIT}}..."
|
|
docker build --build-arg GIT_COMMIT={{GIT_COMMIT}} -t {{PROJECT}}:{{IMAGE_TAG_COMMIT}} .
|
|
|
|
# Build and tag with both latest and commit hash
|
|
docker-build-full: docker-build docker-build-commit
|
|
|
|
# Fast rebuild using Docker BuildKit cache
|
|
docker-rebuild-fast:
|
|
@echo "Fast rebuilding Docker image {{PROJECT}}:{{IMAGE_TAG}}..."
|
|
DOCKER_BUILDKIT=1 docker build \
|
|
--build-arg GIT_COMMIT={{GIT_COMMIT}} \
|
|
--cache-from={{PROJECT}}:{{IMAGE_TAG}} \
|
|
-t {{PROJECT}}:{{IMAGE_TAG}} \
|
|
-t {{PROJECT}}:{{IMAGE_TAG_COMMIT}} \
|
|
.
|
|
|
|
# Run the Docker container locally
|
|
docker-run: docker-build
|
|
@echo "Running Docker container {{PROJECT}}..."
|
|
docker run -d -p 3000:3000 --name {{PROJECT}} {{PROJECT}}:{{IMAGE_TAG}}
|
|
|
|
# Stop and remove the Docker container
|
|
docker-stop:
|
|
@echo "Stopping Docker container {{PROJECT}}..."
|
|
docker stop {{PROJECT}} || true
|
|
docker rm {{PROJECT}} || true
|
|
|
|
# Clean up Docker images and containers
|
|
docker-clean: docker-stop
|
|
@echo "Removing Docker image {{PROJECT}}:{{IMAGE_TAG}}..."
|
|
docker rmi {{PROJECT}}:{{IMAGE_TAG}} || true
|
|
|
|
# --- Deployment ---
|
|
|
|
# Tag image for registry
|
|
docker-tag:
|
|
@echo "Tagging image for registry..."
|
|
docker tag {{PROJECT}}:{{IMAGE_TAG}} {{REGISTRY}}/{{PROJECT}}:{{IMAGE_TAG}} || true
|
|
docker tag {{PROJECT}}:{{IMAGE_TAG_COMMIT}} {{REGISTRY}}/{{PROJECT}}:{{IMAGE_TAG_COMMIT}} || true
|
|
@echo "Tagged {{PROJECT}}:{{IMAGE_TAG}} -> {{REGISTRY}}/{{PROJECT}}:{{IMAGE_TAG}}"
|
|
@echo "Tagged {{PROJECT}}:{{IMAGE_TAG_COMMIT}} -> {{REGISTRY}}/{{PROJECT}}:{{IMAGE_TAG_COMMIT}}"
|
|
|
|
# Push image to registry (builds, tags, and pushes)
|
|
docker-push: docker-build-full
|
|
@echo "Tagging images for registry..."
|
|
docker tag {{PROJECT}}:{{IMAGE_TAG}} {{REGISTRY}}/{{PROJECT}}:{{IMAGE_TAG}} || true
|
|
docker tag {{PROJECT}}:{{IMAGE_TAG_COMMIT}} {{REGISTRY}}/{{PROJECT}}:{{IMAGE_TAG_COMMIT}} || true
|
|
@echo "Pushing images to {{REGISTRY}}..."
|
|
docker push {{REGISTRY}}/{{PROJECT}}:{{IMAGE_TAG}}
|
|
docker push {{REGISTRY}}/{{PROJECT}}:{{IMAGE_TAG_COMMIT}}
|
|
|
|
# --- CI/CD Pipeline Simulation ---
|
|
|
|
# Run full CI pipeline locally (lint, test, build)
|
|
ci: lint typecheck test-unit test-acceptance docker-build
|
|
@echo "CI Pipeline completed successfully!"
|
|
|
|
# PR validation (what runs on pull requests)
|
|
pr-validate: lint typecheck test-unit test-acceptance
|
|
@echo "PR validation completed successfully!"
|
|
|
|
# --- Utilities ---
|
|
|
|
# Show help information
|
|
help:
|
|
@just --list
|
|
|
|
# Clean up project (remove node_modules, build artifacts)
|
|
clean:
|
|
@echo "Cleaning project..."
|
|
rm -rf node_modules .next dist .turbo
|
|
|
|
# Generate Prisma client
|
|
prisma-generate:
|
|
bun x prisma generate
|
|
|
|
# Reset development database
|
|
db-reset-dev:
|
|
bun run scripts/setup-postgres.js --drop
|
|
|
|
# Setup development database
|
|
db-setup-dev:
|
|
bun run scripts/setup-postgres.js
|
|
|
|
# Clean production database (remove test records)
|
|
db-clean-prod:
|
|
bun run scripts/cleanup-prod-db.js
|
|
|
|
# Check production database for test records
|
|
db-check-prod:
|
|
bun run scripts/check-test-records.js
|
|
|
|
# Create admin user
|
|
admin-create:
|
|
node scripts/create-admin-via-api.js
|
|
|
|
# List all users
|
|
users-list:
|
|
node scripts/list-users.js
|
|
|
|
# Update admin password
|
|
admin-update-password:
|
|
node scripts/update-admin-password.js
|
|
|
|
# Bump version
|
|
version-bump-patch:
|
|
bun run scripts/bump-version.js patch
|
|
|
|
version-bump-minor:
|
|
bun run scripts/bump-version.js minor
|
|
|
|
version-bump-major:
|
|
bun run scripts/bump-version.js major
|
|
|
|
# Docker Compose shortcuts
|
|
docker-up:
|
|
docker-compose up -d
|
|
|
|
docker-down:
|
|
docker-compose down
|
|
|
|
docker-logs:
|
|
docker-compose logs -f
|
|
|
|
# View workflow status
|
|
workflow-status:
|
|
@echo "Current workflows in .gitea/workflows/:"
|
|
ls -la .gitea/workflows/
|
|
@echo ""
|
|
@echo "PR Workflow: Runs unit + acceptance tests on pull requests"
|
|
@echo "Test Workflow: Runs unit tests on all branch pushes"
|
|
@echo "Release Workflow: Runs on main branch pushes (version bump + Docker build)"
|