forked from rollkit/rollkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
133 lines (115 loc) · 4.18 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
PACKAGE_NAME := github.com/rollkit/rollkit
GOLANG_CROSS_VERSION ?= v1.22.1
# Define pkgs, run, and cover variables for test so that we can override them in
# the terminal more easily.
# IGNORE_DIRS is a list of directories to ignore when running tests and linters.
# This list is space separated.
IGNORE_DIRS ?= third_party
pkgs := $(shell go list ./... | grep -vE "$(IGNORE_DIRS)")
run := .
count := 1
## 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 --ignore './cmd/rollkit/docs/*.md' '**/*.md'
@echo "--> Running hadolint"
@hadolint test/docker/mockserv.Dockerfile
@echo "--> Running yamllint"
@yamllint --no-warnings . -c .yamllint.yml
@echo "--> Running goreleaser check"
@goreleaser check
@echo "--> Running actionlint"
@actionlint
.PHONY: lint
## fmt: Run fixes for linters.
fmt:
@echo "--> Formatting markdownlint"
@markdownlint --config .markdownlint.yaml --ignore './cmd/rollkit/docs/*.md' '**/*.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/get_deps.sh
./proto/gen.sh
.PHONY: proto-gen
## mock-gen: generate mocks of external (commetbft) types
mock-gen:
@echo "-> Generating mocks"
mockery --output test/mocks --srcpkg github.com/cometbft/cometbft/rpc/client --name Client
mockery --output test/mocks --srcpkg github.com/cometbft/cometbft/abci/types --name Application
mockery --output test/mocks --srcpkg github.com/rollkit/go-da --name DA
mockery --output test/mocks --srcpkg github.com/rollkit/rollkit/store --name Store
.PHONY: mock-gen
## proto-lint: Lint protobuf files. Requires docker.
proto-lint:
@echo "--> Linting Protobuf files"
@$(DOCKER_BUF) lint --error-format=json
.PHONY: proto-lint
# Extract the latest Git tag as the version number
VERSION := $(shell git describe --tags --abbrev=0)
GITSHA := $(shell git rev-parse --short HEAD)
LDFLAGS := \
-X github.com/rollkit/rollkit/cmd/rollkit/commands.Version=$(VERSION) \
-X github.com/rollkit/rollkit/cmd/rollkit/commands.GitSHA=$(GITSHA)
## install: Install rollkit CLI
install:
@echo "--> Installing Rollkit CLI"
@go install -ldflags "$(LDFLAGS)" ./cmd/rollkit
@echo "--> Rollkit CLI Installed!"
@echo " Check the version with: rollkit version"
@echo " Check the binary with: which rollkit"
.PHONY: install
## prebuilt-binary: Create prebuilt binaries and attach them to GitHub release. Requires Docker.
prebuilt-binary:
@if [ ! -f ".release-env" ]; then \
echo "A .release-env file was not found but is required to create prebuilt binaries. This command is expected to be run in CI where a .release-env file exists. If you need to run this command locally to attach binaries to a release, you need to create a .release-env file with a Github token (classic) that has repo:public_repo scope."; \
exit 1;\
fi
docker run \
--rm \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean
.PHONY: prebuilt-binary