bootstrapit updates

This commit is contained in:
Manuel Barkhau 2020-07-19 13:58:33 +00:00
parent e70c45403c
commit f1e17562b8
5 changed files with 251 additions and 26 deletions

View file

@ -300,9 +300,9 @@ git_hooks:
## -- Integration --
## Run flake8 linter and check for fmt
.PHONY: lint
lint:
## Run isort with --check-only
.PHONY: lint_isort
lint_isort:
@printf "isort ..\n"
@$(DEV_ENV)/bin/isort \
--check-only \
@ -314,6 +314,10 @@ lint:
src/ test/
@printf "\e[1F\e[9C ok\n"
## Run sjfmt with --check
.PHONY: lint_sjfmt
lint_sjfmt:
@printf "sjfmt ..\n"
@$(DEV_ENV)/bin/sjfmt \
--target-version=py36 \
@ -323,19 +327,36 @@ lint:
src/ test/ 2>&1 | sed "/All done/d" | sed "/left unchanged/d"
@printf "\e[1F\e[9C ok\n"
## Run flake8
.PHONY: lint_flake8
lint_flake8:
@rm -f reports/flake8*;
@mkdir -p "reports/";
@printf "flake8 ..\n"
@$(DEV_ENV)/bin/flake8 src/
@$(DEV_ENV)/bin/flake8 src/ --tee --output-file reports/flake8.txt || exit 0;
@$(DEV_ENV)/bin/flake8_junit reports/flake8.txt reports/flake8.xml >> /dev/null;
@$(DEV_ENV_PY) scripts/exit_0_if_empty.py reports/flake8.txt;
@printf "\e[1F\e[9C ok\n"
## Run flake8 linter and check for fmt
.PHONY: lint
lint: lint_isort lint_sjfmt lint_flake8
## Run mypy type checker
.PHONY: mypy
mypy:
@rm -rf ".mypy_cache";
@rm -rf "reports/mypycov";
@mkdir -p "reports/";
@printf "mypy ....\n"
@MYPYPATH=stubs/:vendor/ $(DEV_ENV_PY) -m mypy \
--html-report mypycov \
--html-report reports/mypycov \
--no-error-summary \
src/ | sed "/Generated HTML report/d"
@printf "\e[1F\e[9C ok\n"
@ -344,16 +365,10 @@ mypy:
## Run pylint. Should not break the build yet
.PHONY: pylint
pylint:
@printf "pylint ..\n";
@$(DEV_ENV)/bin/pylint --jobs=4 --output-format=colorized --score=no \
--disable=C0103,C0301,C0330,C0326,C0330,C0411,R0903,W1619,W1618,W1203 \
--extension-pkg-whitelist=ujson,lxml,PIL,numpy,pandas,sklearn,pyblake2 \
src/
@$(DEV_ENV)/bin/pylint --jobs=4 --output-format=colorized --score=no \
--disable=C0103,C0111,C0301,C0330,C0326,C0330,C0411,R0903,W1619,W1618,W1203 \
--extension-pkg-whitelist=ujson,lxml,PIL,numpy,pandas,sklearn,pyblake2 \
test/
@mkdir -p "reports/";
@printf "pylint ..\n";
@$(DEV_ENV)/bin/pylint --rcfile=setup.cfg src/ test/
@printf "\e[1F\e[9C ok\n"
@ -363,6 +378,9 @@ test:
@rm -rf ".pytest_cache";
@rm -rf "src/__pycache__";
@rm -rf "test/__pycache__";
@rm -rf "reports/testcov/";
@rm -f "reports/pytest*";
@mkdir -p "reports/";
# First we test the local source tree using the dev environment
ENV=$${ENV-dev} \
@ -371,8 +389,10 @@ test:
$(DEV_ENV_PY) -m pytest -v \
--doctest-modules \
--verbose \
--cov-report html \
--cov-report "html:reports/testcov/" \
--cov-report term \
--html=reports/pytest/index.html \
--junitxml reports/pytest.xml \
-k "$${PYTEST_FILTER}" \
$(shell cd src/ && ls -1 */__init__.py | awk '{ sub(/\/__init__.py/, "", $$1); print "--cov "$$1 }') \
test/ src/;
@ -394,9 +414,9 @@ test:
## -- Helpers --
## Run code formatter on src/ and test/
.PHONY: fmt
fmt:
## Run import sorting on src/ and test/
.PHONY: fmt_isort
fmt_isort:
@$(DEV_ENV)/bin/isort \
--force-single-line-imports \
--length-sort \
@ -405,6 +425,10 @@ fmt:
--project $(PKG_NAME) \
src/ test/;
## Run code formatter on src/ and test/
.PHONY: fmt_sjfmt
fmt_sjfmt:
@$(DEV_ENV)/bin/sjfmt \
--target-version=py36 \
--skip-string-normalization \
@ -412,10 +436,14 @@ fmt:
src/ test/;
## Run code formatters
.PHONY: fmt
fmt: fmt_isort fmt_sjfmt
## Shortcut for make fmt lint mypy test
## Shortcut for make fmt lint mypy devtest test
.PHONY: check
check: fmt lint mypy test
check: fmt lint mypy devtest test
## Start subshell with environ variables set.