-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
130 lines (117 loc) · 3.37 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
118
119
120
121
122
123
124
125
126
127
128
129
130
#
# This Makefile serves as convenient command-line auto-completion
#
PROJECT_NAME=cijoe
BUILD=pyproject-build
PIPX=pipx
PYTEST="$(shell pipx environment -V PIPX_LOCAL_VENVS)/${PROJECT_NAME}/bin/pytest"
PYTHON_SYS=python3
PYTHON_VENV="$(shell pipx environment -V PIPX_LOCAL_VENVS)/${PROJECT_NAME}/bin/python3"
TWINE=twine
define default-help
# invoke: 'make uninstall', 'make install'
endef
.PHONY: default
default: build
@echo "## ${PROJECT_NAME}: make default"
@echo "## ${PROJECT_NAME}: make default [DONE]"
define all-help
# Do all: clean uninstall build install
endef
.PHONY: all
all: uninstall clean deps build install info test
define deps-help
# Dependencies for building cijoe and uploading it to PyPI
endef
.PHONY: deps
deps:
${PIPX} install build || true
${PIPX} install twine || true
define info-help
# Dump various Python / tooling information
endef
.PHONY: info
info:
@echo "## ${PROJECT_NAME}: make info"
${BUILD} --version || true
${PIPX} --version || true
${PYTEST} --version || true
${PYTHON_SYS} --version || true
${PYTHON_VENV} --version || true
${TWINE} --version || true
@echo "## ${PROJECT_NAME}: make info [DONE]"
define docker-help
# drop into a docker instance with the repository bind-mounted at /tmp/source
endef
.PHONY: docker
docker:
@echo "## ${PROJECT_NAME}: docker"
@docker run -it -w /tmp/source --mount type=bind,source="$(shell pwd)",target=/tmp/source ghcr.io/xnvme/xnvme-deps-debian-bullseye:next bash
@echo "## ${PROJECT_NAME}: docker [DONE]"
define format-help
# run code format (style, code-conventions and language-integrity) on staged changes
endef
.PHONY: format
format:
@echo "## ${PROJECT_NAME}: format"
@pre-commit run
@echo "## ${PROJECT_NAME}: format [DONE]"
define format-all-help
# run code format (style, code-conventions and language-integrity) on staged and committed changes
endef
.PHONY: format-all
format-all:
@echo "## ${PROJECT_NAME}: format-all"
@pre-commit run --all-files
@echo "## ${PROJECT_NAME}: format-all [DONE]"
define build-help
# Build the package (sdist and wheel using sdist)
endef
.PHONY: build
build:
@echo "## ${PROJECT_NAME}: make build"
@${BUILD}
@echo "## ${PROJECT_NAME}: make build [DONE]"
define install-help
# install for current user
endef
.PHONY: install
install:
@echo "## ${PROJECT_NAME}: make install"
@${PIPX} install dist/*.tar.gz --include-deps --force
@echo "## ${PROJECT_NAME}: make install [DONE]"
define uninstall-help
# uninstall
#
# Prefix with 'sudo' when uninstalling a system-wide installation
endef
.PHONY: uninstall
uninstall:
@echo "## ${PROJECT_NAME}: make uninstall"
@${PIPX} uninstall ${PROJECT_NAME} || echo "Cannot uninstall => That is OK"
@echo "## ${PROJECT_NAME}: make uninstall [DONE]"
define examples-help
# Run pytest on the testcase-test
endef
.PHONY: test
test:
@echo "## ${PROJECT_NAME}: make test"
${PYTEST} --pyargs cijoe.core.selftest --config src/cijoe/core/configs/default-config.toml
@echo "## ${PROJECT_NAME}: make test [DONE]"
define examples-help
# Run pytest on the testcase-test
endef
.PHONY: release
release: all
@echo "## ${PROJECT_NAME}: make release"
@echo -n "# rel: "; date
@${TWINE} upload dist/*
@echo "## ${PROJECT_NAME}: make release"
define clean-help
# clean the Python build dirs (build, dist)
endef
.PHONY: clean
clean:
@echo "## ${PROJECT_NAME}: clean"
@git clean -fdx || echo "Failed git-clean ==> That is OK"
@echo "## ${PROJECT_NAME}: clean [DONE]"