-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (56 loc) · 2.13 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
ARTIFACT_ID=redis
MAKEFILES_VERSION=9.2.1
WORKSPACE=/workspace
ASSETS_BUILD_DIRECTORY=assets
BATS_LIBRARY_DIR=$(TARGET_DIR)/bats_libs
TESTS_DIR=./unitTests
BASH_TEST_REPORT_DIR=$(TARGET_DIR)/shell_test_reports
BASH_TEST_REPORTS=$(BASH_TEST_REPORT_DIR)/TestReport-*.xml
BATS_ASSERT=$(BATS_LIBRARY_DIR)/bats-assert
BATS_MOCK=$(BATS_LIBRARY_DIR)/bats-mock
BATS_SUPPORT=$(BATS_LIBRARY_DIR)/bats-support
BATS_FILE=$(BATS_LIBRARY_DIR)/bats-file
BATS_BASE_IMAGE?=bats/bats
BATS_CUSTOM_IMAGE?=cloudogu/bats
BATS_TAG?=1.2.1
.DEFAULT_GOAL:=dogu-release
include build/make/variables.mk
include build/make/self-update.mk
include build/make/release.mk
include build/make/k8s-dogu.mk
.PHONY unit-test-shell:
unit-test-shell: unit-test-shell-$(ENVIRONMENT)
$(BATS_ASSERT):
@git clone --depth 1 https://github.com/bats-core/bats-assert $@
$(BATS_MOCK):
@git clone --depth 1 https://github.com/grayhemp/bats-mock $@
$(BATS_SUPPORT):
@git clone --depth 1 https://github.com/bats-core/bats-support $@
$(BATS_FILE):
@git clone --depth 1 https://github.com/bats-core/bats-file $@
$(BASH_SRC):
BASH_SRC:=$(shell find "${WORKDIR}" -type f -name "*.sh")
${BASH_TEST_REPORT_DIR}: $(TARGET_DIR)
@mkdir -p $(BASH_TEST_REPORT_DIR)
unit-test-shell-ci: $(BASH_SRC) $(BASH_TEST_REPORT_DIR) $(BATS_ASSERT) $(BATS_MOCK) $(BATS_SUPPORT) $(BATS_FILE)
@echo "Test shell units on CI server"
@make unit-test-shell-generic
unit-test-shell-local: $(BASH_SRC) $(PASSWD) $(ETCGROUP) $(HOME_DIR) buildTestImage $(BASH_TEST_REPORT_DIR) $(BATS_ASSERT) $(BATS_MOCK) $(BATS_SUPPORT) $(BATS_FILE)
@echo "Test shell units locally (in Docker)"
@docker run --rm \
-v $(HOME_DIR):/home/$(USER) \
-v $(WORKDIR):$(WORKSPACE) \
-w $(WORKSPACE) \
--entrypoint="" \
$(BATS_CUSTOM_IMAGE):$(BATS_TAG) \
${TESTS_DIR}/customBatsEntrypoint.sh make unit-test-shell-generic
unit-test-shell-generic:
@bats --formatter junit --output ${BASH_TEST_REPORT_DIR} ${TESTS_DIR}
.PHONY buildTestImage:
buildTestImage:
@echo "Build shell test container"
@cd ${TESTS_DIR} && docker build \
--build-arg=BATS_BASE_IMAGE=${BATS_BASE_IMAGE} \
--build-arg=BATS_TAG=${BATS_TAG} \
-t ${BATS_CUSTOM_IMAGE}:${BATS_TAG} \
.