-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
132 lines (99 loc) · 4.32 KB
/
Justfile
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
set positional-arguments
@clean-venv:
rm -Rf .venv || true
@create-venv:
uv venv -p python3.12
@pip-sync:
uv pip sync --require-hashes requirements/main.txt requirements/dev.txt requirements/ruldap3.txt
@sync: pip-sync update-lib
@mkvenv: clean-venv create-venv sync
@run-dev:
source ./.venv/bin/activate && cd ./api && DEV=true python -m sertifikatsok --host 127.0.0.1 --port 7001 2>&1
@run-testserver:
source ./.venv/bin/activate && cd ./testserver && python -m testserver
@tests *args='':
source ./.venv/bin/activate && cd ./api && pytest -m "not apitest" "$@"
@mypy:
source ./.venv/bin/activate && cd ./api && mypy --version && mypy .
@pre-commit:
pre-commit run --all-files
@checks: pre-commit mypy tests
alias py := python
@python:
source ./.venv/bin/activate && python
# Dependabot uses pip-tools, which thinks setuptools
# is a scary dependency, so it adds it to the requirement file
# after a warning. If Dependabot doesn't see the warning
# footer in the original requirements file, it will remove it,
# plus any dependency after it, from the finished file. So, to
# make sure Dependabot doesn't remove our setuptools dependency,
# we must add the header to the requirements file. And let's just
# move the setuptools dependency to it as well, to minimize diffs.
move_dev_setuptools_dependency_to_unsafe_footer:
#!.venv/bin/python3
from pathlib import Path
dev_req = Path("requirements/dev.txt").read_text().splitlines()
new_reqs = []
setuptools_lines = []
in_setuptools = False
for line in dev_req:
if line.startswith("setuptools=="):
in_setuptools = True
setuptools_lines.append(line)
elif in_setuptools and line.startswith(" "):
setuptools_lines.append(line)
else:
in_setuptools = False
new_reqs.append(line)
if setuptools_lines:
new_reqs.extend(
[
"",
"# The following packages are considered to be unsafe in a requirements file:",
*setuptools_lines,
]
)
new_reqs.append("") # final newline
Path("requirements/dev.txt").write_text("\n".join(new_reqs))
@compile:
cd requirements && uv pip compile main.in -o main.txt --generate-hashes --no-header --no-strip-extras
cd requirements && uv pip compile dev.in -o dev.txt --generate-hashes --no-header --no-strip-extras
cd requirements && uv pip compile ruldap3.in -o ruldap3.txt --generate-hashes --no-header --no-strip-extras
just move_dev_setuptools_dependency_to_unsafe_footer
@upgrade:
cd requirements && uv pip compile main.in -o main.txt --generate-hashes --upgrade --no-header --no-strip-extras
cd requirements && uv pip compile dev.in -o dev.txt --generate-hashes --upgrade --no-header --no-strip-extras
cd requirements && uv pip compile ruldap3.in -o ruldap3.txt --generate-hashes --upgrade --no-header --no-strip-extras
just move_dev_setuptools_dependency_to_unsafe_footer
@upgrade-pkg *args='':
cd requirements && uv pip compile main.in -o main.txt --generate-hashes --no-header --no-strip-extras --upgrade-package "$@"
cd requirements && uv pip compile dev.in -o dev.txt --generate-hashes --no-header --no-strip-extras --upgrade-package "$@"
cd requirements && uv pip compile ruldap3.in -o ruldap3.txt --generate-hashes --no-header --no-strip-extras --upgrade-package "$@"
just move_dev_setuptools_dependency_to_unsafe_footer
alias ulib := update-lib
@update-lib:
source ./.venv/bin/activate && maturin develop --uv -m ruldap3/Cargo.toml
@build-lib:
source ./.venv/bin/activate && maturin build --release -m ruldap3/Cargo.toml
@install-optimized-lib: build-lib
source ./.venv/bin/activate && uv pip install --force-reinstall ./ruldap3/target/wheels/*
# docker compose stuff
@doctests *args='':
docker compose -f docker-compose.yaml -f docker-compose.dev.yaml exec test pytest "$@"
@apitests:
just doctests -m apitest
@docbuild:
docker compose -f docker-compose.yaml -f docker-compose.dev.yaml build
@docps:
docker compose -f docker-compose.yaml -f docker-compose.dev.yaml ps
@docdown:
docker compose -f docker-compose.yaml -f docker-compose.dev.yaml down
@docup: docdown
docker compose -f docker-compose.yaml -f docker-compose.dev.yaml up -d
# frontend stuff
@wwwdev-static:
cd www && npm run dev || true
@wwwdev-api:
cd www && VITE_PROXY=1 npm run dev || true
@wwwbuild:
cd www && npm run build