Last active
December 19, 2018 18:21
-
-
Save FGtatsuro/059f8b7a717b0bd7f0e3cb3fe1f38997 to your computer and use it in GitHub Desktop.
sample Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TAG = my_performance:0.1 | |
CONTAINER_NAME = my_performance_oneshot | |
TIME_ZONE = Asia/Tokyo | |
SRC = $(wildcard tests/*.py) $(wildcard tests/configs/*.py) $(wildcard tests/scenarios/*.py) | |
.PHONY: all build test result clean lint format tags unittest | |
all: test | |
build: .build | |
# Ref: https://www.gnu.org/software/make/manual/html_node/Wildcard-Examples.html#Wildcard-Examples | |
.build: Dockerfile requirements.txt setup.cfg $(SRC) | |
docker build -t $(TAG) . | |
touch .build | |
test: build | |
if [ -z "`docker ps | grep $(CONTAINER_NAME)`" ]; then \ | |
docker run -d --name $(CONTAINER_NAME) \ | |
-p 8089:8089 \ | |
-e TZ=$(TIME_ZONE) \ | |
-e PYTHONPATH=. \ | |
$(TAG) \ | |
locust -f $(LOCUST_FILE); \ | |
fi | |
docker logs -f $(CONTAINER_NAME) | |
test-scenario: build | |
docker run --rm --name $(CONTAINER_NAME) -e TZ=$(TIME_ZONE) $(TAG) \ | |
python -m $(SCENARIO_MODULE) | |
clean: | |
-docker rm -f $(CONTAINER_NAME) | |
rm -f .build | |
rm -rf tests/__pycache__ tests/configs/__pycache__ tests/scenarios/__pycache__ | |
# This target always return 0 as exit code. | |
# If you want to fail this target(ex. CI), you must create a wrapper script like: | |
# make lint 2>&1 | grep Error; if [ $? -eq 0 ]; then exit 1; fi | |
lint: | |
-flake8 $(SRC) | |
-pydocstyle $(SRC) | |
-mypy $(SRC) | |
# -isort --diff --recursive . | |
-isort --diff $(SRC) | |
format: | |
# autopep8 --in-place --aggressive --recursive . | |
autopep8 --in-place --aggressive $(SRC) | |
# isort --recursive . | |
isort $(SRC) | |
tags: Dockerfile requirements.txt setup.cfg $(SRC) | |
ctags -R --exclude=.mypy_cache | |
unittest: $(SRC) | |
find tests -name '*.py' | \ | |
grep -v -e '__init__.py' -e 'config' | \ | |
sed -e 's|.py||g' -e 's|/|.|g' | \ | |
xargs -L 1 -I {} python -c 'import {}, doctest, sys; r=doctest.testmod({}, verbose=True); sys.exit(r.failed!=0)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autopep8 | |
pydocstyle | |
mypy | |
git+https://github.com/PyCQA/flake8.git@master#egg=flake8 | |
isort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[pycodestyle] | |
[flake8] | |
max-line-length = 100 | |
# FYI: http://www.pydocstyle.org/en/stable/error_codes.html | |
# Conflict: | |
# - D203 vs D211 (FYI: https://github.com/PyCQA/pydocstyle/issues/141) | |
# - D212 vs D213 (FYI: https://github.com/PyCQA/pydocstyle/issues/242) | |
[pydocstyle] | |
ignore = D100,D101,D102,D103,D104,D105,D106,D107,D203,D213 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment