hako/Makefile
Felipe M. 7c5d341d3d
Some checks failed
CI / goreleaser-lint (pull_request) Successful in 1m2s
CI / format (pull_request) Successful in 2m44s
CI / test (pull_request) Successful in 4m27s
CI / build (pull_request) Successful in 3m36s
CI / lint (pull_request) Successful in 6m24s
CI / e2e (pull_request) Failing after 3m32s
ci: run golangci-lint at the pinned version
The ci-lint target guarded its install with `which golangci-lint`, so on a
runner that already ships golangci-lint the pinned version was never
installed and whatever the image carried ran instead. That binary is v1,
which cannot read a `version: "2"` config and exits with "can't load
config: unsupported version of the configuration".

This is why lint fails on master as well, and why it started failing at
ccda656c ("ci: run workflows on the GitHub-compatible runner") while the
target itself has not changed since.

Always installs the pinned version and invokes it by absolute path, so
the result no longer depends on what the runner image happens to carry.

Verified in a golang:1.26 container both clean and with a decoy
golangci-lint ahead of it on PATH; the old target picks up the decoy and
fails, the new one does not.
2026-09-22 18:11:37 +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 := v2.13.2
# 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