hako/Makefile
Felipe M. d4457cc4f6
All checks were successful
CI / goreleaser-lint (pull_request) Successful in 8s
CI / format (pull_request) Successful in 1m33s
CI / lint (pull_request) Successful in 3m23s
CI / build (pull_request) Successful in 3m5s
CI / test (pull_request) Successful in 4m38s
CI / e2e (pull_request) Successful in 26m24s
fix(e2e): move off the retired Playwright driver CDN
playwright-go v0.5200.1 fetches its driver from playwright.azureedge.net
and two sibling mirrors. Microsoft retired that CDN, so the e2e job died
on a 404 before it ever reached a test. The replacement host serves no
builds/driver zip for any version — 1.52 through 1.62 all answer 400 —
so there is nothing to pin or mirror to.

v0.6100.0 onwards pulls playwright-core from npm and Node from
nodejs.org instead, and moves the module path back to
github.com/mxschmitt/playwright-go. Take v0.6201.1, the latest. The
Playwright 1.52 to 1.62 jump needs no changes beyond the import path.

The CLI must match the module the tests link against, and the three
places that ran it had already drifted apart: the workflow pinned
v0.5200.1, the Makefile and scripts/e2e.sh asked for @latest. Both now
read the version from e2e/go.mod, and the workflow calls make e2e-install.
2026-09-22 16:38:00 +02:00

108 lines
3.1 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
# 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 (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:
@cd e2e && go run $(PLAYWRIGHT_CMD)@$$(go list -m -f '{{.Version}}' $(PLAYWRIGHT_MODULE)) install --with-deps chromium