-
Notifications
You must be signed in to change notification settings - Fork 37
/
justfile
126 lines (102 loc) · 3.34 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
# list all tasks
default:
@just --list
# run tests
test *FLAGS:
@uv run pytest .github/workflows/ tests/ -m "not integration" {{ FLAGS }}
# run integration tests
integration *FLAGS:
@uv run pytest tests/ -m integration {{ FLAGS }}
# check licenses
check-licenses force="":
#!/usr/bin/env bash
mapfile -t license_files < <(find . -type f -name 'pyproject.toml')
total=${#license_files[@]}
for ((i=0; i<total; i++)); do
license="${license_files[i]}"
remaining=$((total - i - 1))
if ! git diff --quiet "$license" || [ "{{ force }}" == "--force" ]; then
echo "checking licenses for: $license"
uv run .github/workflows/scripts/check_licenses.py "$license"
if [ $remaining -gt 0 ]; then
echo ""
fi
fi
done
# list supported licenses
list-licenses:
@uv run .github/workflows/scripts/check_licenses.py --supported-licenses
# format code
format:
#!/usr/bin/env bash
UVX_PATH="$(which uvx)"
if [ -z "$UVX_PATH" ]; then
echo "[error]: unable to find uvx"
exit 1
fi
eval "$UVX_PATH ruff format ."
eval "$UVX_PATH ruff check . --fix"
just --unstable --fmt
# run tests with coverage
coverage *FLAGS:
@uv run coverage run -m pytest tests/ -m "not integration" {{ FLAGS }}
@uv run coverage report
@uv run coverage lcov -o lcov.info
# build docs
docs:
@uv sync && uv run mkdocs serve
# install pre-commit hooks
install-hooks:
#!/usr/bin/env bash
HOOKS_DIR="$(git rev-parse --git-path hooks)"
if [ ! -d "$HOOKS_DIR" ]; then
mkdir -p "$HOOKS_DIR"
fi
cat > "$HOOKS_DIR/pre-commit" <<EOF
#!/usr/bin/env bash
just format
just check-licenses
EOF
if [ ! -f "$HOOKS_DIR/pre-commit" ]; then
echo "[error]: failed to create pre-commit hook at $HOOKS_DIR/pre-commit"
exit 1
fi
echo "installed pre-commit hook to $HOOKS_DIR"
chmod +x "$HOOKS_DIR/pre-commit"
# get latest ai-exchange version from pypi
ai-exchange-version:
#!/usr/bin/env bash
curl --silent https://pypi.org/pypi/ai-exchange/json |
jq --raw-output ".info.version"
# bump goose and ai-exchange version
release version:
#!/usr/bin/env bash
if [[ ! "{{ version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
echo "[error]: invalid version '{{ version }}'."
echo " expected: semver format major.minor.patch or major.minor.patch-<suffix>"
exit 1
fi
uvx --from=toml-cli toml set --toml-path=pyproject.toml "project.version" {{ version }}
git checkout -b "release-{{ version }}"
git add pyproject.toml
git commit --message "chore(release): release version {{ version }}"
# extract tag from pyproject.toml
get-tag-version:
@uvx --from=toml-cli toml get --toml-path=pyproject.toml "project.version"
# create tag from pyproject.toml
tag:
#!/usr/bin/env bash
git tag v$(just get-tag-version)
# create tag and push to origin (use this when release branch is merged to main)
tag-push: tag
#!/usr/bin/env bash
# this will kick of ci for release
git push origin tag v$(just get-tag-version)
# create release notes latest tag..HEAD
release-notes:
#!/usr/bin/env bash
git log --pretty=format:"- %s" v$(just get-tag-version)..HEAD
# setup langfuse server
langfuse-server:
#!/usr/bin/env bash
./scripts/setup_langfuse.sh