2024-06-05 20:10:03 +00:00
|
|
|
# Directory containing the Makefile.
|
|
|
|
PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|
|
|
|
|
|
|
export GOBIN ?= $(PROJECT_ROOT)/bin
|
|
|
|
export PATH := $(GOBIN):$(PATH)
|
2023-02-22 21:58:17 +00:00
|
|
|
|
|
|
|
FXLINT = $(GOBIN)/fxlint
|
2023-05-19 20:23:55 +00:00
|
|
|
MDOX = $(GOBIN)/mdox
|
2023-02-22 21:58:17 +00:00
|
|
|
|
2023-08-22 10:32:01 +00:00
|
|
|
MODULES = . ./tools ./docs ./internal/e2e
|
2023-05-19 20:23:55 +00:00
|
|
|
|
|
|
|
# 'make cover' should not run on docs by default.
|
|
|
|
# We run that separately explicitly on a specific platform.
|
|
|
|
COVER_MODULES ?= $(filter-out ./docs,$(MODULES))
|
2023-02-22 21:58:17 +00:00
|
|
|
|
2024-06-05 20:10:03 +00:00
|
|
|
.PHONY: all
|
|
|
|
all: build lint test
|
|
|
|
|
2023-02-22 21:58:17 +00:00
|
|
|
.PHONY: build
|
|
|
|
build:
|
|
|
|
go build ./...
|
|
|
|
|
2024-06-05 20:10:03 +00:00
|
|
|
.PHONY: lint
|
|
|
|
lint: golangci-lint tidy-lint fx-lint docs-lint
|
2023-02-22 21:58:17 +00:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
|
|
|
@$(foreach dir,$(MODULES),(cd $(dir) && go test -race ./...) &&) true
|
|
|
|
|
|
|
|
.PHONY: cover
|
|
|
|
cover:
|
2023-05-19 20:23:55 +00:00
|
|
|
@$(foreach dir,$(COVER_MODULES), \
|
|
|
|
(cd $(dir) && \
|
|
|
|
echo "[cover] $(dir)" && \
|
|
|
|
go test -race -coverprofile=cover.out -coverpkg=./... ./... && \
|
|
|
|
go tool cover -html=cover.out -o cover.html) &&) true
|
2023-02-22 21:58:17 +00:00
|
|
|
|
2024-06-05 20:10:03 +00:00
|
|
|
.PHONY: tidy
|
|
|
|
tidy:
|
|
|
|
@$(foreach dir,$(MODULES),(cd $(dir) && go mod tidy) &&) true
|
2023-02-22 21:58:17 +00:00
|
|
|
|
2023-05-19 20:23:55 +00:00
|
|
|
.PHONY: docs
|
|
|
|
docs:
|
|
|
|
cd docs && yarn build
|
|
|
|
|
2024-06-05 20:10:03 +00:00
|
|
|
.PHONY: golangci-lint
|
|
|
|
golangci-lint:
|
|
|
|
@$(foreach mod,$(MODULES), \
|
|
|
|
(cd $(mod) && \
|
|
|
|
echo "[lint] golangci-lint: $(mod)" && \
|
|
|
|
golangci-lint run --path-prefix $(mod)) &&) true
|
|
|
|
|
|
|
|
.PHONY: tidy-lint
|
|
|
|
tidy-lint:
|
|
|
|
@$(foreach mod,$(MODULES), \
|
|
|
|
(cd $(mod) && \
|
|
|
|
echo "[lint] tidy: $(mod)" && \
|
|
|
|
go mod tidy && \
|
|
|
|
git diff --exit-code -- go.mod go.sum) &&) true
|
|
|
|
|
|
|
|
.PHONY: fx-lint
|
|
|
|
fx-lint: $(FXLINT)
|
|
|
|
@$(FXLINT) ./...
|
|
|
|
|
|
|
|
.PHONY: docs-lint
|
|
|
|
docs-lint: $(MDOX)
|
2023-05-19 20:23:55 +00:00
|
|
|
@echo "Checking documentation"
|
2024-06-05 20:10:03 +00:00
|
|
|
@make -C docs check
|
2023-05-19 20:23:55 +00:00
|
|
|
|
2024-06-05 20:10:03 +00:00
|
|
|
$(MDOX): tools/go.mod
|
|
|
|
cd tools && go install github.com/bwplotka/mdox
|
|
|
|
|
|
|
|
$(FXLINT): tools/cmd/fxlint/main.go
|
|
|
|
cd tools && go install go.uber.org/fx/tools/cmd/fxlint
|