forked from codehearts/shpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (68 loc) · 2.65 KB
/
Makefile
File metadata and controls
79 lines (68 loc) · 2.65 KB
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
REPO_ROOT=$(shell git rev-parse --show-toplevel)
DOCKER_FLAGS=-it --rm -e SHUNIT_COLOR=always
DOCKER_DEBIAN=debian:buster-20190708-slim
DOCKER_ZSH=zshusers/zsh:5.7.1
DOCKER_CHECKBASHISMS=manabu/checkbashisms-docker:0.1.0
DOCKER_SHELLCHECK=koalaman/shellcheck:latest
DOCKER_KCOV=kcov/kcov:v36
TESTS=$(wildcard t/test_*)
APP_TESTS=$(addprefix /app/, $(TESTS))
WORK_TESTS=$(addprefix /work/, $(TESTS))
.PHONY: check test test_bash test_dash test_sh test_zsh coverage lint
check: test
test: test_bash test_dash test_sh test_zsh
test_bash: docker_installed
ifeq (, $(shell docker images -q $(DOCKER_DEBIAN)))
@docker pull $(DOCKER_DEBIAN)
endif
@docker run $(DOCKER_FLAGS) -e SHELL=/bin/bash \
--mount type=bind,source=$(REPO_ROOT),target=/app,readonly \
$(DOCKER_DEBIAN) /bin/bash /app/t/run_tests
test_dash: docker_installed
ifeq (, $(shell docker images -q $(DOCKER_DEBIAN)))
@docker pull $(DOCKER_DEBIAN)
endif
@docker run $(DOCKER_FLAGS) -e SHELL=/bin/dash \
--mount type=bind,source=$(REPO_ROOT),target=/rootfs,readonly \
$(DOCKER_DEBIAN) /bin/dash -c /rootfs/t/run_tests
test_sh: docker_installed
ifeq (, $(shell docker images -q $(DOCKER_DEBIAN)))
@docker pull $(DOCKER_DEBIAN)
endif
@docker run $(DOCKER_FLAGS) -e SHELL=/bin/sh \
--mount type=bind,source=$(REPO_ROOT),target=/app,readonly \
$(DOCKER_DEBIAN) /bin/sh -c /app/t/run_tests
test_zsh: docker_installed
ifeq (, $(shell docker images -q $(DOCKER_ZSH)))
@docker pull $(DOCKER_ZSH)
endif
@docker run $(DOCKER_FLAGS) -e SHELL=/usr/bin/zsh -w /app \
--mount type=bind,source=$(REPO_ROOT),target=/app \
$(DOCKER_ZSH) /usr/bin/zsh -o shwordsplit -c /app/t/run_tests
lint: docker_installed
ifeq (, $(shell docker images -q $(DOCKER_CHECKBASHISMS)))
@docker pull $(DOCKER_CHECKBASHISMS)
endif
ifeq (, $(shell docker images -q $(DOCKER_SHELLCHECK)))
@docker pull $(DOCKER_SHELLCHECK)
endif
@docker run $(DOCKER_FLAGS) \
--mount type=bind,source=$(REPO_ROOT),target=/work,readonly \
$(DOCKER_CHECKBASHISMS) /work/shpy /work/shpy-shunit2 \
/work/t/run_tests $(WORK_TESTS)
@docker run $(DOCKER_FLAGS) \
--mount type=bind,source=$(REPO_ROOT),target=/app,readonly \
$(DOCKER_SHELLCHECK) /app/shpy /app/shpy-shunit2 \
/app/t/run_tests $(APP_TESTS)
coverage: docker_installed
ifeq (, $(shell docker images -q $(DOCKER_KCOV)))
@docker pull $(DOCKER_KCOV)
endif
@docker run $(DOCKER_FLAGS) --security-opt seccomp=unconfined \
-e SHELL=/bin/bash -e USE_KCOV=true \
--mount type=bind,source=$(REPO_ROOT),target=/source \
--entrypoint=/source/t/run_tests $(DOCKER_KCOV)
docker_installed:
ifeq (, $(shell which docker))
$(error Docker is required for testing, see https://www.docker.com to get set up)
endif