-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjustfile
More file actions
196 lines (160 loc) · 6.44 KB
/
Copy pathjustfile
File metadata and controls
196 lines (160 loc) · 6.44 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
set dotenv-load := true
set export
set shell := ["bash", "-uc"]
nowts:=`date +%Y%m%d_%H%M%S`
YYYYMMDD:= `date +%Y%m%d`
# Development
# Show all available commands (default)
default:
@just --list
# Install dev dependencies
install-dev:
uv sync --extra dev
# Run pre-commit hooks manually
precommit:
uv run python -m pre_commit run --all-files --verbose
# Run pre-commit autoupdate (when pre-commit-config.yaml is updated)
precommit-autoupdate:
uv run python -m pre_commit autoupdate
# Run tests with coverage
test-cov *args:
pytest --cov=supervaizer --cov-report=term --cov-report=html {{args}}
# Run tests without coverage
test *args:
uv run pytest --no-cov {{args}}
# Run tests without coverage
test-no-cov *args:
uv run pytest --no-cov {{args}}
# Run only previously failed tests
test-failed:
uv run pytest --lf --no-cov
# Run mypy type checking
mypy:
uv run python -m pre_commit run mypy --all-files
# Sync dependencies (from pyproject.toml)
install:
uv sync
upgrade:
uv sync -U
# Sync all dependencies - including dev dependencies
install-all:
uv sync --all-extras
# build
build:
hatch build
# Toggle PEP 440 .dev0 on canonical version (syncs src/supervaizer/__version__.py + pyproject [tool.bumpversion]).
# Does not edit CHANGELOG or historical docs. After `on`, avoid `just tag_version` until `off` (tags should be release-only).
# Usage: just version-dev on | just version-dev off
version-dev cmd:
uv run python tools/dev_version.py {{cmd}}
# Reusable recipe to bump version
_bump-version bump_type:
@echo "VERSION BUMP IN CICD - not running: hatch version {{bump_type}} "
hatch build
# Increase 0.0.1
release-patch:
just _bump-version fix
# Increase 0.1.0
release-minor:
just _bump-version minor
# Increase 1.0.0
release-major:
just _bump-version major
# Push tags to remote
push_tags:
git push origin --tags
@echo "Tags pushed to remote"
# Install Git hooks
install-hooks:
# First unset any existing hooksPath
@git config --unset-all core.hooksPath || true
# Install pre-commit hooks
@uv run python -m pre_commit install
# Set up our custom hooks
@git config core.hooksPath .githooks
# Git hooks installed
# API documentation @http://127.0.0.1:8000/redoc
dev:
uvicorn controller:app --reload
# Local test mode: no Studio credentials, built-in Hello World agent (for agent workbench)
local:
uv run supervaizer start --local
# Create git tag for current version - Automated done in post-commit hook
tag-version:
bash -c "VERSION=\$(grep '^VERSION = ' src/supervaizer/__version__.py | cut -d'\"' -f2) && TAG=\"v\${VERSION}\" && if git rev-parse -q --verify \"refs/tags/\${TAG}\" >/dev/null; then echo \"Tag \${TAG} already exists - skipping\"; else git tag -a \"\${TAG}\" -m \"Version \${VERSION}\" && echo \"Created tag \${TAG}\"; fi"
# Generate RSA private key (PEM) for SUPERVAIZER_PRIVATE_KEY (e.g. Vercel env)
generate-private-key:
uv run python -c "from cryptography.hazmat.primitives.asymmetric import rsa; from cryptography.hazmat.primitives import serialization; from cryptography.hazmat.backends import default_backend; k = rsa.generate_private_key(65537, 2048, default_backend()); print(k.private_bytes(serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8, serialization.NoEncryption()).decode())"
# Check git history for secret leaks
security-scan:
trufflehog git file://. --results=verified,unknown --fail
# Generate model reference documentation
generate-docs:
uv run python tools/gen_model_docs.py
uv run python tools/export_openapi.py
# Deployment sequence
ready-to-go:
just test-no-cov
just precommit
just version-dev off
just generate-docs
bash -euc 'branch_id="$(but status --json | uv run python tools/get_applied_but_branch_id.py)"; but commit "$branch_id" -m "chore: update documentation" --json --status-after'
# Merge develop to main
merge-to-main:
@echo "Switching to main branch..."
git checkout main
@echo "Pulling latest main..."
git pull origin main
@echo "Merging develop into main..."
git merge develop --no-ff -m "chore: merge develop to main"
@echo "✅ Merged develop to main"
# Push main branch to remote
push-main:
@echo "Pushing main branch to remote..."
git push origin main
@echo "✅ Main branch pushed to remote"
# Complete release: merge develop to main, push main and tags
release:
just merge-to-main
just push-main
just push_tags
just gh-release
@echo "✅ Release complete! Main branch and tags pushed to remote"
# Ship to production: precommit, create a release PR merging develop→main (CI does the version bump).
# Embed bump type token ([MINOR]/[PATCH]/[MAJOR]) so CI picks up the right part after the PR merges.
# Run "ready-to-go" to ensure the documentation commit happens in the active stack only.
# Usage: just ship [patch|minor|major]
ship part="minor":
#!/usr/bin/env bash
set -euo pipefail
just precommit
case "{{part}}" in
patch|minor|major) ;;
*)
echo "Invalid ship part '{{part}}'. Use patch, minor, or major."
exit 1
;;
esac
BUMP_TOKEN=$(echo "{{part}}" | tr '[:lower:]' '[:upper:]')
RELEASE_BRANCH="release/{{part}}-$(date +%Y%m%d-%H%M%S)"
RELEASE_TITLE="[${BUMP_TOKEN}] chore: merge develop to main"
git fetch origin main develop
git switch -c "$RELEASE_BRANCH" origin/main
git merge origin/develop --no-ff -m "$RELEASE_TITLE"
git push -u origin "$RELEASE_BRANCH"
if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then
gh pr create \
--base main \
--head "$RELEASE_BRANCH" \
--title "$RELEASE_TITLE" \
--body "Release PR created by \`just ship {{part}}\`. Merge this PR after required checks pass; the publish workflow will bump the {{part}} version from the merge commit token."
else
echo "Create a PR to main from $RELEASE_BRANCH after required checks pass."
fi
# Create or update GitHub release for the latest tag on origin/main
gh-release:
bash tools/gh-release-latest-tag.sh supervaize/supervaizer
# After `just ship`, wait for the PyPI publish to be available, then
# merge main back into develop and refresh release notes from CHANGELOG.md.
ship-reconcile repo="supervaize/supervaizer" mode="merge" timeout_seconds="1800" poll_seconds="15":
bash tools/reconcile-release-after-ship.sh "{{repo}}" --mode "{{mode}}" --timeout-seconds {{timeout_seconds}} --poll-seconds {{poll_seconds}}