-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
76 lines (61 loc) · 1.97 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
#!/usr/bin/make -f
VERSION := $(shell echo $(shell git describe --tags 2>/dev/null || git log -1 --format='%h') | sed 's/^v//')
DOCKER := $(shell which docker)
versioningPath := "github.com/celestiaorg/blobstream-ops/cmd/blobstream-ops/version"
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)'"
all: install
.PHONY: all
install: mod-verify
@echo "--> Installing blobstream-ops"
@go install -mod=readonly ${LDFLAGS} ./cmd/blobstream-ops
.PHONY: install
mod-verify: mod
@echo "--> Verifying dependencies have expected content"
GO111MODULE=on go mod verify
.PHONY: mod-verify
mod:
@echo "--> Updating go.mod"
@go mod tidy
.PHONY: mod
pre-build:
@echo "--> Fetching latest git tags"
@git fetch --tags
.PHONY: pre-build
build: mod
@mkdir -p build/
@go build -o build ${LDFLAGS} ./cmd/blobstream-ops
.PHONY: build
build-docker:
@echo "--> Building Docker image"
@$(DOCKER) build -t celestiaorg/blobstream-ops -f Dockerfile .
.PHONY: build-docker
lint:
@echo "--> Running golangci-lint"
@golangci-lint run
@echo "--> Running markdownlint"
@markdownlint --config .markdownlint.yaml '**/*.md'
.PHONY: lint
fmt:
@echo "--> Running golangci-lint --fix"
@golangci-lint run --fix
@echo "--> Running markdownlint --fix"
@markdownlint --fix --quiet --config .markdownlint.yaml .
.PHONY: fmt
test:
@echo "--> Running unit tests"
@go test -mod=readonly ./...
.PHONY: test
test-all: test-race test-cover
.PHONY: test-all
test-race:
@echo "--> Running tests with -race"
@VERSION=$(VERSION) go test -mod=readonly -race -test.short ./...
.PHONY: test-race
test-cover:
@echo "--> Generating coverage.txt"
@export VERSION=$(VERSION); bash -x scripts/test_cover.sh
.PHONY: test-cover
benchmark:
@echo "--> Running tests with -bench"
@go test -mod=readonly -bench=. ./...
.PHONY: benchmark