2026-09-19 20:31:14 +02:00
|
|
|
SHELL := /bin/sh
|
|
|
|
|
|
|
|
|
|
DATABASE_URL ?= postgres://go_guess:go_guess@localhost:5432/go_guess?sslmode=disable
|
|
|
|
|
JWT_SECRET ?= local-development-secret-change-me-12345
|
|
|
|
|
GOOSE := cd backend && go run github.com/pressly/goose/v3/cmd/goose@v3.26.0
|
2026-09-20 09:13:48 +02:00
|
|
|
BDD_COMPOSE := docker compose -f docker-compose.bdd.yml
|
2026-09-19 20:31:14 +02:00
|
|
|
|
2026-09-20 09:13:48 +02:00
|
|
|
.PHONY: help dev db-up db-down migrate migrate-down seed backend frontend frontend-install test test-backend test-frontend test-integration test-bdd test-bdd-down test-env test-env-down lint build
|
2026-09-19 20:31:14 +02:00
|
|
|
|
2026-09-20 09:01:35 +02:00
|
|
|
help:
|
|
|
|
|
@echo "make dev builds the demo docker image"
|
|
|
|
|
@echo "make db-up starts the database docker container"
|
|
|
|
|
@echo "make db-down stops the database docker container"
|
|
|
|
|
@echo "make migrate runs the sql scripts migration"
|
|
|
|
|
@echo "make migrate-down revert the sql scripts migration"
|
|
|
|
|
@echo "make seed seeds data into the database"
|
|
|
|
|
@echo "make backend runs the backend"
|
|
|
|
|
@echo "make frontend runs the frontend"
|
|
|
|
|
@echo "make frontend-install installs the dependencies for the frontend"
|
2026-09-20 09:13:48 +02:00
|
|
|
@echo "make test full test suite: frontend, integration, and browser BDD"
|
2026-09-20 09:01:35 +02:00
|
|
|
@echo "make test-backend runs the tests for the backend"
|
|
|
|
|
@echo "make test-frontend runs the tests for the fronted"
|
|
|
|
|
@echo "make test-integration runs the integration tests"
|
2026-09-20 09:13:48 +02:00
|
|
|
@echo "make test-bdd runs browser BDD stories against the production image"
|
|
|
|
|
@echo "make test-bdd-down removes the isolated BDD stack and database"
|
2026-09-20 09:01:35 +02:00
|
|
|
@echo "make test-env builds the docker tests image"
|
|
|
|
|
@echo "make test-env-down stops the test image"
|
|
|
|
|
@echo "make lint runs lint on the frontend"
|
|
|
|
|
@echo "make build builds the entire project"
|
2026-09-19 20:31:14 +02:00
|
|
|
dev:
|
|
|
|
|
docker compose up --build
|
|
|
|
|
|
|
|
|
|
db-up:
|
|
|
|
|
docker compose up -d db
|
|
|
|
|
|
|
|
|
|
db-down:
|
|
|
|
|
docker compose down
|
|
|
|
|
|
|
|
|
|
migrate:
|
|
|
|
|
$(GOOSE) -dir migrations postgres "$(DATABASE_URL)" up
|
|
|
|
|
|
|
|
|
|
migrate-down:
|
|
|
|
|
$(GOOSE) -dir migrations postgres "$(DATABASE_URL)" down
|
|
|
|
|
|
2026-09-19 21:11:20 +02:00
|
|
|
seed:
|
|
|
|
|
cd backend && DATABASE_URL="$(DATABASE_URL)" APP_ENV="$${APP_ENV:-development}" go run ./cmd/seed
|
|
|
|
|
|
2026-09-19 20:31:14 +02:00
|
|
|
backend:
|
|
|
|
|
cd backend && DATABASE_URL="$(DATABASE_URL)" JWT_SECRET="$(JWT_SECRET)" go run ./cmd/api
|
|
|
|
|
|
|
|
|
|
frontend:
|
|
|
|
|
cd frontend && npm run dev
|
|
|
|
|
|
2026-09-19 21:11:20 +02:00
|
|
|
frontend-install:
|
|
|
|
|
cd frontend && npm ci
|
|
|
|
|
|
2026-09-20 09:13:48 +02:00
|
|
|
test: frontend-install test-integration test-frontend test-bdd
|
2026-09-19 20:31:14 +02:00
|
|
|
|
|
|
|
|
test-backend:
|
|
|
|
|
cd backend && go test ./...
|
|
|
|
|
|
|
|
|
|
test-frontend:
|
|
|
|
|
cd frontend && npm test
|
|
|
|
|
|
|
|
|
|
test-integration:
|
2026-09-19 21:11:20 +02:00
|
|
|
cd backend && go test -tags=integration ./...
|
|
|
|
|
|
2026-09-20 09:13:48 +02:00
|
|
|
test-bdd:
|
|
|
|
|
@set -eu; \
|
|
|
|
|
$(BDD_COMPOSE) down -v --remove-orphans; \
|
|
|
|
|
trap '$(BDD_COMPOSE) down -v --remove-orphans >/dev/null 2>&1' EXIT INT TERM; \
|
|
|
|
|
$(BDD_COMPOSE) up --build --abort-on-container-exit --exit-code-from bdd
|
|
|
|
|
|
|
|
|
|
test-bdd-down:
|
|
|
|
|
$(BDD_COMPOSE) down -v --remove-orphans
|
|
|
|
|
|
2026-09-19 21:11:20 +02:00
|
|
|
test-env:
|
|
|
|
|
COMPOSE_PROJECT_NAME=go-guess-test APP_ENV=test DB_PORT=15432 API_PORT=18080 \
|
2026-09-19 21:58:24 +02:00
|
|
|
WEB_PORT=15173 FRONTEND_URL=http://localhost:15173 RABBITMQ_AMQP_PORT=15673 \
|
|
|
|
|
RABBITMQ_MANAGEMENT_PORT=25673 docker compose up -d --build
|
2026-09-19 21:11:20 +02:00
|
|
|
|
|
|
|
|
test-env-down:
|
|
|
|
|
COMPOSE_PROJECT_NAME=go-guess-test docker compose down -v --remove-orphans
|
2026-09-19 20:31:14 +02:00
|
|
|
|
|
|
|
|
lint:
|
|
|
|
|
cd backend && go vet ./...
|
|
|
|
|
cd frontend && npm run lint
|
|
|
|
|
|
|
|
|
|
build:
|
|
|
|
|
cd backend && go build ./...
|
|
|
|
|
cd frontend && npm run build
|