forked from containers/tar-diff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (55 loc) · 2.13 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
.PHONY: all build clean fmt install lint test tools unit-test integration-test validate .install.gitvalidation .install.golangci-lint .gitvalidation
export GOPROXY=https://proxy.golang.org
GOBIN := $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN := $(GOPATH)/bin
endif
BUILDFLAGS :=
PACKAGES := $(shell GO111MODULE=on go list $(BUILDFLAGS) ./...)
SOURCE_DIRS = $(shell echo $(PACKAGES) | awk 'BEGIN{FS="/"; RS=" "}{print $$4}' | uniq)
PREFIX ?= ${DESTDIR}/usr
INSTALLDIR=${PREFIX}/bin
export PATH := $(PATH):${GOBIN}
all: tools tar-diff tar-patch test validate .gitvalidation
build:
GO111MODULE="on" go build $(BUILDFLAGS) ./...
tar-diff:
GO111MODULE="on" go build $(BUILDFLAGS) ./cmd/tar-diff
tar-patch:
GO111MODULE="on" go build $(BUILDFLAGS) ./cmd/tar-patch
install: tar-diff tar-patch
install -d -m 755 ${INSTALLDIR}
install -m 755 tar-diff ${INSTALLDIR}/tar-diff
install -m 755 tar-patch ${INSTALLDIR}/tar-patch
tools: .install.gitvalidation .install.golangci-lint
.install.gitvalidation:
if [ ! -x "$(GOBIN)/git-validation" ]; then \
GO111MODULE="off" go get $(BUILDFLAGS) github.com/vbatts/git-validation; \
fi
.install.golangci-lint:
if [ ! -x "$(GOBIN)/golangci-lint" ]; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOBIN) v1.25.0; \
fi
clean:
rm -f tar-diff tar-patch
integration-test: tar-diff tar-patch
tests/test.sh
unit-test:
GO111MODULE="on" go test $(BUILDFLAGS) -cover ./...
test: unit-test integration-test
fmt:
@gofmt -l -s -w $(SOURCE_DIRS)
validate: lint
@GO111MODULE="on" go vet ./...
@test -z "$$(gofmt -s -l . | tee /dev/stderr)"
lint:
$(GOBIN)/golangci-lint run
.gitvalidation:
@which $(GOBIN)/git-validation > /dev/null 2>/dev/null || (echo "ERROR: git-validation not found. Consider 'make clean && make tools'" && false)
ifeq ($(TRAVIS),true)
$(GOBIN)/git-validation -q -run DCO,short-subject,dangling-whitespace
else
git fetch -q "https://github.com/containers/tar-diff.git" "refs/heads/master"
upstream="$$(git rev-parse --verify FETCH_HEAD)" ; \
$(GOBIN)/git-validation -q -run DCO,short-subject,dangling-whitespace -range $$upstream..HEAD
endif