generated from rollkit/template-da-repo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
105 lines (90 loc) · 2.9 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
98
99
100
101
102
103
104
105
LDFLAGS=-ldflags="-X '$(versioningPath).buildTime=$(shell date)' -X '$(versioningPath).lastCommit=$(shell git rev-parse HEAD)' -X '$(versioningPath).semanticVersion=$(shell git describe --tags --dirty=-dev 2>/dev/null || git rev-parse --abbrev-ref HEAD)'"
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
# Define pkgs, run, and cover vairables for test so that we can override them in
# the terminal more easily.
pkgs := $(shell go list ./...)
run := .
count := 1
## build: Build local-sequencer binary.
build:
@echo "--> Building local-sequencer"
@go build -o build/ ${LDFLAGS} ./...
.PHONY: build
## docker-build: Build local-sequencer docker image.
docker-build:
@echo "--> Building local-sequencer docker image"
@docker build -t local-sequencer .
.PHONY: docker-build
## help: Show this help message
help: Makefile
@echo " Choose a command run in "$(PROJECTNAME)":"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
.PHONY: help
## clean: clean testcache
clean:
@echo "--> Clearing testcache"
@go clean --testcache
.PHONY: clean
## cover: generate to code coverage report.
cover:
@echo "--> Generating Code Coverage"
@go install github.com/ory/go-acc@latest
@go-acc -o coverage.txt $(pkgs)
.PHONY: cover
## deps: Install dependencies
deps:
@echo "--> Installing dependencies"
@go mod download
# @make proto-gen
@go mod tidy
.PHONY: deps
## lint: Run linters golangci-lint and markdownlint.
lint: vet
@echo "--> Running golangci-lint"
@golangci-lint run
@echo "--> Running markdownlint"
@markdownlint --config .markdownlint.yaml '**/*.md'
@hadolint Dockerfile
@echo "--> Running yamllint"
@yamllint --no-warnings . -c .yamllint.yml
.PHONY: lint
## fmt: Run fixes for linters. Currently only markdownlint.
fmt:
@echo "--> Formatting markdownlint"
@markdownlint --config .markdownlint.yaml '**/*.md' -f
@echo "--> Formatting go"
@golangci-lint run --fix
.PHONY: fmt
## vet: Run go vet
vet:
@echo "--> Running go vet"
@go vet $(pkgs)
.PHONY: vet
## test: Running unit tests
test: vet
@echo "--> Running unit tests"
@go test -v -race -covermode=atomic -coverprofile=coverage.txt $(pkgs) -run $(run) -count=$(count)
.PHONY: test
### proto-gen: Generate protobuf files. Requires docker.
# proto-gen:
# @echo "--> Generating Protobuf files"
# ./proto/gen.sh
# .PHONY: proto-gen
#? check-proto-deps: Check protobuf deps
check-proto-deps:
ifeq (,$(shell which protoc-gen-gocosmos))
@go install github.com/cosmos/gogoproto/protoc-gen-gocosmos@latest
endif
.PHONY: check-proto-deps
#? proto-gen: Generate protobuf files
proto-gen: check-proto-deps
@echo "Generating Protobuf files"
@go run github.com/bufbuild/buf/cmd/buf@latest generate --path proto/sequencing
.PHONY: proto-gen
#
### proto-lint: Lint protobuf files. Requires docker.
proto-lint:
@echo "--> Linting Protobuf files"
@$(DOCKER_BUF) lint --error-format=json
.PHONY: proto-lint