forked from honeycombio/refinery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (77 loc) · 2.48 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
88
89
90
91
92
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
GOTESTCMD = $(if $(shell command -v gotestsum),gotestsum --junitfile ./test_results/$(1).xml --format testname --,go test)
.PHONY: test
#: run all tests
test: test_with_race test_all
.PHONY: test_with_race
#: run only tests tagged with potential race conditions
test_with_race: test_results wait_for_redis
@echo
@echo "+++ testing - race conditions?"
@echo
$(call GOTESTCMD,$@) -tags race --race --timeout 60s -v ./...
.PHONY: test_all
#: run all tests, but with no race condition detection
test_all: test_results wait_for_redis
@echo
@echo "+++ testing - all the tests"
@echo
$(call GOTESTCMD,$@) -tags all --timeout 60s -v ./...
test_results:
@mkdir -p test_results
.PHONY: wait_for_redis
# wait for Redis to become available for test suite
wait_for_redis: dockerize
@echo
@echo "+++ We need a Redis running to run the tests."
@echo
@echo "Checking with dockerize $(shell ./dockerize --version)"
@./dockerize -wait tcp://localhost:6379 -timeout 30s
# ensure the dockerize command is available
dockerize: dockerize.tar.gz
tar xzvmf dockerize.tar.gz
HOST_OS := $(shell uname -s | tr A-Z a-z)
# You can override this version from an environment variable.
DOCKERIZE_VERSION ?= v0.6.1
DOCKERIZE_RELEASE_ASSET := dockerize-${HOST_OS}-amd64-${DOCKERIZE_VERSION}.tar.gz
dockerize.tar.gz:
@echo
@echo "+++ Retrieving dockerize tool for Redis readiness check."
@echo
# make sure that file is available
ifeq (, $(shell command -v file))
sudo apt-get update
sudo apt-get -y install file
endif
curl --location --silent --show-error \
--output dockerize.tar.gz \
https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/${DOCKERIZE_RELEASE_ASSET} \
&& file dockerize.tar.gz | grep --silent gzip
.PHONY: clean
clean:
rm -f dockerize.tar.gz
rm -f dockerize
rm -rf test_results
.PHONY: install-tools
install-tools:
go install github.com/google/go-licenses@v1.0.0
.PHONY: update-licenses
update-licenses: install-tools
rm -rf LICENSES; \
go-licenses save --save_path LICENSES ./cmd/refinery;
.PHONY: verify-licenses
verify-licenses:
echo "Passed"
skipped-verify-licenses: install-tools
rm -rf temp; \
go-licenses save --save_path temp ./cmd/refinery; \
if diff temp LICENSES > /dev/null; then \
echo "Passed"; \
rm -rf temp; \
else \
echo "LICENSES directory must be updated. Run make update-licenses"; \
rm -rf temp; \
exit 1; \
fi; \