forked from anton-yurchenko/git-release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (41 loc) · 1.3 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
I := "⚪"
E := "🔴"
BINARY := $(notdir $(CURDIR))
GO_BIN_DIR := $(GOPATH)/bin
OSES := windows linux
ARCHS := amd64
test: lint
@echo "$(I) unit testing... [this may take a couple of minutes]"
@go test -v $$(go list ./... | grep -v vendor | grep -v mocks) -race -coverprofile=coverage.txt -covermode=atomic
.PHONY: lint
lint: $(GO_LINTER)
@echo "$(I) vendoring..."
@go mod vendor || (echo "$(E) 'go mod vendor' error"; exit 1)
@go mod tidy || (echo "$(E) 'go mod tidy' error"; exit 1)
@echo "$(I) linting..."
@golangci-lint run ./... || (echo "$(E) linter error"; exit 1)
.PHONY: init
init:
@rm -rf go.mod go.sum ./vendor
@go mod init $$(pwd | awk -F'/' '{print $$NF}')
.PHONY: build
build: test
@echo "$(I) building binaries for javascript executor..."
@rm -rf ./bin
@mkdir -p bin
@for ARCH in $(ARCHS); do \
for OS in $(OSES); do \
if test "$$OS" = "windows"; then \
GOOS=$$OS GOARCH=$$ARCH go build -o bin/$(BINARY)-$$OS-$$ARCH.exe; \
else \
GOOS=$$OS GOARCH=$$ARCH go build -o bin/$(BINARY)-$$OS-$$ARCH; \
fi; \
done; \
done
.PHONY: codecov
codecov: test
@go tool cover -html=coverage.txt || (echo "$(E) 'go tool cover' error"; exit 1)
GO_LINTER := $(GO_BIN_DIR)/golangci-lint
$(GO_LINTER):
@echo "installing linter..."
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint