-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
71 lines (56 loc) · 2.08 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
################################################################################
# Variables
################################################################################
# set DOCKER_CLI_HINTS=false to disable docker for desktop messages
# ref.: https://forums.docker.com/t/how-to-turn-off-the-whats-new-message/140860
export DOCKER_CLI_HINTS = false
# Image name
IMAGE_NAME=dotfiles-test
# Container name
CONTAINER_NAME=dotfiles-test
# Path to the tests in the container
TEST_PATH=/home/testuser/.tests/
TESTRESULT_PATH=/home/testuser/.test_results/
################################################################################
# Targets
################################################################################
# Helper
################################################################################
.PHONY: gen_keybinding_docs
gen_keybinding_docs:
@`pwd`/.dotfileassets/gen_keymapping_md_table.sh
# Tests
################################################################################
# Default target: build the Docker image and run the tests
.PHONY: all
all: test
.PHONY: lint-md
lint-md:
@docker run --rm -v `pwd`:/workdir davidanson/markdownlint-cli2 "README.md"
# Build the Docker image
.PHONY: build
build:
@echo "Building Docker image..."
docker build -t $(IMAGE_NAME) -f .Dockerfile .
# Run all tests
.PHONY: test
test: build
@echo "Running tests..."
@mkdir -p `pwd`/.test_results
@docker run --name $(CONTAINER_NAME) -i -v `pwd`/.test_results:$(TESTRESULT_PATH) --rm $(IMAGE_NAME) bash -c "bats --formatter junit $(TEST_PATH) | tee $(TESTRESULT_PATH)/unit-test-result.xml"
# Run all tests and open shell in container for debugging
.PHONY: test
test-debug: build
@echo "Running tests..."
@docker run --name $(CONTAINER_NAME) -it --rm $(IMAGE_NAME) bash -c "bats -x -p -T --print-output-on-failure $(TEST_PATH); bash"
# Remove the Docker image
.PHONY: clean
clean:
@echo "Cleaning up..."
@rm -r `pwd`/.test_results
@docker rm -fv $(CONTAINER_NAME)
@docker rmi -f $(IMAGE_NAME)
# Open shell in the build image
.PHONY: shell
shell: build
@docker run -it --rm $(IMAGE_NAME) bash