-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefile
94 lines (73 loc) · 3.26 KB
/
Makefile
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
82
83
84
85
86
87
88
89
90
91
92
93
94
SOURCES ?= $(shell find . -type f \( -name "*.go" -o -name "go.mod" -o -name "go.sum" \) -print)
TEST_DB_PORT := 3100
# renovate:image-tag imageName=ghcr.io/k1low/tbls
TBLS_VERSION := "v1.79.4"
# renovate:image-tag imageName=index.docker.io/stoplight/spectral
SPECTRAL_VERSION := "6.14.2"
.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/[email protected]
go install github.com/golang/mock/[email protected]
.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 stoplight/spectral:$(SPECTRAL_VERSION) 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:[email protected]:$(TEST_DB_PORT)/traq" -v $$PWD:/work -w /work ghcr.io/k1low/tbls:$(TBLS_VERSION) 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:[email protected]:$(TEST_DB_PORT)/traq" -v $$PWD:/work -w /work ghcr.io/k1low/tbls:$(TBLS_VERSION) 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:[email protected]:$(TEST_DB_PORT)/traq" -v $$PWD:/work -w /work ghcr.io/k1low/tbls:$(TBLS_VERSION) lint -c .tbls.yml
.PHONY: goreleaser-snapshot
goreleaser-snapshot: ## Release dry-run
@docker run --rm -it -v $$PWD:/src -w /src goreleaser/goreleaser --snapshot --skip-publish --rm-dist
.PHONY: update-frontend
update-frontend: ## Update frontend files in dev/frontend
@mkdir -p ./dev/frontend
# renovate:github-url
@curl -L -Ss https://github.com/traPtitech/traQ_S-UI/releases/download/v3.21.0/dist.tar.gz | tar zxv -C ./dev/frontend/ --strip-components=2
.PHONY: reset-frontend
reset-frontend: ## Completely replace frontend files in dev/frontend
rm -rf ./dev/frontend
@make update-frontend
.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 ./...