-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (36 loc) · 1.64 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
SHELL := /bin/bash
PROJECT_NAME = lodge
DOCKER_IMG := $(PROJECT_NAME):latest
DOCKER_RUN := docker run --rm -t
USER := -e USER_ID="$(shell id -u $$USER)" -e GROUP_ID="$(shell id -g $$USER)"
PYTEST := python -B -m pytest -vv -p no:cacheprovider
MOUNT_TEST := -v $(PWD)/test_lodge.py:/lodge/test_lodge.py
# Source https://gist.github.com/coryodaniel/5fb5503953ca799cd51adc6764324780
help: ## Print this beautiful help
@grep -E '^[a-zA-Z_0-9-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "argument '$*' is required"; \
exit 1; \
fi
clean: ## Clean the image
docker rmi $(DOCKER_IMG) --force
build: ## Build an image to run tests and linter
docker build -t $(DOCKER_IMG) .
shell: build ## Opens a shell to interact inside the container
$(DOCKER_RUN) -i $(DOCKER_IMG) bash
check: build ## Runs all tests
$(DOCKER_RUN) $(MOUNT_TEST) $(DOCKER_IMG) $(PYTEST) --cov=$(PROJECT_NAME)
check-interactive: build ## Runs all tests in interactive mode
$(DOCKER_RUN) $(MOUNT_TEST) -i $(DOCKER_IMG) $(PYTEST)
check-interactive/%: build ## Runs all tests in interactive mode
$(DOCKER_RUN) $(MOUNT_TEST) -i $(DOCKER_IMG) $(PYTEST) $*
lint: build # Run all static checks
$(DOCKER_RUN) $(MOUNT_TEST) $(DOCKER_IMG) mypy lodge.py test_lodge.py
$(DOCKER_RUN) $(MOUNT_TEST) $(DOCKER_IMG) flake8 lodge.py test_lodge.py
publish: check lint guard-VERSION
$(DOCKER_RUN) -e TWINE_USERNAME -e TWINE_PASSWORD $(DOCKER_IMG) bash -c \
"python setup.py build sdist bdist_wheel; \
twine upload --non-interactive dist/lodge-$(VERSION)-py3-none-any.whl"