-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
128 lines (99 loc) · 2.67 KB
/
Makefile
File metadata and controls
128 lines (99 loc) · 2.67 KB
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
help:
@echo 'Usage: make [target]'
@echo
@echo 'Development Targets:'
@echo ' venv Create virtual Python environment for development.'
@echo ' checks Run linters and tests.'
@echo
@echo 'Deployment Targets:'
@echo ' service Remove, install, configure, and run app.'
@echo ' rm Remove app.'
@echo ' help Show this help message.'
# Development Targets
# -------------------
VENV = ~/.venv/tzero
venv: FORCE
rm -rf $(VENV)/
python3 -m venv $(VENV)/
$(VENV)/bin/pip3 install -U build twine
$(VENV)/bin/pip3 install ruff mypy pytest
lint:
$(VENV)/bin/ruff check
$(VENV)/bin/ruff format --diff
$(VENV)/bin/mypy .
test:
$(VENV)/bin/pytest -v
coverage:
$(VENV)/bin/coverage run --branch -m unittest -v
$(VENV)/bin/coverage report --show-missing
$(VENV)/bin/coverage html
check-password:
! grep -r '"password":' . | grep -vE '^\./[^/]*.json|Makefile|\.\.\.'
checks: lint test check-password
clean:
rm -rf *.pyc __pycache__
rm -rf .coverage htmlcov
rm -rf dist tzero.egg-info
# Distribution Targets
# --------------------
dist: clean
$(VENV)/bin/python3 -m build
$(VENV)/bin/twine check dist/*
unzip -c dist/*.whl '*/METADATA'
unzip -t dist/*.whl
tar -tvf dist/*.tar.gz
upload:
$(VENV)/bin/twine upload dist/*
test-upload:
$(VENV)/bin/twine upload --repository testpypi dist/*
UVENV = ~/.venv/user-tzero
user-venv: FORCE
rm -rf $(UVENV)
python3 -m venv $(UVENV)
verify-upload:
$(MAKE) verify-sdist
$(MAKE) verify-bdist
verify-test-upload:
$(MAKE) verify-test-sdist
$(MAKE) verify-test-bdist
verify-sdist: user-venv
$(UVENV)/bin/pip3 install --no-binary :all: tzero
ls -l $(UVENV)/bin/tzero
verify-bdist: user-venv
$(UVENV)/bin/pip3 install tzero
ls -l $(UVENV)/bin/tzero
verify-test-sdist: user-venv
$(UVENV)/bin/pip3 install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
--no-binary :all: \
--pre tzero
ls -l $(UVENV)/bin/tzero
verify-test-bdist: user-venv
$(UVENV)/bin/pip3 install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
--pre tzero
ls -l $(UVENV)/bin/tzero
# Deployment Targets
# ------------------
service: rmservice
adduser --system --group --home / tzero
mkdir -p /opt/data/tzero/
chown -R tzero:tzero . /opt/data/tzero/
chmod 600 tzero.json
systemctl enable "$$PWD/etc/tzero.service"
systemctl daemon-reload
systemctl start tzero
@echo Done; echo
rmservice:
-systemctl stop tzero
-systemctl disable tzero
systemctl daemon-reload
-deluser tzero
@echo Done; echo
pull-backup:
mkdir -p ~/bkp/
ssh splnx.net "tar -czf - -C /opt/data/ tzero/" > ~/bkp/tzero-$$(date "+%Y-%m-%d_%H-%M-%S").tgz
ls -lh ~/bkp/
FORCE: