-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
118 lines (97 loc) · 3.7 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
DATE = $(shell date)
PYTHON = $(shell uv run which python 2>/dev/null || which python)
PKG_VERSION = $(shell uv run python get-version.py)
BUILD_DATE = $(shell date +'%B %d, %Y')
PARALLEL_NUM ?= $(shell python -c 'import multiprocessing as m;print(int(max(m.cpu_count()/2, 2)))')
QPC_VAR_PROGRAM_NAME := $(or $(QPC_VAR_PROGRAM_NAME), qpc)
QPC_VAR_PROGRAM_NAME_UPPER := $(shell echo $(QPC_VAR_PROGRAM_NAME) | tr '[:lower:]' '[:upper:]')
QPC_VAR_CURRENT_YEAR := $(shell date +'%Y')
QPC_VAR_PROJECT := $(or $(QPC_VAR_PROJECT), Quipucords)
OLD_MAN_PAGE_BUILD_DATE := $(shell grep -e "^\.TH" docs/_build/qpc.1 | cut -d '"' -f 6)
TOPDIR = $(shell pwd)
DIRS = test bin locale src
PYDIRS = quipucords
BINDIR = bin
OMIT_PATTERNS = */test*.py,*/.virtualenvs/*.py,*/virtualenvs/*.py,.tox/*.py
SPHINX_BUILD = $(shell uv run which sphinx-build)
SED = sed
help:
@echo "Please use \`make <target>' where <target> is one of:"
@echo " help to show this message"
@echo " install to install the client egg"
@echo " clean to remove cache, dist, build, and egg files"
@echo " lint to run all linters"
@echo " lint-ruff to run the ruff linter"
@echo " lint-docs to run rstcheck against docs"
@echo " test to run unit tests"
@echo " test-coverage to run unit tests and measure test coverage"
@echo " manpage to build the manpage"
@echo " lock-requirements to lock all python dependencies"
@echo " update-requirements to update all python dependencies"
clean:
-rm -rf dist/ build/ qpc.egg-info/
find . -type f -name '*.pyc' -delete
find . -type d -name __pycache__ -delete
install:
$(PYTHON) setup.py build -f
$(PYTHON) setup.py install -f
lint: lint-ruff lint-docs
lint-ruff:
uv run ruff check .
uv run ruff format --check .
lint-docs:
uv run rstcheck docs/source/man-template.rst
uv run rstcheck docs/_build/man-qpc.rst
test:
uv run pytest
test-coverage:
uv run pytest --cov=qpc
uv run coverage report --show-missing
uv run coverage xml
# verify the pyproject.toml configuration file integrity
config-verify:
$(PYTHON) config-verify.py
# write a man page (roff format) with placeholders for names, version, and dates
update-man-template-roff:
@$(SPHINX_BUILD) -b man -q \
-D project='QPC_VAR_PROGRAM_NAME' \
-D release='PKG_VERSION' \
-D today='BUILD_DATE' \
docs docs/_build
# generate an upstream "qpc" man page in human-readable RST
generate-man-qpc-rst:
@$(SED) \
-e "s/QPC_VAR_PROGRAM_NAME/${QPC_VAR_PROGRAM_NAME}/g" \
-e "s/QPC_VAR_PROJECT/${QPC_VAR_PROJECT}/g" \
-e "s/QPC_VAR_CURRENT_YEAR/${QPC_VAR_CURRENT_YEAR}/g" \
docs/source/man-template.rst
update-man-qpc-rst:
$(MAKE) --no-print-directory generate-man-qpc-rst > docs/_build/man-qpc.rst
# generate an upstream "qpc" man page in man-parsable roff format
generate-man-qpc-roff:
@$(SED) \
-e "s/QPC_VAR_PROGRAM_NAME/${QPC_VAR_PROGRAM_NAME}/g" \
-e "s/QPC_VAR_PROJECT/${QPC_VAR_PROJECT}/g" \
-e "s/QPC_VAR_CURRENT_YEAR/${QPC_VAR_CURRENT_YEAR}/g" \
-e "s/PKG_VERSION/${PKG_VERSION}/g" \
-e "s/BUILD_DATE/${BUILD_DATE}/g" \
docs/_build/QPC_VAR_PROGRAM_NAME.1
update-man-qpc-roff:
$(MAKE) --no-print-directory generate-man-qpc-roff > docs/_build/qpc.1
# regenerate and update all man page files
manpage:
$(MAKE) update-man-template-roff
$(MAKE) update-man-qpc-rst
$(MAKE) update-man-qpc-roff
# test if man page files have changed
manpage-test:
$(MAKE) update-man-template-roff
$(MAKE) update-man-qpc-rst
$(MAKE) update-man-qpc-roff BUILD_DATE="${OLD_MAN_PAGE_BUILD_DATE}"
git diff --exit-code docs
git diff --staged --exit-code docs
lock-requirements:
uv lock
update-requirements:
uv lock --upgrade
$(MAKE) lock-requirements