-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (44 loc) · 1.18 KB
/
Makefile
File metadata and controls
58 lines (44 loc) · 1.18 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
.DEFAULT_GOAL := help
vendor := vendor
target := target
bin := $(target)/bin
reports := $(target)/reports
## build: Compile binaries.
go_src := $(shell find * -name *.go -not -path "$(vendor)/*" -not -path "$(target)/*")
go_out := $(patsubst cmd/%/main.go,$(bin)/%,$(wildcard cmd/*/main.go))
.PHONY: build
build: $(go_out)
$(bin)/%: cmd/%/main.go $(go_src) | $(bin)
@go build --trimpath -o=$@ $<
$(bin):
@mkdir -p $@
$(reports):
@mkdir -p $@
## generate: Run generators.
.PHONY: generate
generate: go/generate openapi/generate
.PHONY: go/generate
go/generate:
@go generate ./...
.PHONY: openapi/generate
openapi/generate:
@go tool oapi-codegen -config ./api/codegen.config.yaml ./api/openapi.v1.yaml
## tests: Run tests.
.PHONY: test tests
test tests: go/test
.PHONY: go/test
go/test: $(go_src) | $(reports)
@go test -v -covermode=atomic -coverprofile=$(reports)/cover.out ./...
## lint: Run static analysis.
.PHONY: lint
lint: go/lint
.PHONY: go/lint
go/lint:
@golangci-lint run
## help: Display available targets.
.PHONY: help
help: Makefile
@echo "Usage: make [target]"
@echo
@echo "Targets:"
@sed -n 's/^## //p' $< | awk -F ':' '{printf " %-20s%s\n",$$1,$$2}'