-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (104 loc) · 4.49 KB
/
Copy pathMakefile
File metadata and controls
132 lines (104 loc) · 4.49 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
PWD := $(shell pwd)
GOPATH := $(shell go env GOPATH)
LDFLAGS := $(shell go run buildscripts/gen-ldflags.go)
TARGET_GOARCH ?= $(shell go env GOARCH)
TARGET_GOOS ?= $(shell go env GOOS)
VERSION ?= $(shell git describe --tags)
TAG ?= "pgsty/mc:$(VERSION)"
GOLANGCI = $(GOPATH)/bin/golangci-lint
GOLANGCI_VERSION ?= v2.13.1
GOLANGCI_MODULE = github.com/golangci/golangci-lint/v2/cmd/golangci-lint
.PHONY: credits check-credits check-dependency-floors
all: build
checks:
@echo "Checking dependencies"
@(env bash $(PWD)/buildscripts/checkdeps.sh)
getdeps:
@mkdir -p ${GOPATH}/bin
@if ! $(GOLANGCI) version 2>/dev/null | grep -qF " $(patsubst v%,%,$(GOLANGCI_VERSION)) "; then \
set -e; \
echo "Installing golangci-lint $(GOLANGCI_VERSION)"; \
GOBIN=$(GOPATH)/bin GOFLAGS= go install $(GOLANGCI_MODULE)@$(GOLANGCI_VERSION); \
fi
@echo "Installing module tools" && go install tool
crosscompile:
@(env bash $(PWD)/buildscripts/cross-compile.sh)
verifiers: getdeps vet lint check-brand check-credits
check-dependency-floors:
@echo "Checking dependency floors"
@go run ./buildscripts/check-dependency-floors
credits:
@env bash $(PWD)/buildscripts/gen-credits.sh
check-credits:
@echo "Checking third-party credits"
@tmp=$$(mktemp); \
trap 'rm -f "$$tmp"' EXIT; \
env bash $(PWD)/buildscripts/gen-credits.sh "$$tmp"; \
if ! cmp -s CREDITS "$$tmp"; then \
echo "CREDITS is stale; run 'make credits'" >&2; \
diff -u CREDITS "$$tmp" || true; \
exit 1; \
fi
check-brand:
@echo "Running $@ check"
@(env bash $(PWD)/buildscripts/check-branding.sh)
docker: build
@docker build -t $(TAG) . -f Dockerfile.dev
vet:
@echo "Running $@"
@GO111MODULE=on go vet github.com/minio/mc/...
lint-fix: getdeps ## runs golangci-lint suite of linters with automatic fixes
@echo "Running $@ check"
@$(GOLANGCI) run --build-tags kqueue --timeout=10m --config ./.golangci.yml --fix
lint: getdeps
@echo "Running $@ check"
@$(GOLANGCI) run --build-tags kqueue --timeout=10m --config ./.golangci.yml
# Builds mc, runs the verifiers then runs the tests.
check: test
test: verifiers build
@echo "Running unit tests"
@GO111MODULE=on CGO_ENABLED=0 go test -tags kqueue ./... 1>/dev/null
@echo "Running functional tests"
@GO111MODULE=on MC_TEST_RUN_FULL_SUITE=true go test -race -v --timeout 20m ./... -run Test_FullSuite
test-race: verifiers build
@echo "Running unit tests under -race"
@GO111MODULE=on go test -race -v --timeout 20m ./... 1>/dev/null
# Verify mc binary
verify:
@echo "Verifying build with race"
@GO111MODULE=on CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/mc 1>/dev/null
@echo "Running functional tests"
@GO111MODULE=on MC_TEST_RUN_FULL_SUITE=true go test -race -v --timeout 20m ./... -run Test_FullSuite
# Builds mc locally.
build: checks
@echo "Building mc binary to './mc'"
@GO111MODULE=on GOOS=$(TARGET_GOOS) GOARCH=$(TARGET_GOARCH) CGO_ENABLED=0 go build -trimpath -tags kqueue --ldflags "$(LDFLAGS)" -o $(PWD)/mc
hotfix-vars:
$(eval LDFLAGS := $(shell MC_RELEASE="RELEASE" MC_HOTFIX="hotfix.$(shell git rev-parse --short HEAD)" go run buildscripts/gen-ldflags.go $(shell git describe --tags --abbrev=0 | \
sed 's#RELEASE\.\([0-9]\+\)-\([0-9]\+\)-\([0-9]\+\)T\([0-9]\+\)-\([0-9]\+\)-\([0-9]\+\)Z#\1-\2-\3T\4:\5:\6Z#')))
$(eval VERSION := $(shell git describe --tags --abbrev=0).hotfix.$(shell git rev-parse --short HEAD))
$(eval TAG := "pgsty/mc:$(VERSION)")
hotfix: hotfix-vars install ## builds mc binary with hotfix tags
@mv -f ./mc ./mc.$(VERSION)
@minisign -qQSm ./mc.$(VERSION) -s "${CRED_DIR}/minisign.key" < "${CRED_DIR}/minisign-passphrase"
@sha256sum < ./mc.$(VERSION) | sed 's, -,mc.$(VERSION),g' > mc.$(VERSION).sha256sum
hotfix-push:
@echo "hotfix-push is disabled: publish fork artifacts through the pgsty/mc GitHub release workflow" >&2
@false
docker-hotfix-push: docker-hotfix
@docker push -q $(TAG) && echo "Published new container $(TAG)"
docker-hotfix: hotfix checks ## builds mc docker container with hotfix tags
@echo "Building mc docker image '$(TAG)'"
@docker build -q --no-cache -t $(TAG) --build-arg RELEASE=$(VERSION) . -f Dockerfile.hotfix
# Builds mc and installs it to $GOPATH/bin.
install: build
@echo "Installing mc binary to '$(GOPATH)/bin/mc'"
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/mc $(GOPATH)/bin/mc
@echo "Installation successful. To learn more, try \"mc --help\"."
clean:
@echo "Cleaning up all the generated files"
@find . -name '*.test' | xargs rm -fv
@find . -name '*~' | xargs rm -fv
@rm -rvf mc
@rm -rvf build
@rm -rvf release