-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (64 loc) · 3.81 KB
/
Makefile
File metadata and controls
83 lines (64 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
.DEFAULT_GOAL := help
VERSION := $(shell cat ./VERSION)
GIT_SHORT_HASH := $(shell if jj root >/dev/null 2>&1; then jj log --no-graph -T 'commit_id.short(7)' -r @ 2>/dev/null; else git rev-parse --short HEAD 2>/dev/null; fi || echo "unknown")
GIT_TAG_NAME := "release-"$(VERSION)
DUMMY_DIR := scripts/make
GENERATE_FRONTEND_DUMMY := $(DUMMY_DIR)/generate-frontend.done
GENERATE_BACKEND_DUMMY := $(DUMMY_DIR)/generate-backend.done
FRONTEND_GENERATED_ASSETS_DUMMY := $(DUMMY_DIR)/generate-font-atlas.done
MSDF_SETUP_DUMMY := $(DUMMY_DIR)/msdf-setup.done
BACKEND_TEST_SRCS := $(shell find . -path "./web" -prune -o -path "./.git" -prune -o -name "*_test.go" -not -name "zzz_*.go" -print)
BACKEND_SRCS := $(shell find . -path "./web" -prune -o -path "./.git" -prune -o -name "*.go" -not -name "zzz_*.go" -not -name "*_test.go" -print)
ENUM_GO_ALL_FILES := $(wildcard pkg/model/enum/*.go)
ENUM_GO_FILES := $(filter-out %_test.go,$(ENUM_GO_ALL_FILES))
FRONTEND_CODEGEN_DIR := scripts/frontend-codegen
FRONTEND_CODEGEN_DEPS := $(wildcard $(FRONTEND_CODEGEN_DIR)/*.go $(FRONTEND_CODEGEN_DIR)/templates/*)
FRONTEND_SOURCE_FILES := $(shell find ./web \( -name "node_modules" -o -name ".angular" -o -path "./web/src/assets" \) -prune -o -not -path "./web/src/environments/version.*.ts" -not -path "*/zzz-generated.*" -not -path "./web/angular.json" -print)
FRONTEND_GENERATED_SRCS = web/src/app/zzz-generated.scss web/src/app/zzz-generated.ts web/angular.json
FRONTEND_ARTIFACT_FILES_DUMMY = pkg/server/dist/browser/build-web.done
include scripts/make/*.mk
# ====================================================================================
# Development commands
# ====================================================================================
## Test
.PHONY: test
test: test-web test-go ## Run all tests
.PHONY: coverage
coverage: coverage-go coverage-web ## Run all tests and generate coverage report
## Lint
.PHONY: lint
lint: lint-web lint-go ## Run all linters
.PHONY: lint-warning
lint-warning: generate-depguard-rules ## Lint warning contains lint rules that is warning at this moment but should be fixed long term.
golangci-lint run --config=.generated-golangci-depguard.yaml
.PHONY: generate-depguard-rules
generate-depguard-rules: ## Generate depguard rule from Go source. This rule prevents packages being imported from unexpected package and enforce packages to follow the package structure rule.
cd ./scripts/depguard-generator/ && go run . --package-root=../.. --output=../../.generated-golangci-depguard.yaml
## Format
.PHONY: format
format: format-web format-go ## Format all source code
# ====================================================================================
# Setup
# ====================================================================================
.PHONY: setup
setup: setup-hooks
cd web && npm install
make build
.PHONY: setup-hooks
setup-hooks: ## Set up git hooks
@if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then \
HOOK_DIR=$$(git rev-parse --git-path hooks); \
PRE_COMMIT_HOOK="$$HOOK_DIR/pre-commit"; \
mkdir -p "$$HOOK_DIR"; \
printf '%s\n' '#!/bin/sh' 'cd "$$(git rev-parse --show-toplevel)"' 'exec make pre-commit' > "$$PRE_COMMIT_HOOK"; \
chmod +x "$$PRE_COMMIT_HOOK"; \
echo "Git hooks configured. (Note: jj users should run 'make pre-commit' manually)"; \
else \
echo "Not a git repository. Skipping git hook setup. If you use jj, you can manually run 'make pre-commit' before 'jj commit'."; \
fi
# ====================================================================================
# Utils
# ====================================================================================
.PHONY: help
help: ## Show this help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)