Skip to content

Commit e57e5cc

Browse files
committed
just(feat): Add root justfile for task automation
why: Migrate from Makefile to just for cleaner task runner syntax and better cross-platform support. what: - Add justfile with recipes for testing, linting, docs - Default command lists all available recipes - Watch commands gracefully handle missing entr
1 parent d36954d commit e57e5cc

1 file changed

Lines changed: 131 additions & 0 deletions

File tree

justfile

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# justfile for libvcs
2+
# https://just.systems/
3+
4+
set shell := ["bash", "-uc"]
5+
6+
# File patterns
7+
py_files := "find . -type f -not -path '*/\\.*' | grep -i '.*[.]py$' 2> /dev/null"
8+
doc_files := "find . -type f -not -path '*/\\.*' | grep -i '.*[.]rst$\\|.*[.]md$\\|.*[.]css$\\|.*[.]py$\\|mkdocs\\.yml\\|CHANGES\\|TODO\\|.*conf\\.py' 2> /dev/null"
9+
all_files := "find . -type f -not -path '*/\\.*' | grep -i '.*[.]py$\\|.*[.]rst$\\|.*[.]md$\\|.*[.]css$\\|.*[.]py$\\|mkdocs\\.yml\\|CHANGES\\|TODO\\|.*conf\\.py' 2> /dev/null"
10+
11+
# List all available commands
12+
default:
13+
@just --list
14+
15+
# ============================================================================
16+
# Testing
17+
# ============================================================================
18+
19+
# Run tests with pytest
20+
test *args:
21+
uv run py.test {{ args }}
22+
23+
# Run tests then start continuous testing with pytest-watcher
24+
start:
25+
just test
26+
uv run ptw .
27+
28+
# Watch files and run tests on change (requires entr)
29+
watch-test:
30+
#!/usr/bin/env bash
31+
set -euo pipefail
32+
if command -v entr > /dev/null; then
33+
${{ all_files }} | entr -c just test
34+
else
35+
just test
36+
just _entr-warn
37+
fi
38+
39+
# ============================================================================
40+
# Documentation
41+
# ============================================================================
42+
43+
# Build documentation
44+
build-docs:
45+
just -f docs/justfile html
46+
47+
# Watch files and rebuild docs on change
48+
watch-docs:
49+
#!/usr/bin/env bash
50+
set -euo pipefail
51+
if command -v entr > /dev/null; then
52+
${{ doc_files }} | entr -c just build-docs
53+
else
54+
just build-docs
55+
just _entr-warn
56+
fi
57+
58+
# Start documentation server with auto-reload
59+
start-docs:
60+
just -f docs/justfile start
61+
62+
# Start documentation design mode (watches static files)
63+
design-docs:
64+
just -f docs/justfile design
65+
66+
# ============================================================================
67+
# Linting & Formatting
68+
# ============================================================================
69+
70+
# Format code with ruff
71+
ruff-format:
72+
uv run ruff format .
73+
74+
# Run ruff linter
75+
ruff:
76+
uv run ruff check .
77+
78+
# Watch files and run ruff on change
79+
watch-ruff:
80+
#!/usr/bin/env bash
81+
set -euo pipefail
82+
if command -v entr > /dev/null; then
83+
${{ py_files }} | entr -c just ruff
84+
else
85+
just ruff
86+
just _entr-warn
87+
fi
88+
89+
# Run mypy type checker
90+
mypy:
91+
uv run mypy $(${{ py_files }})
92+
93+
# Watch files and run mypy on change
94+
watch-mypy:
95+
#!/usr/bin/env bash
96+
set -euo pipefail
97+
if command -v entr > /dev/null; then
98+
${{ py_files }} | entr -c just mypy
99+
else
100+
just mypy
101+
just _entr-warn
102+
fi
103+
104+
# Format markdown files with prettier
105+
format-markdown:
106+
prettier --parser=markdown -w *.md docs/*.md docs/**/*.md CHANGES
107+
108+
# ============================================================================
109+
# Typing
110+
# ============================================================================
111+
112+
# Run monkeytype to collect runtime types
113+
monkeytype-create:
114+
uv run monkeytype run $(uv run which py.test)
115+
116+
# Apply collected monkeytype annotations
117+
monkeytype-apply:
118+
uv run monkeytype list-modules | xargs -n1 -I{} sh -c 'uv run monkeytype apply {}'
119+
120+
# ============================================================================
121+
# Private helpers
122+
# ============================================================================
123+
124+
[private]
125+
_entr-warn:
126+
@echo "----------------------------------------------------------"
127+
@echo " ! File watching functionality non-operational ! "
128+
@echo " "
129+
@echo "Install entr(1) to automatically run tasks on file change."
130+
@echo "See https://eradman.com/entrproject/ "
131+
@echo "----------------------------------------------------------"

0 commit comments

Comments
 (0)