-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (50 loc) · 1.52 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
MAKEFLAGS += --silent
SHELL := /usr/bin/env bash
PROJECT_NAME := github.com/carlosonunez/status
.PHONY: test unit e2e init tidy component _component_%
usage: ## Prints this help text.
printf "make [target]\n\
Hack on $$(make project_name).\n\
\n\
TARGETS\n\
\n\
$$(fgrep -h '##' $(MAKEFILE_LIST) | fgrep -v '?=' | fgrep -v grep | sed 's/\\$$//' | sed -e 's/##//' | sed 's/^/ /g')\n\
\n\
ENVIRONMENT VARIABLES\n\
\n\
$$(fgrep '?=' $(MAKEFILE_LIST) | grep -v grep | sed 's/\?=.*##//' | sed 's/^/ /g')\n\
\n\
NOTES\n\
\n\
- Adding a new stage? Add a comment with two pound signs after the stage name to add it to this help text.\n"
test: unit component e2e # Runs all tests
unit: _verify_ginkgo
unit: # Runs unit tests.
ginkgo --label-filter '!e2e && !component' ./...
e2e: _verify_ginkgo
e2e: # Runs e2e feature suites.
ginkgo --label-filter tests/...
component: _verify_ginkgo _component_pub_sub
init: _verify_go
init:
test -f go.mod || go mod init "$(PROJECT_NAME)"; \
$(MAKE) tidy
tidy: _verify_go
go mod tidy
_verify_go:
if ! which go &>/dev/null; \
then \
>&2 echo "ERROR: Golang is not installed. Please install it first."; \
exit 1; \
fi; \
exit 0
_verify_ginkgo:
if ! which ginkgo &>/dev/null; \
then \
>&2 echo "ERROR: ginkgo not installed; run go get github.com/onsi/gingko/v2/ginkgo to do so"; \
exit 1; \
fi
_component_%:
component=$$(echo "$@" | sed 's/^_component_//'); \
>&2 echo "===> Running tests against third-party component: $$component"; \
ginkgo --label-filter 'component' "third_party/$$component/..."