/
Makefile
81 lines (67 loc) · 2.6 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
SHA=$(shell git rev-parse --short HEAD)
VERSION=$(shell cat VERSION)
DIRTY=$(shell if `git diff-index --quiet HEAD --`; then echo false; else echo true; fi)
LDFLAGS=-ldflags "-w -s -X github.com/chanzuckerberg/blessclient/pkg/util.GitSha=${SHA} -X github.com/chanzuckerberg/blessclient/pkg/util.Version=${VERSION} -X github.com/chanzuckerberg/blessclient/pkg/util.Dirty=${DIRTY}"
export GOFLAGS=-mod=vendor
export GO111MODULE=on
export CGO_ENABLED=1
setup:
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- v1.16.0
curl -L https://raw.githubusercontent.com/chanzuckerberg/bff/master/download.sh | sh
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- v0.9.14
.PHONY: setup
test: deps ## run tests, will update vendor
go test -coverprofile=coverage.txt -covermode=atomic ./...
.PHONY: test
test-ci: ## run tests in CI, will fail if vendor is not up to date
go test -coverprofile=coverage.txt -covermode=atomic ./...
.PHONY: test
release: test ## Create a new tag and let travis_ci do the rest
bff bump
git push
git push --tags
.PHONY: release
build: ## build the binary
go build ${LDFLAGS} .
.PHONY: build
release-prerelease: test build ## release to github as a 'pre-release'
version=`./blessclient version`; \
git tag v"$$version"; \
git push
git push --tags
.PHONY: release-prerelease
publish-darwin:
goreleaser release -f .goreleaser.darwin.yml --debug
.PHONY: publish-darwin
publish-prerelease-darwin:
goreleaser release -f .goreleaser.prerelease.darwin.yml --debug
.PHONY: publish-prerelease-darwin
publish-linux: build ## Update the github release with a linux build. Must be run after release-darwin
tar -zcf blessclient.tar.gz blessclient
github-release upload \
--user chanzuckerberg \
--repo blessclient \
--tag ${TRAVIS_TAG} \
--name blessclient_${TRAVIS_TAG}_linux_amd64.tar.gz \
--file blessclient.tar.gz
.PHONY: publish-linux
install: deps
go install ${LDFLAGS} .
.PHONY: install
deps:
go mod tidy
go mod vendor
.PHONY: deps
lint: ## run the fast go linters
./bin/golangci-lint run --no-config \
--disable-all --enable=deadcode --enable=gocyclo --enable=golint --enable=varcheck \
--enable=structcheck --enable=errcheck --enable=dupl --enable=unparam --enable=goimports \
--enable=interfacer --enable=unconvert --enable=gosec --enable=megacheck
.PHONY: lint
lint-ci: ## run the fast go linters
./bin/reviewdog -conf .reviewdog.yml -reporter=github-pr-review
.PHONY: lint-ci
lint-all: ## run the fast go linters
# doesn't seem to be a way to get reviewdog to not filter by diff
./bin/golangci-lint run
.PHONY: lint-all