Skip to content

Commit 0f4f8c4

Browse files
authored
Merge pull request #391 from kenibrewer/feat/makefile-improvements
feat(dev): add improved makefile with additional helper commands
2 parents 0c50446 + c324eda commit 0f4f8c4

File tree

3 files changed

+40
-56
lines changed

3 files changed

+40
-56
lines changed

.devcontainer/postCreateCommand.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# re-included here for the benefit of manual dev environments.
44
poetry self add "poetry-dynamic-versioning[plugin]"
55
poetry config virtualenvs.in-project true --local
6-
poetry install --with dev --all-extras
6+
poetry install --with dev,docs --all-extras
77
poetry run pre-commit install --install-hooks

Makefile

+39-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
1-
# Minimal makefile for Sphinx documentation
2-
#
1+
install: .devcontainer/postCreateCommand.sh ## Install the poetry environment and install the pre-commit hooks
2+
@echo "🛠️ Creating virtual environment using poetry and installing pre-commit hooks"
3+
@bash .devcontainer/postCreateCommand.sh
4+
@echo "🐢 Launching poetry shell"
5+
@poetry shell
36

4-
# You can set these variables from the command line, and also
5-
# from the environment for the first two.
6-
SPHINXOPTS ?=
7-
SPHINXBUILD ?= sphinx-build
8-
SOURCEDIR = docs
9-
BUILDDIR = build
7+
.PHONY: check
8+
check: ## Run code quality tools.
9+
@echo "🔒 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check"
10+
@poetry check --lock
11+
@echo "🔎 Linting code: Running pre-commit"
12+
@poetry run pre-commit run -a
1013

11-
# Put it first so that "make" without argument is like "make help".
12-
help:
13-
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
.PHONY: test
15+
test: ## Test the code with pytest
16+
@echo "🧪 Testing code: Running pytest"
17+
@poetry run pytest --cov --cov-config=pyproject.toml --cov-report=xml
18+
19+
.PHONY: docs
20+
docs: ## Build the documentation
21+
@echo "📚 Building documentation"
22+
@poetry run sphinx-build docs build
23+
24+
.PHONY: build
25+
build: clean-build ## Build wheel file using poetry
26+
@echo "🛞 Creating wheel and sdist files"
27+
@poetry build
1428

15-
.PHONY: help Makefile
29+
.PHONY: clean-build
30+
clean-build: ## clean build artifacts
31+
@echo "🧹 Cleaning build artifacts"
32+
@rm -rf dist
1633

17-
# Catch-all target: route all unknown targets to Sphinx using the new
18-
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19-
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
34+
.PHONY: docker-build
35+
test_docker_build: ## Build the docker image and run the tests
36+
@echo "🐳 Building docker image and running tests"
37+
@docker build -f build/docker/Dockerfile -t pycytominer:latest .
38+
@docker run pycytominer:latest poetry run pytest
39+
40+
.PHONY: help
41+
help:
42+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' "$(MAKEFILE_LIST)" | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
2143

22-
# note: presumes the existence of docker daemon to receive docker commands
23-
test_docker_build:
24-
docker build -f build/docker/Dockerfile -t pycytominer:latest . && \
25-
docker run pycytominer:latest poetry run pytest
44+
.DEFAULT_GOAL := help

make.bat

-35
This file was deleted.

0 commit comments

Comments
 (0)