-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
87 lines (72 loc) · 2.09 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
78
79
80
81
82
83
84
85
86
87
SHELL := bash
TMPDIR ?= /tmp
RUNDIR ?= /tmp/travis-run.d
PREFIX ?= /usr/local
SHELLCHECK_URL := https://www.googleapis.com/download/storage/v1/b/shellcheck/o/shellcheck-v0.5.0.linux.x86_64.tar.xz?alt=media
SHFMT_URL := https://github.com/mvdan/sh/releases/download/v2.5.0/shfmt_v2.5.0_linux_amd64
TOP = $(shell git rev-parse --show-toplevel)
.PHONY: all
all: test
.PHONY: clean
clean:
@: noop
.PHONY: test
test:
bats $(wildcard *.bats)
.PHONY: systest
systest: .assert-ci
sudo -H DEBUG=1 RUNDIR=$(RUNDIR) $(TOP)/bin/tfw bootstrap
sudo -H DEBUG=1 RUNDIR=$(RUNDIR) $(TOP)/bin/tfw admin-bootstrap
.PHONY: sysseed
sysseed: .assert-ci
mkdir -p $(RUNDIR)
rsync -av $(TOP)/.testdata/rundir/ $(RUNDIR)
.PHONY: deps
deps: ensure-checkmake ensure-shellcheck ensure-shfmt
pip install -r requirements.txt
.PHONY: lint
lint:
checkmake Makefile &>/dev/null
shfmt -f bin/ | xargs shellcheck
shfmt -i 2 -w bin/
yapf -i -r -vv bin/
.PHONY: ensure-checkmake
ensure-checkmake:
if ! checkmake --version &>/dev/null; then \
go get github.com/mrtazz/checkmake; \
pushd $${GOPATH%%:*}/src/github.com/mrtazz/checkmake; \
make all install PREFIX=$(HOME); \
popd; \
fi
.PHONY: ensure-shellcheck
ensure-shellcheck:
if [[ $$(shellcheck --version | awk '/^version:/ { print $$2 }') != 0.5.0 ]]; then \
curl -sSL -o "$(TMPDIR)/shellcheck.tar.xz" "$(SHELLCHECK_URL)"; \
tar -C "$(HOME)/bin" --exclude="*.txt" --strip-components=1 -xf "$(TMPDIR)/shellcheck.tar.xz"; \
shellcheck --version; \
fi
.PHONY: ensure-shfmt
ensure-shfmt:
if [[ $$(shfmt -version 2>/dev/null) != v2.5.0 ]]; then \
curl -sSL "$(SHFMT_URL)" -o "$(HOME)/bin/shfmt"; \
chmod +x "$(HOME)/bin/shfmt"; \
shfmt -version; \
fi
USAGE.md: bin/tfw
echo '# Usage' >$@
./bin/tfw list-internal-commands | \
LC_ALL=C sort | \
awk '{ \
printf "\n## tfw help %s\n\n```\n", $$1; \
system("./bin/tfw help "$$1); \
print "```" \
}' >>$@
.PHONY: install
install:
install -D -m 0755 -t $(PREFIX)/bin $(wildcard bin/*)
.PHONY: .assert-ci
.assert-ci:
@[[ "$(TRAVIS)" && "$(CI)" ]] || { \
echo 'ERROR: $$TRAVIS and $$CI not detected!'; \
exit 1; \
}