/
Makefile
65 lines (56 loc) · 1.7 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
PACKAGES ?= mountinfo mount sequential signal symlink user
BINDIR ?= _build/bin
CROSS ?= linux/arm linux/arm64 linux/ppc64le linux/s390x \
freebsd/amd64 openbsd/amd64 darwin/amd64 darwin/arm64 windows/amd64
SUDO ?= sudo -n
test test-local: RUN_VIA_SUDO = $(shell $(SUDO) true && echo -exec \"$(SUDO)\")
.PHONY: all
all: clean lint test cross
.PHONY: clean
clean:
$(RM) mount/go-local.*
.PHONY: test
test: test-local
set -eu; \
for p in $(PACKAGES); do \
(cd $$p; go test $(RUN_VIA_SUDO) -v .); \
done
.PHONY: tidy
tidy:
set -eu; \
for p in $(PACKAGES); do \
(cd $$p; go mod tidy); \
done
# Test the mount module against the local mountinfo source code instead of the
# release specified in its go.mod. This allows catching regressions / breaking
# changes in mountinfo.
.PHONY: test-local
test-local: MOD = -modfile=go-local.mod
test-local:
echo 'replace github.com/moby/sys/mountinfo => ../mountinfo' | cat mount/go.mod - > mount/go-local.mod
# Run go mod tidy to make sure mountinfo dependency versions are met.
cd mount && go mod tidy $(MOD) && go test $(MOD) $(RUN_VIA_SUDO) -v .
$(RM) mount/go-local.*
.PHONY: lint
lint: $(BINDIR)/golangci-lint
$(BINDIR)/golangci-lint version
set -eu; \
for p in $(PACKAGES); do \
(cd $$p; \
go mod download; \
../$(BINDIR)/golangci-lint run); \
done
$(BINDIR)/golangci-lint: $(BINDIR)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BINDIR) v1.45.2
$(BINDIR):
mkdir -p $(BINDIR)
.PHONY: cross
cross:
set -eu; \
for osarch in $(CROSS); do \
export GOOS=$${osarch%/*} GOARCH=$${osarch#*/}; \
echo "# building for $$GOOS/$$GOARCH"; \
for p in $(PACKAGES); do \
(cd $$p; go build .); \
done; \
done