Some checks failed
CI / goreleaser-lint (pull_request) Successful in 10s
CI / lint (pull_request) Has been cancelled
CI / format (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
CI / e2e (pull_request) Has been cancelled
CI / build (pull_request) Has been cancelled
104 lines
2.9 KiB
Makefile
104 lines
2.9 KiB
Makefile
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 := v1.64.5
|
|
|
|
.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 (installs if missing)
|
|
.PHONY: ci-lint
|
|
ci-lint:
|
|
@which golangci-lint > /dev/null 2>&1 || go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
|
|
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:
|
|
@go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps chromium
|