PROJECT_NAME := hako CGO_ENABLED := 0 DIST_PATH := ./dist TEST_OPTIONS := -v -failfast -race -bench=. -benchtime=100000x -cover -coverprofile=coverage.out TEST_TIMEOUT := 5m GOLANGCI_LINT_VERSION := v2.14.0 # The Playwright CLI must match the module the e2e tests link against. PLAYWRIGHT_MODULE := github.com/mxschmitt/playwright-go PLAYWRIGHT_CMD := $(PLAYWRIGHT_MODULE)/cmd/playwright .DEFAULT_GOAL := help ## help: Display this help message .PHONY: help help: @echo "Available targets:" @grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /' | sort ## clean: Clean test cache, build files .PHONY: clean clean: @rm -rf $(DIST_PATH) @rm -rf webapp/dist @rm -rf webapp/node_modules @rm -f webapp/bun.lockb @go clean -modcache -testcache ## clean-devdata: Clear devdata database and files (keeps config.yaml) .PHONY: clean-devdata clean-devdata: @rm -rf devdata/data @rm -f devdata/hako.db devdata/hako.db-shm devdata/hako.db-wal ## build: Build project using goreleaser (snapshot) .PHONY: build build: build-webapp goreleaser build --snapshot --clean ## build-webapp: Build the webapp .PHONY: build-webapp build-webapp: @which bun > /dev/null || (echo "Error: Bun is not installed. Install it from https://bun.sh" && exit 1) @cd webapp && bun install && bun --bun node_modules/.bin/vite build ## build-docker: Build Docker image locally via goreleaser .PHONY: build-docker build-docker: build-webapp goreleaser release --snapshot --clean ## run: Build frontend and run the server .PHONY: run run: build-webapp run-server ## run-server: Run the API server only (without building webapp) .PHONY: run-server run-server: CGO_ENABLED=$(CGO_ENABLED) go run ./cmd/$(PROJECT_NAME)/*.go server --config devdata/config.yaml ## run-webapp: Run the webapp in dev mode with hot-reload .PHONY: run-webapp run-webapp: @which bun > /dev/null || (echo "Error: Bun is not installed. Install it from https://bun.sh" && exit 1) @cd webapp && bun --bun node_modules/.bin/vite --mode development ## format: Format code and tidy modules .PHONY: format format: go fmt ./... go mod tidy ## ci-lint: Run golangci-lint at the pinned version .PHONY: ci-lint ci-lint: @go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) $$(go env GOPATH)/bin/golangci-lint run ./... ## lint: Run all linters .PHONY: lint lint: lint-server lint-webapp ## lint-server: Check the server for linting errors .PHONY: lint-server lint-server: @golangci-lint run ./... ## lint-webapp: Check the webapp for linting errors .PHONY: lint-webapp lint-webapp: @which bun > /dev/null || (echo "Error: Bun is not installed. Install it from https://bun.sh" && exit 1) @cd webapp && bun --bun node_modules/.bin/eslint . ## test: Run tests with coverage .PHONY: test test: CGO_ENABLED=1 go test $(TEST_OPTIONS) -timeout=$(TEST_TIMEOUT) ./... ## e2e: Run end-to-end integration tests .PHONY: e2e e2e: @./scripts/e2e.sh ## e2e-install: Install Playwright browsers .PHONY: e2e-install e2e-install: @cd e2e && go run $(PLAYWRIGHT_CMD)@$$(go list -m -f '{{.Version}}' $(PLAYWRIGHT_MODULE)) install --with-deps chromium