-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (79 loc) · 1.77 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
95
96
97
PROJECT_NAME := filmstund
GOFMT_FILES = $(shell go list -f '{{.Dir}}' ./... | grep -v '/pb')
## Default make target
checks:\
sqlc-generate \
generate \
fmt \
build \
lint \
test \
mod-tidy \
mod-verify \
commitlint \
verify-nodiff
$(info done!)
.PHONY: checks
# Include tooling here
include .tools/golangci-lint/rules.mk
include .tools/gofumpt/rules.mk
include .tools/commitlint/rules.mk
include .tools/sqlc/rules.mk
yarn-install:
@yarn install --cwd ./web --silent --frozen-lockfile
.PHONY: yarn-install
lint-go: $(golangci-lint_bin) yarn-install
$(info [$@] linting $(PROJECT_NAME)...)
@$< run --config .golangci.yaml
.PHONY: lint-go
lint-web:
@make -C web lint-web
.PHONY: lint-web
lint: lint-go lint-web
verify-nodiff:
$(info [$@] verifying no git diff...)
@git update-index --refresh && git diff-index --quiet HEAD --
.PHONY: verify-nodiff
# Format all files
fmt: $(gofumpt_bin)
$(info [$@] formatting all Go files...)
@$< -w $(GOFMT_FILES)
.PHONY: fmt
mod-tidy:
$(info [$@] tidying up...)
@go mod tidy
.PHONY: mod-tidy
mod-verify:
$(info [$@] verifying modules...)
@go mod verify
.PHONY: mod-verify
generate:
$(info [$@] codegen...)
@go generate ./...
test:
$(info [$@] running the tests...)
@go test \
-shuffle=on \
-count=1 \
-short \
-timeout=5m \
./...
.PHONY: test
clean:
@rm -rf ./.build
.PHONY: clean
build: clean
$(info [$@] building ${PROJECT_NAME}...)
go build -o .build/${PROJECT_NAME} ./cmd/${PROJECT_NAME}
go build -o .build/migrate ./cmd/migrate
go build -o .build/popularity ./cmd/popularity
.PHONY: build
build-website: yarn-install
$(info [$@] building website...)
@yarn --cwd ./web --silent types
@yarn --cwd ./web --silent build
migrate: build
@./.build/migrate
run: build migrate
@./.build/${PROJECT_NAME}
.PHONY: run