Skip to content

Commit

Permalink
feat: update pytest usage with Makefile (some clean along...)
Browse files Browse the repository at this point in the history
  • Loading branch information
duboise-cnes committed Sep 15, 2023
1 parent da6493a commit 8dd3e3e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
38 changes: 19 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ help: ## this help
.PHONY: venv
venv: ## create virtualenv in "venv" dir if not exists
@test -d ${VENV} || python3 -m venv ${VENV}
@${VENV}/bin/python -m pip install --upgrade pip setuptools wheel # no check to upgrade each time
@${VENV}/bin/python -m pip install --upgrade pip setuptools wheel # no check to upgrade each time install is run
@touch ${VENV}/bin/activate

.PHONY: install
Expand All @@ -85,15 +85,15 @@ install: venv ## install the package in dev mode in virtualenv
## Test section

.PHONY: test
test: install ## run tests and coverage quickly with the default Python
@${VENV}/bin/pytest -o log_cli=true -o log_cli_level=${LOGLEVEL} --cov-config=.coveragerc --cov --cov-report=term-missing
test: ## run tests and coverage quickly with the default Python
@${VENV}/bin/pytest -o log_cli_level=${LOGLEVEL} --cov-config=.coveragerc --cov --cov-report=term-missing

.PHONY: test-all
test-all: install ## run tests on every Python version with tox
test-all: ## run tests on every Python version with tox
@${VENV}/bin/tox -r -p auto ## recreate venv (-r) and parallel mode (-p auto)

.PHONY: coverage
coverage: install ## check code coverage quickly with the default Python
coverage: ## check code coverage quickly with the default Python
@${VENV}/bin/coverage run --source shareloc -m pytest
@${VENV}/bin/coverage report -m
@${VENV}/bin/coverage html
Expand All @@ -104,22 +104,22 @@ coverage: install ## check code coverage quickly with the default Python
### Format with isort and black

.PHONY: format
format: install format/isort format/black ## run black and isort formatting (depends install)
format: format/isort format/black ## run black and isort formatting

.PHONY: format/isort
format/isort: install ## run isort formatting (depends install)
format/isort: ## run isort formatting
@echo "+ $@"
@${VENV}/bin/isort shareloc tests

.PHONY: format/black
format/black: install ## run black formatting (depends install)
format/black: ## run black formatting
@echo "+ $@"
@${VENV}/bin/black shareloc tests

### Check code quality and linting : isort, black, flake8, pylint

.PHONY: lint
lint: install lint/isort lint/black lint/flake8 lint/pylint ## check code quality and linting
lint: lint/isort lint/black lint/flake8 lint/pylint ## check code quality and linting

.PHONY: lint/isort
lint/isort: ## check imports style with isort
Expand Down Expand Up @@ -157,7 +157,7 @@ docs: install ## generate Sphinx HTML documentation, including API docs
## Notebook section

.PHONY: notebook
notebook: install ## Install Jupyter notebook kernel with venv
notebook: ## Install Jupyter notebook kernel with venv
@echo "Install Jupyter Kernel and launch Jupyter notebooks environment"
@${VENV}/bin/python -m ipykernel install --sys-prefix --name=shareloc-$(VENV) --display-name=shareloc-$(VERSION)
@echo " --> After virtualenv activation, please use following command to launch local jupyter notebook to open Notebooks:"
Expand Down Expand Up @@ -193,15 +193,15 @@ release: dist ## package and upload a release
## Clean section

.PHONY: clean
clean: clean-venv clean-build clean-precommit clean-pyc clean-test clean-docs clean-notebook ## remove all build, test, precommit, coverage, notebook checkpoints and Python artifacts
clean: clean-venv clean-build clean-precommit clean-pyc clean-test clean-docs clean-notebook ## remove all venv, build, precommit, python artifacts, test, docs, notebook cache

.PHONY: clean-venv
clean-venv:
clean-venv: ## clean installed venv
@echo "+ $@"
@rm -rf ${VENV}

.PHONY: clean-build
clean-build: ## remove build artifacts
clean-build: ## clean build artifacts
@echo "+ $@"
@rm -fr build/
@rm -fr dist/
Expand All @@ -210,19 +210,19 @@ clean-build: ## remove build artifacts
@find . -name '*.egg' -exec rm -f {} +

.PHONY: clean-precommit
clean-precommit:
clean-precommit: ## clean precommit
@rm -f .git/hooks/pre-commit
@rm -f .git/hooks/pre-push

.PHONY: clean-pyc
clean-pyc: ## remove Python file artifacts
clean-pyc: ## clean python file artifacts
@echo "+ $@"
@find . -type f -name "*.py[co]" -exec rm -fr {} +
@find . -type d -name "__pycache__" -exec rm -fr {} +
@find . -name '*~' -exec rm -fr {} +

.PHONY: clean-test
clean-test: ## remove test and coverage artifacts
clean-test: ## clean test and coverage artifacts
@echo "+ $@"
@rm -fr .tox/
@rm -f .coverage
Expand All @@ -235,19 +235,19 @@ clean-test: ## remove test and coverage artifacts
@rm -f debug.log

.PHONY: clean-docs
clean-docs:
clean-docs: ## clean generated docs
@echo "+ $@"
@rm -rf docs/build/
@rm -rf docs/source/api_reference/
@rm -rf docs/source/apidoc/

.PHONY: clean-notebook
clean-notebook:
clean-notebook: ## clean notebooks cache
@echo "+ $@"
@find . -type d -name ".ipynb_checkpoints" -exec rm -fr {} +

.PHONY: clean-docker
clean-docker:
clean-docker: ## clean shareloc docker images
@echo "+ $@"
@echo "Clean Docker image shareloc ${VERSION_MIN}"
@docker image rm cnes/shareloc:${VERSION_MIN}
Expand Down
4 changes: 2 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# content of pytest.ini
[pytest]
log_cli = 1
log_cli_level = info
log_cli = 0
log_cli_level = WARNING
log_cli_date_format=%y-%m-%d %H:%M:%S
log_cli_format=%(asctime)s :: %(levelname)s :: %(message)s
markers =
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ dev =
build
pytest
pytest-cov
pytest-sugar
tox
mypy

Expand Down

0 comments on commit 8dd3e3e

Please sign in to comment.