Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refine Makefile #639

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ build:
post_install:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make dev-doc
post_build:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make doc-mypy doc-coverage
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make mypy doc-coverage
os: ubuntu-22.04
tools:
python: '3.12'
Expand Down
18 changes: 7 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format pyproject-fmt codespell lint pre-commit test-run test build publish doc-autobuild doc-gen doc-mypy doc-coverage doc consistency
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format pyproject-fmt codespell lint pre-commit test-run test build publish doc-autobuild doc-build doc-coverage doc consistency

########################################################################################
# Variables
Expand Down Expand Up @@ -42,16 +42,16 @@ deepclean: clean

# Install the package in editable mode.
install:
pdm install --prod
pdm sync --prod

# Install the package in editable mode with specific optional dependencies.
dev-%:
pdm install --dev --group $*
pdm sync --dev --group $*

# Prepare the development environment.
# Install the package in editable mode with all optional dependencies and pre-commit hook.
dev:
pdm install
pdm sync
if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi

# Install standalone tools
Expand All @@ -72,7 +72,7 @@ endif

# Check lint with mypy.
mypy:
pdm run python -m mypy .
pdm run python -m mypy . --html-report $(PUBLIC_DIR)/reports/mypy

# Lint with ruff.
ruff:
Expand Down Expand Up @@ -135,20 +135,16 @@ doc-autobuild:
-a

# Build documentation only from src.
doc-gen:
doc-build:
pdm run python -m sphinx.cmd.build docs $(PUBLIC_DIR)

# Generate mypy reports.
doc-mypy:
pdm run python -m mypy src tests --html-report $(PUBLIC_DIR)/reports/mypy

# Generate html coverage reports with badge.
doc-coverage: test-run
pdm run python -m coverage html -d $(PUBLIC_DIR)/reports/coverage
pdm run bash scripts/generate-coverage-badge.sh $(PUBLIC_DIR)/_static/badges

# Generate all documentation with reports.
doc: doc-gen doc-mypy doc-coverage
doc: doc-build mypy doc-coverage

########################################################################################
# Template
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ enable_error_code = [
]
exclude = [
"build",
"doc",
"template",
]
no_implicit_optional = true
Expand Down
2 changes: 1 addition & 1 deletion template/.readthedocs.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ build:
post_install:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make dev-doc
post_build:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make doc-mypy doc-coverage
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make mypy doc-coverage
os: ubuntu-22.04
tools:
python: '{{ default_py }}'
Expand Down
18 changes: 7 additions & 11 deletions template/Makefile.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[% from pathjoin("includes", "variable.jinja") import page_url with context -%]
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format pyproject-fmt codespell lint pre-commit test-run test build publish doc-autobuild doc-gen doc-mypy doc-coverage doc
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format pyproject-fmt codespell lint pre-commit test-run test build publish doc-autobuild doc-build doc-coverage doc
[%- if project_name == "Serious Scaffold Python" %] consistency[% endif %]

########################################################################################
Expand Down Expand Up @@ -44,16 +44,16 @@ deepclean: clean

# Install the package in editable mode.
install:
pdm install --prod
pdm sync --prod

# Install the package in editable mode with specific optional dependencies.
dev-%:
pdm install --dev --group $*
pdm sync --dev --group $*

# Prepare the development environment.
# Install the package in editable mode with all optional dependencies and pre-commit hook.
dev:
pdm install
pdm sync
if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi

# Install standalone tools
Expand All @@ -74,7 +74,7 @@ endif

# Check lint with mypy.
mypy:
pdm run python -m mypy .
pdm run python -m mypy . --html-report $(PUBLIC_DIR)/reports/mypy

# Lint with ruff.
ruff:
Expand Down Expand Up @@ -137,20 +137,16 @@ doc-autobuild:
-a

# Build documentation only from src.
doc-gen:
doc-build:
pdm run python -m sphinx.cmd.build docs $(PUBLIC_DIR)

# Generate mypy reports.
doc-mypy:
pdm run python -m mypy src tests --html-report $(PUBLIC_DIR)/reports/mypy

# Generate html coverage reports with badge.
doc-coverage: test-run
pdm run python -m coverage html -d $(PUBLIC_DIR)/reports/coverage
pdm run bash scripts/generate-coverage-badge.sh $(PUBLIC_DIR)/_static/badges

# Generate all documentation with reports.
doc: doc-gen doc-mypy doc-coverage
doc: doc-build mypy doc-coverage

[% if project_name == "Serious Scaffold Python" -%]
########################################################################################
Expand Down
1 change: 1 addition & 0 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ enable_error_code = [
]
exclude = [
"build",
"doc",
[%- if project_name == "Serious Scaffold Python" %]
"template",
[%- endif %]
Expand Down