This repository has been archived by the owner on Feb 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (59 loc) · 2.63 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
# Protobuf parameters
PROTOS=$(shell find proto -name '*.proto')
PROTOS_GO=$(PROTOS:.proto=.pb.go)
# Linter parameters
GO_LINT_CMD=golangci-lint
GO_LINT=$(GO_LINT_CMD) run --build-tags="lint" --deadline=4m --disable="ineffassign" --disable="gas" --tests=false --skip-files=".*\\.pb.go"
# Test parameters
COVERAGE_FILE=coverage.txt
# Test data
TESTDATA_FILE=./samples/go-samples.json
# == .PHONY ===================================================================
.PHONY: dep golangcilint deps build lint test coverage protobuf update_chainscript docker testdata_generate testdata_validate
# == all ======================================================================
all: build
# == deps =====================================================================
dep:
go get -u github.com/golang/dep/cmd/dep
golangcilint:
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
deps: dep golangcilint
dep ensure
# == build ====================================================================
build:
go build ./...
# == lint =====================================================================
lint:
$(GO_LINT) ./...
# == test =====================================================================
test:
go test ./...
# == coverage =================================================================
coverage: $(COVERAGE_FILE)
$(COVERAGE_FILE):
go test ./... -coverprofile=$(COVERAGE_FILE) -covermode=atomic
# == protobuf =================================================================
protobuf: $(PROTOS_GO)
%.pb.go: %.proto
protoc --go_out=. -Iproto $<
# == update_chainscript =======================================================
update_chainscript: SHELL:=/bin/bash
update_chainscript:
@if [[ -n $$(git diff --stat) ]]; then \
echo "Chainscript cannot be updated: you have unstaged changes in your working tree. Please commit or stash your current work and retry." 1>&2; false; \
elif [[ -n $$(git status -s) ]]; then \
echo "Chainscript cannot be updated: you have staged changes. Please commit or stash your current work and retry." 1>&2; false; \
else \
rm -r ./proto; \
git commit -m -a "removing old chainscript subtree"; \
git subtree add --prefix proto git@github.com:stratumn/chainscript.git master --squash; \
fi
# == docker ===================================================================
docker:
docker build -t stratumn/go-chainscript:latest .
# == testdata_generate ========================================================
testdata_generate:
go run cmd/*.go generate $(TESTDATA_FILE)
# == testdata_validate ========================================================
testdata_validate:
go run cmd/*.go validate $(TESTDATA_FILE)