-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
120 lines (100 loc) · 4.25 KB
/
Justfile
File metadata and controls
120 lines (100 loc) · 4.25 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
set shell := ["bash", "-c"]
set windows-shell := ["C:/Program Files/Git/bin/bash.exe", "-c"]
timeout_seconds := "20"
# Helper function to style echo messages
log message style="magenta":
#!/bin/bash
case "{{ style }}" in
blue) echo -e "{{ BLUE }}{{ BOLD }}{{ ITALIC }}{{ message }}{{ NORMAL }}" ;;
magenta) echo -e "{{ MAGENTA }}{{ BOLD }}{{ ITALIC }}{{ message }}{{ NORMAL }}" ;;
yellow) echo -e "{{ YELLOW }}{{ BOLD }}{{ ITALIC }}{{ message }}{{ NORMAL }}" ;;
red) echo -e "{{ RED }}{{ BOLD }}{{ ITALIC }}{{ message }}{{ NORMAL }}" ;;
*) just log "Yellow: change" "yellow" \
&& just log "Blue: Additive" "blue" \
&& just log "Red: subtractive" "red" \
&& just log "Magenta: command"
esac
# List all tasks (default)
help: (log "" "")
@echo "Just docs: https://just.systems/man/en/introduction.html"
@echo "cheatsheet: https://cheatography.com/linux-china/cheat-sheets/justfile/"
@just --list
# Install the virtual environment and per-commit hooks
install: (log "Creating virtual environment using uv")
uv sync --all-packages --frozen
# update the virtual environment and per-commit hooks
update: (log "Updating virtual environment using uv" "yellow")
uv lock --upgrade
uv sync --all-packages
uv run pre-commit autoupdate
# Run code formatter
format: (log "Format python files" "yellow")
uv run ruff format
# Run project quality (invoke pre-commit on all files)
check-quality: (log "Checking code quality: Running pre-commit")
uv run pre-commit run --all
# Run python static code check
check-static:
@just log "\nStatic type checking: Running pyright"
uv run pyright .
@just log "\nChecking for obsolete dependencies: Running deptry"
uv run deptry src
# Run all Project tests with coverage report if given
test $report="":
uv run pytest -m 'not contract_testing and not lfs' ${report:+--cov --cov-report $report}
# Run integration tests with optional coverage (appends to existing coverage data)
test-integration $report="":
uv run pytest -m 'integration' ${report:+--cov --cov-append --cov-report $report}
unit-test $report="":
uv run pytest -m 'not lfs and not integration' ${report:+--cov --cov-append --cov-report $report}
# test-contract REST API
test-contract: (log "Running contract tests...")
uv run pytest -m 'contract_testing'
# Run all endpoints health checks
smoke-test artifact="" host="127.0.0.1" port="8000": (api-bg artifact) (log "Waiting for API to be ready...")
for i in $(seq 1 {{timeout_seconds}}); do \
curl -fs http://{{ host }}:{{ port }}/docs > /dev/null && break; \
sleep 1; \
done
@just test-contract
@if [ "{{ os_family() }}" = "unix" ]; then \
kill $(cat api.pid) || true; \
else \
taskkill //IM main.exe //F 2>nul || true; \
fi
@rm -f api.pid
# Removes version control system dirty files
clean: (log "Delete all dirty files" "red")
git clean -xfd
# Build an executable for the REST API
build: (log "\nBuilding the REST API to an executable" "blue")
uv run pyinstaller --onefile src/main.py --clean \
--hidden-import=numpy \
--hidden-import=numpy.core \
--hidden-import=numpy.core._methods \
--hidden-import=numpy.core._dtype_ctypes \
--collect-submodules=surfalize
# Start API development server
api: (log "Starting FastAPI development server")
uv run fastapi dev src/main.py
# Start API with multiple workers
api-prod: (log "Starting FastAPI with 6 workers")
uv run fastapi run src/main.py --workers 6
# Start API server in the background
api-bg artifact="":
@cmd=(just api); [ -n "{{ artifact }}" ] && cmd=(./dist/{{ artifact }}); \
${cmd[@]} 2>/dev/null & echo $! > api.pid
@just log "API started in the background"
@cat api.pid
# list or run github job locally
ci job="":
[ -z "{{ job }}" ] && act --list || act --job {{ job }} --quiet
# run coverage difference between current branch and main
cov-diff base_branch="origin/main":
[ -f coverage.xml ] || just test xml
@just log "Getting coverage difference against {{ base_branch }}"
uv run diff-cover coverage.xml \
--compare-branch {{ base_branch }} \
--diff-range-notation '..' \
--fail-under 80 \
--format markdown:diff_coverage.md