forked from traPtitech/traQ
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (61 loc) · 2.74 KB
/
Copy pathMakefile
File metadata and controls
79 lines (61 loc) · 2.74 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
SOURCES ?= $(shell find . -type f \( -name "*.go" -o -name "go.mod" -o -name "go.sum" \) -print)
TEST_DB_PORT := 3100
# renovate:image-full-digest
TBLS_IMAGE := "ghcr.io/k1low/tbls:v1.95.0@sha256:5d194e7baa9d14e740ee41f29985b8cb7601926fca019a4bb0c34b8c937bd8cb"
# renovate:image-full-digest
SPECTRAL_IMAGE := "index.docker.io/stoplight/spectral:6.16.1@sha256:6a09f1093febf704046322cc543d57748ae475d6160c10237f04a794e0e18c37"
.DEFAULT_GOAL := help
.PHONY: help
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
traQ: $(SOURCES) ## Build traQ binary
CGO_ENABLED=0 go build -o traQ -ldflags "-s -w -X main.version=Dev -X main.revision=Local"
.PHONY: init
init: ## Download and install go mod dependencies
go mod download
go install github.com/google/wire/cmd/wire@v0.7.0
go install github.com/golang/mock/mockgen@v1.6.0
.PHONY: genkey
genkey: ## Generate dev keys
mkdir -p ./dev/keys
cd ./dev/keys && go run ../bin/gen_ec_pem.go
.PHONY: test
test: ## Run test
MARIADB_PORT=$(TEST_DB_PORT) go test ./... -race -shuffle=on
.PHONY: up-test-db
up-test-db: ## Make sure the test db container is running
@TEST_DB_PORT=$(TEST_DB_PORT) ./dev/bin/up-test-db.sh
.PHONY: rm-test-db
rm-test-db: ## Remove the test db container
@./dev/bin/down-test-db.sh
.PHONY: lint
lint: ## Lint go and swagger files
-@make golangci-lint
-@make swagger-lint
.PHONY: golangci-lint
golangci-lint: ## Lint go files
@golangci-lint run
.PHONY: swagger-lint
swagger-lint: ## Lint swagger file
@docker run --rm -it -v $$PWD:/tmp $(SPECTRAL_IMAGE) lint -r /tmp/.spectral.yml -q /tmp/docs/v3-api.yaml
.PHONY: db-gen-docs
db-gen-docs: ## Generate db docs in docs/dbSchema
TRAQ_MARIADB_PORT=$(TEST_DB_PORT) go run main.go migrate --reset
docker run --rm --net=host -e TBLS_DSN="mariadb://root:password@127.0.0.1:$(TEST_DB_PORT)/traq" -v $$PWD:/work -w /work $(TBLS_IMAGE) doc -c .tbls.yml --rm-dist
.PHONY: db-diff-docs
db-diff-docs: ## List diff of db docs
TRAQ_MARIADB_PORT=$(TEST_DB_PORT) go run main.go migrate --reset
docker run --rm --net=host -e TBLS_DSN="mariadb://root:password@127.0.0.1:$(TEST_DB_PORT)/traq" -v $$PWD:/work -w /work $(TBLS_IMAGE) diff -c .tbls.yml
.PHONY: db-lint
db-lint: ## Lint db docs according to .tbls.yml
TRAQ_MARIADB_PORT=$(TEST_DB_PORT) go run main.go migrate --reset
docker run --rm --net=host -e TBLS_DSN="mariadb://root:password@127.0.0.1:$(TEST_DB_PORT)/traq" -v $$PWD:/work -w /work $(TBLS_IMAGE) lint -c .tbls.yml
.PHONY: up
up: ## Build and start the app containers
@docker compose up -d --build
.PHONY: down
down: ## Stop and remove app containers
@docker compose down
.PHONY: gogen
gogen: ## Generate auto-generated go files
go generate ./...