Skip to content

Commit f7f16e7

Browse files
committed
refactor(build): Makefile organization and help
1 parent 3d85264 commit f7f16e7

File tree

1 file changed

+55
-22
lines changed

1 file changed

+55
-22
lines changed

Makefile

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33

44
# Makefile for utility work on coverage.py.
55

6-
help: ## Show this help.
7-
@echo "Available targets:"
8-
@grep '^[a-zA-Z]' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' 'NF==2 {printf " %-26s%s\n", $$1, $$2}'
6+
.DEFAULT_GOAL := help
7+
8+
##@ Utilities
9+
10+
.PHONY: help clean_platform clean sterile
911

10-
clean_platform: ## Remove files that clash across platforms.
12+
clean_platform:
1113
@rm -f *.so */*.so
1214
@rm -rf __pycache__ */__pycache__ */*/__pycache__ */*/*/__pycache__ */*/*/*/__pycache__ */*/*/*/*/__pycache__
1315
@rm -f *.pyc */*.pyc */*/*.pyc */*/*/*.pyc */*/*/*/*.pyc */*/*/*/*/*.pyc
1416
@rm -f *.pyo */*.pyo */*/*.pyo */*/*/*.pyo */*/*/*/*.pyo */*/*/*/*/*.pyo
1517

16-
clean: clean_platform ## Remove artifacts of test execution, installation, etc.
18+
clean: clean_platform ## Remove artifacts of test execution, installation, etc.
1719
@echo "Cleaning..."
1820
@-pip uninstall -yq coverage
1921
@rm -f *.pyd */*.pyd
@@ -32,28 +34,31 @@ clean: clean_platform ## Remove artifacts of test execution, i
3234
@rm -rf tests/actual
3335
@-make -C tests/gold/html clean
3436

35-
sterile: clean ## Remove all non-controlled content, even if expensive.
37+
sterile: clean ## Remove all non-controlled content, even if expensive.
3638
rm -rf .tox
3739

40+
help: ## Show this help.
41+
@# Adapted from https://www.thapaliya.com/en/writings/well-documented-makefiles/
42+
@echo Available targets:
43+
@awk 'BEGIN{FS=":.*##";} /^[^: ]+:.*##/{printf " \033[1m%-20s\033[m %s\n",$$1,$$2} /^##@/{printf "\n%s\n",substr($$0,5)}' $(MAKEFILE_LIST)
3844

39-
CSS = coverage/htmlfiles/style.css
40-
SCSS = coverage/htmlfiles/style.scss
45+
##@ Tests and quality checks
4146

42-
css: $(CSS) ## Compile .scss into .css.
43-
$(CSS): $(SCSS)
44-
pysassc --style=compact $(SCSS) $@
45-
cp $@ tests/gold/html/styled
47+
.PHONY: lint smoke
4648

4749
lint: ## Run linters and checkers.
4850
tox -q -e lint
4951

5052
PYTEST_SMOKE_ARGS = -n auto -m "not expensive" --maxfail=3 $(ARGS)
5153

5254
smoke: ## Run tests quickly with the C tracer in the lowest supported Python versions.
53-
COVERAGE_NO_PYTRACER=1 tox -q -e py36 -- $(PYTEST_SMOKE_ARGS)
55+
COVERAGE_NO_PYTRACER=1 tox -q -e py37 -- $(PYTEST_SMOKE_ARGS)
56+
5457

55-
# Coverage measurement of coverage.py itself (meta-coverage). See metacov.ini
56-
# for details.
58+
##@ Metacov: coverage measurement of coverage.py itself
59+
# See metacov.ini for details.
60+
61+
.PHONY: metacov metahtml metasmoke
5762

5863
metacov: ## Run meta-coverage, measuring ourself.
5964
COVERAGE_COVERAGE=yes tox -q $(ARGS)
@@ -64,9 +69,14 @@ metahtml: ## Produce meta-coverage HTML reports.
6469
metasmoke:
6570
COVERAGE_NO_PYTRACER=1 ARGS="-e py39" make metacov metahtml
6671

72+
73+
##@ Requirements management
74+
75+
.PHONY: upgrade
76+
6777
PIP_COMPILE = pip-compile --upgrade --allow-unsafe
6878
upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
69-
upgrade: ## update the *.pip files with the latest packages satisfying *.in files
79+
upgrade: ## Update the *.pip files with the latest packages satisfying *.in files.
7080
pip install -q -r requirements/pip-tools.pip
7181
$(PIP_COMPILE) -o requirements/pip-tools.pip requirements/pip-tools.in
7282
$(PIP_COMPILE) -o requirements/pip.pip requirements/pip.in
@@ -77,10 +87,28 @@ upgrade: ## update the *.pip files with the latest packages satisfying *.in
7787
$(PIP_COMPILE) -o requirements/light-threads.pip requirements/light-threads.in
7888
$(PIP_COMPILE) -o doc/requirements.pip doc/requirements.in
7989

90+
91+
##@ Pre-builds for prepping the code
92+
93+
.PHONY: css workflows prebuild
94+
95+
CSS = coverage/htmlfiles/style.css
96+
SCSS = coverage/htmlfiles/style.scss
97+
98+
css: $(CSS) ## Compile .scss into .css.
99+
$(CSS): $(SCSS)
100+
pysassc --style=compact $(SCSS) $@
101+
cp $@ tests/gold/html/styled
102+
80103
workflows: ## Run cog on the workflows to keep them up-to-date.
81104
python -m cogapp -crP .github/workflows/*.yml
82105

83-
# Kitting
106+
prebuild: css workflows cogdoc ## One command for all source prep.
107+
108+
109+
##@ Kitting: making releases
110+
111+
.PHONY: kit kit_upload test_upload kit_local download_kits check_kits
84112

85113
kit: ## Make the source distribution.
86114
python -m build
@@ -106,10 +134,10 @@ download_kits: ## Download the built kits from GitHub.
106134
check_kits: ## Check that dist/* are well-formed.
107135
python -m twine check dist/*
108136

109-
build_ext:
110-
python setup.py build_ext
111137

112-
# Documentation
138+
##@ Documentation
139+
140+
.PHONY: cogdoc dochtml docdev docspell
113141

114142
DOCBIN = .tox/doc/bin
115143
SPHINXOPTS = -aE
@@ -122,7 +150,7 @@ WEBSAMPLEBETA = $(WEBHOME)/files/sample_coverage_html_beta
122150
$(DOCBIN):
123151
tox -q -e doc --notest
124152

125-
cogdoc: $(DOCBIN) ## Run docs through cog
153+
cogdoc: $(DOCBIN) ## Run docs through cog.
126154
$(DOCBIN)/python -m cogapp -crP --verbosity=1 doc/*.rst
127155

128156
dochtml: cogdoc $(DOCBIN) ## Build the docs HTML output.
@@ -134,7 +162,12 @@ docdev: dochtml ## Build docs, and auto-watch for changes.
134162
docspell: $(DOCBIN) ## Run the spell checker on the docs.
135163
$(SPHINXBUILD) -b spelling doc doc/_spell
136164

137-
publish:
165+
166+
##@ Publishing docs
167+
168+
.PHONY: publish publishbeta relnotes_json github_releases
169+
170+
publish: ## Publish the sample HTML report.
138171
rm -f $(WEBSAMPLE)/*.*
139172
mkdir -p $(WEBSAMPLE)
140173
cp doc/sample_html/*.* $(WEBSAMPLE)

0 commit comments

Comments
 (0)