diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index 66b8d7f5..8bd14678 100755 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -3,5 +3,5 @@ # re-included here for the benefit of manual dev environments. poetry self add "poetry-dynamic-versioning[plugin]" poetry config virtualenvs.in-project true --local -poetry install --with dev --all-extras +poetry install --with dev,docs --all-extras poetry run pre-commit install --install-hooks diff --git a/Makefile b/Makefile index b184c7bd..c6fe85bd 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,44 @@ -# Minimal makefile for Sphinx documentation -# +install: .devcontainer/postCreateCommand.sh ## Install the poetry environment and install the pre-commit hooks + @echo "๐Ÿ› ๏ธ Creating virtual environment using poetry and installing pre-commit hooks" + @bash .devcontainer/postCreateCommand.sh + @echo "๐Ÿข Launching poetry shell" + @poetry shell -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = docs -BUILDDIR = build +.PHONY: check +check: ## Run code quality tools. + @echo "๐Ÿ”’ Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check" + @poetry check --lock + @echo "๐Ÿ”Ž Linting code: Running pre-commit" + @poetry run pre-commit run -a -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +.PHONY: test +test: ## Test the code with pytest + @echo "๐Ÿงช Testing code: Running pytest" + @poetry run pytest --cov --cov-config=pyproject.toml --cov-report=xml + +.PHONY: docs +docs: ## Build the documentation + @echo "๐Ÿ“š Building documentation" + @poetry run sphinx-build docs build + +.PHONY: build +build: clean-build ## Build wheel file using poetry + @echo "๐Ÿ›ž Creating wheel and sdist files" + @poetry build -.PHONY: help Makefile +.PHONY: clean-build +clean-build: ## clean build artifacts + @echo "๐Ÿงน Cleaning build artifacts" + @rm -rf dist -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +.PHONY: docker-build +test_docker_build: ## Build the docker image and run the tests + @echo "๐Ÿณ Building docker image and running tests" + @docker build -f build/docker/Dockerfile -t pycytominer:latest . + @docker run pycytominer:latest poetry run pytest + +.PHONY: help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' "$(MAKEFILE_LIST)" | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' -# note: presumes the existence of docker daemon to receive docker commands -test_docker_build: - docker build -f build/docker/Dockerfile -t pycytominer:latest . && \ - docker run pycytominer:latest poetry run pytest +.DEFAULT_GOAL := help diff --git a/make.bat b/make.bat deleted file mode 100644 index 3e4fe6d7..00000000 --- a/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=docs -set BUILDDIR=build - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd