-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
155 lines (121 loc) · 3.89 KB
/
Justfile
File metadata and controls
155 lines (121 loc) · 3.89 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
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
set dotenv-load := true
_default:
@just --list
# Run ruff check with autofix
fix:
uv run ruff check . --fix
# Run ruff check (no fix)
check:
uv run ruff check .
# Run ruff format
fmt:
uv run ruff format .
# Run pyright (type checker)
type:
uv run pyright .
# Run pre-commit hooks manually on all files
pre-commit:
test -d .git && uv run pre-commit run --all-files
# Run codespell on code file to find typos
spell:
uv run codespell
# Run typecheck and tests in parallel
[parallel]
_type-test: test type
# Run ruff check, format, spell checker, pre-commit, tests and type checker
lint: fix fmt spell pre-commit _type-test
# Check ruff check, tests, spell checker and type checker
check-all: check test spell type
# Watch Python files and run `check-all` on changes
watch:
watchexec --exts=py --clear --restart "just check-all"
# Run end-to-end tests with pytest
e2e:
uv run pytest -s --runslow tests/
# Run unit tests only
test:
uv run pytest --quiet tests/
# Run unit tests coverage
cov:
uv run pytest --cov=paper --cov-report=html --quiet tests/
# Show all files with type errors
typefiles:
uv run pyright . | grep -o '/.*\.py' | sort | uniq -c | sort -n
# Show documentation as HTML in a browser
doc:
uv run pdoc paper --docformat google
# Start development server
api-dev:
LOG_LEVEL=debug TIMERS=1 uv run fastapi dev src/paper/backend/api.py --host 0.0.0.0
# Start production server
api-serve:
uv run fastapi run src/paper/backend/api.py --port 8001
# Lint both core and frontend
lint-all:
just lint
cd frontend && just lint
# Run a GitHub workflow and watch its progress
_deploy-workflow workflow:
#!/usr/bin/env bash
set -euo pipefail
gh workflow run "{{workflow}}"
echo "Waiting for workflow to start..."
sleep 3
run_id=$(gh run list --workflow "{{workflow}}" --limit 1 --json databaseId --jq '.[0].databaseId')
gh run watch "$run_id"
# Deploy backend via graphmind-api
deploy-backend:
ssh $BACKEND_DEPLOY_HOST '/opt/graphmind/deployment/deploy_api.sh'
# Deploy frontend to GitHub Pages (manual trigger)
deploy-frontend: (_deploy-workflow "Deploy to GitHub Pages")
# Deploy both backend and frontend
deploy:
#!/usr/bin/env bash
set -euo pipefail
just deploy-backend 2>&1 | awk '{print "\033[36m[backend]\033[0m " $0; fflush()}' &
backend_pid=$!
(
printf '\033[33m[frontend]\033[0m Deploying to GitHub Pages...\n'
if just deploy-frontend > /dev/null 2>&1; then
printf '\033[33m[frontend]\033[0m Deployment succeeded\n'
else
printf '\033[33m[frontend]\033[0m Deployment failed!\n'
exit 1
fi
) &
frontend_pid=$!
wait "$backend_pid"
wait "$frontend_pid"
# Follow remote backend logs
api-logs tail="20":
#!/usr/bin/env bash
set -euo pipefail
ssh -t $BACKEND_DEPLOY_HOST \
'cd /opt/graphmind &&
docker compose -f deployment/docker-compose.yml \
logs graphmind -f --tail {{tail}}'
# Bump version for both backend and frontend (ensures they're synchronized)
bump bump:
#!/usr/bin/env bash
set -euo pipefail
# Bump the Python version first
uv version --bump {{bump}} 2> /dev/null || true
uv lock 2> /dev/null
# Get the new version from uv
new_version=$(uv version | cut -d' ' -f2)
# Convert Python version to npm-compatible semver
# Count the dots to determine format
dot_count=$(echo "$new_version" | tr -cd '.' | wc -c)
if [ "$dot_count" -eq 1 ]; then
# Version like "16.0" -> append ".0"
npm_version="${new_version}.0"
else
# Version like "16.0.1" -> use as-is
npm_version="$new_version"
fi
# Set the frontend to the same version
cd frontend
npm version "$npm_version" --no-git-tag-version --allow-same-version
# Commit the version bump
cd ..
jj commit --editor --message "Bump to $new_version"