-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
169 lines (135 loc) · 3.42 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
.PHONY: all develop test lint clean doc format
.PHONY: clean clean-build clean-pyc clean-test coverage dist docs install lint lint/flake8
PKG:=hop3,hop3_agent,hop3_server,hop3_web,hop3_lib
# For tests
# Either uncomment and set the following variables or set them in the environment
# HOP3_DEV_HOST=XXX
all: lint test
#
# Used by CI
#
## Lint / check typing
lint:
ruff check packages/hop3-agent packages/hop3-cli
pyright packages/hop3-agent
mypy packages/hop3-agent
reuse lint -q
cd packages/hop3-agent && deptry src
# vulture --min-confidence 80 packages/hop3-agent/src
## Cleanup repository
clean-and-deploy:
make clean-server
make deploy
clean-server:
echo "--> Cleaning server (warning: this removes everything)"
-ssh root@${HOP3_DEV_HOST} apt-get purge -y nginx nginx-core nginx-common
ssh root@${HOP3_DEV_HOST} rm -rf /home/hop3 /etc/nginx
deploy:
echo "--> Deploying"
@make clean
uv build packages/hop3-agent
uv run pyinfra -y --user root ${HOP3_DEV_HOST} installer/install-hop.py
#
# Setup
#
## Install development dependencies and pre-commit hook (env must be already activated)
develop: install-deps activate-pre-commit configure-git
install: install-deps
install-deps:
@echo "--> Installing dependencies"
uv sync --inexact
activate-pre-commit:
@echo "--> Activating pre-commit hook"
pre-commit install
configure-git:
@echo "--> Configuring git"
git config branch.autosetuprebase always
## Check development environment
check-dev-env:
python3 scripts/check-dev-env.py
## Update dependencies
update-deps:
@echo "--> Updating dependencies"
uv sync -U
uv run pre-commit autoupdate
uv pip list --outdated
uv pip list --format=freeze > compliance/requirements-full.txt
## Generate SBOM
generate-sbom:
@echo "--> Generating SBOM"
uv sync -q --no-dev
uv pip list --format=freeze > compliance/requirements-prod.txt
uv sync -q
# CycloneDX
uv run cyclonedx-py requirements \
--pyproject pyproject.toml -o compliance/sbom-cyclonedx.json \
compliance/requirements-prod.txt
# Add license information
uv run lbom \
--input_file compliance/sbom-cyclonedx.json \
> compliance/sbom-lbom.json
mv compliance/sbom-lbom.json compliance/sbom-cyclonedx.json
# broken
# # SPDX
# sbom4python -r compliance/requirements-prod.txt \
# --sbom spdx --format json \
# -o compliance/sbom-spdx.json
#
# testing & checking
#
.PHONY: test test-randomly test-with-coverage test-with-typeguard clean-test lint audit
# NB: keep tests in the Makefile for now, because if CI.
## Run python tests
test:
@echo "--> Running Python tests"
uv run pytest
@echo ""
test-randomly:
@echo "--> Running Python tests in random order"
uv run pytest --random-order
@echo ""
test-e2e:
@echo "--> Running e2e tests"
make clean-and-deploy
hop-test
@echo ""
test-with-coverage:
@echo "--> Running Python tests"
pytest --cov=hop3 --cov-report term-missing
@echo ""
test-with-typeguard:
@echo "--> Running Python tests with typeguard"
pytest --typeguard-packages=${PKG}
@echo ""
## Run a security audit
audit:
# uvx pip-audit .
# uvx safety scan
just audit
## Formatting
format:
just format
## Format apps
format-apps:
just format-apps
## Fix using ruff
fix:
ruff check packages/hop3-agent --fix --unsafe-fixes
add-copyright:
just add-copyright
## Clean up
clean:
just clean
clean-test:
just clean-test
## Default recipe
default:
just default
## Documentation
doc:
duty docs-build
doc-serve:
duty docs
## Cleanup harder
tidy:
just tidy