Skip to content

Commit 0077313

Browse files
committed
Improvements to makefile
Signed-off-by: Brian Goff <[email protected]> (cherry picked from commit 6a4f8f3) Signed-off-by: Brian Goff <[email protected]>
1 parent 16b2a02 commit 0077313

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
go-md2man
2+
bin

.travis.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ matrix:
1212
- go: tip
1313

1414
script:
15-
- if [ "${TRAVIS_GO_VERSION}" = "stable" ]; then script/setup/dev-tools; fi
16-
- go build -i .
15+
- if [ "${TRAVIS_GO_VERSION}" = "stable" ]; then make golangci-lint
1716
- if [ "${TRAVIS_GO_VERSION}" = "stable" ]; then echo running check scripts; make check; fi
18-
- go build
19-
- go test -v ./...
17+
- make build
18+
- make TEST_FLAGS="-v" test

Makefile

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
LINTER_BIN ?= golangci-lint
2+
3+
.PHONY:
4+
build: bin/go-md2man
5+
6+
.PHONY: clean
7+
clean:
8+
@rm -rf bin/*
9+
110
.PHONY: check
2-
check:
3-
golangci-lint run
11+
check: lint
12+
13+
.PHONY: test
14+
test:
15+
@go test $(TEST_FLAGS) ./...
16+
17+
.PHONY: lint
18+
lint:
19+
@$(LINTER_BIN) run --new-from-rev "HEAD~$(git rev-list master.. --count)" ./...
20+
21+
bin/go-md2man: actual_build_flags := $(BUILD_FLAGS) -o bin/go-md2man
22+
bin/go-md2man: bin
23+
@CGO_ENABLED=0 go build $(actual_build_flags)
24+
25+
bin:
26+
@mkdir ./bin
27+
28+
$(LINTER_BIN): linter_bin_path := $(shell which $(LINTER_BIN))
29+
$(LINTER_BIN):
30+
@if [ -z $(linter_bin_path) ] || [ ! -x $(linter_bin_path) ]; then \
31+
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.15.0; \
32+
fi
33+

hack/ci/check_mods.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
exit_code=0
6+
7+
make mod
8+
git diff --exit-code go.mod go.sum || exit_code=$?
9+
10+
if [ ${exit_code} -eq 0 ]; then
11+
exit 0
12+
fi
13+
14+
echo "please run \`make mod\` and check in the changes"
15+
exit ${exit_code}

script/setup/dev-tools

-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
set -eu -o pipefail
44

5-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.15.0
6-
75
go get -u github.com/golang/dep/cmd/dep

0 commit comments

Comments
 (0)