-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.ext
77 lines (66 loc) · 3.09 KB
/
Makefile.ext
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
LDFLAGS := -X main.Config=$(CURDIR)/config
clean::
find -name "__debug_bin*" -exec rm -vrf {} \;;
bump:: version-bump
version-bump version-bump-reset::
@VERSION="$$(cat VERSION)"; \
sed -i -e "s#\(github.com[/:]tkrop/go-make@v\)[^ ]*#\1$${VERSION}#" \
Makefile config/Makefile config/Makefile.base; \
commit::
@for FILE in $$(find config -type f ! -name "Makefile.vars" ! -name "Makefile"); do \
if [ -f "$${FILE#*/}" ] && [ -n "$$(diff "$${FILE}" "$${FILE#*/}")" ]; then \
echo "error: $${FILE} (not synchronized)" > "/dev/stderr"; exit -1; \
fi; \
done;
sync::
@for FILE in $$(find config -type f ! -name "Makefile.vars"); do \
if [ -f "$${FILE#*/}" ] && [ -n "$$(diff "$${FILE}" "$${FILE#*/}")" ]; then \
echo "sync: $${FILE#*/} => $${FILE}"; cp "$${FILE#*/}" "$${FILE}"; \
fi; \
done;
test-git-message:: test-git-message-fix
$(addprefix test-git-message-,$(COMMIT_CONVENTION)):: test-git-message-%:
@MESSAGE="$(RUNARGS)"; $(call git-message,$*,1); echo "$${MESSAGE}";
test-check-version::
@$(call go-check-version,go-make,$(RUNARGS),)
test-args::
@$(call test-args,$(RUNARGS))
# TODO: fix ordering issue.
test-test-args::
@ACTUAL=($$(make -f Makefile.base test-args scope:all cmd/TestCmd)) && \
EXPECTED=("-coverpkg=./..." "./cmd" "-run" "TestCmd") && \
DIFF="$$(diff <(echo "$${ACTUAL[*]}") <(echo "$${EXPECTED[*]}"))" && \
ACTUAL=($$(make -f Makefile.base test-args scope:all internal/make)) && \
EXPECTED=("-coverpkg=./..." "./internal/make") && \
DIFF="$$(diff <(echo "$${ACTUAL[*]}") <(echo "$${EXPECTED[*]}"))" && \
ACTUAL=($$(make -f Makefile.base test-args internal/make/make_test.go)) && \
EXPECTED=($$(find ./internal/make -name "*.go" | sort -u)) && \
DIFF="$$(diff <(echo "$${ACTUAL[*]}") <(echo "$${EXPECTED[*]}"))" && \
echo "info: test-args finished successful!!" || echo "$${DIFF}";
# Not sure whether this helps - showing allways diff in timings.
test-compat::
@ACTUAL="$$(make --makefile=$(GOMAKE_MAKEFILE) test-self 2>&1)" && \
COMPAT="$$(BASH_COMPAT=3.2 make --makefile=$(GOMAKE_MAKEFILE) test-self 2>&1)" && \
DIFF="$$(diff <(echo "$${ACTUAL}") <(echo "$${COMPAT}"))" && \
echo "info: test-compat finished successful!!" || echo "$${DIFF}";
CI_IMAGE_VERSION ?= latest
CI_IMAGE ?= pierone.stups.zalan.do/cdp-runtime/go:${CI_IMAGE_VERSION}
#@ test build in continuous integration container.
test-cdp:
@if tty -s; then TTY="--tty"; fi; DIRUSER=root; \
DIR=$$(mktemp -d); mkdir -p $${DIR}/.ssh; \
( cat $${HOME}/.gitconfig; \
echo -e '[safe]\n\tdirectory = /workspace' \
) >> $${DIR}/.gitconfig; \
cp ${HOME}/.ssh/{id_*,config,known_hosts} $${DIR}/.ssh; \
sudo chown --recursive root:root $${DIR}; \
trap "sudo rm -rf $${DIR}" EXIT INT TERM; \
$(IMAGE_CMD) run $${TTY} --interactive --rm \
--privileged --network host --workdir="/workspace" \
--env SSH_AUTH_SOCK=/ssh-agent \
--mount type=bind,source=$${SSH_AUTH_SOCK},target=/ssh-agent \
--volume=/var/run/docker.sock:/var/run/docker.sock \
--volume=$${DIR}/.gitconfig:/$${DIRUSER}/.gitconfig \
--volume=$${DIR}/.ssh:/$${DIRUSER}/.ssh \
--volume=$${PWD}:/workspace \
${CI_IMAGE} /bin/bash $(ARGS);