chore: add justfile to format recipe (#163)
This commit is contained in:
@@ -1,79 +1,102 @@
|
||||
# list all tasks
|
||||
default:
|
||||
@just --list --unsorted
|
||||
@just --list --unsorted
|
||||
|
||||
# run tests
|
||||
test *FLAGS:
|
||||
uv run pytest tests -m "not integration" {{FLAGS}}
|
||||
uv run pytest tests -m "not integration" {{ FLAGS }}
|
||||
|
||||
# run integration tests
|
||||
integration *FLAGS:
|
||||
uv run pytest tests -m integration {{FLAGS}}
|
||||
uv run pytest tests -m integration {{ FLAGS }}
|
||||
|
||||
# format code
|
||||
format:
|
||||
#!/usr/bin/env bash
|
||||
UVX_PATH="$(which uvx)"
|
||||
#!/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"
|
||||
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
|
||||
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
|
||||
uv sync && uv run mkdocs serve
|
||||
|
||||
# install pre-commit hooks
|
||||
install-hooks:
|
||||
#!/usr/bin/env bash
|
||||
HOOKS_DIR="$(git rev-parse --git-path hooks)"
|
||||
#!/usr/bin/env bash
|
||||
HOOKS_DIR="$(git rev-parse --git-path hooks)"
|
||||
|
||||
if [ ! -d "$HOOKS_DIR" ]; then
|
||||
mkdir -p "$HOOKS_DIR"
|
||||
fi
|
||||
if [ ! -d "$HOOKS_DIR" ]; then
|
||||
mkdir -p "$HOOKS_DIR"
|
||||
fi
|
||||
|
||||
cat > "$HOOKS_DIR/pre-commit" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
cat > "$HOOKS_DIR/pre-commit" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
|
||||
just format
|
||||
EOF
|
||||
just format
|
||||
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"
|
||||
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:
|
||||
curl -s https://pypi.org/pypi/ai-exchange/json | jq -r .info.version
|
||||
#!/usr/bin/env bash
|
||||
curl --silent https://pypi.org/pypi/ai-exchange/json |
|
||||
jq --raw-output ".info.version"
|
||||
|
||||
# bump project version, push, create pr
|
||||
# bump goose and ai-exchange version
|
||||
release version:
|
||||
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version {{version}}
|
||||
ai_exchange_version=$(just ai-exchange-version) && sed -i '' 's/ai-exchange>=.*/ai-exchange>='"${ai_exchange_version}"'\",/' pyproject.toml
|
||||
git checkout -b release-version-{{version}}
|
||||
git add pyproject.toml
|
||||
git commit -m "chore(release): release version {{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 }}"
|
||||
|
||||
tag_version:
|
||||
grep 'version' pyproject.toml | cut -d '"' -f 2
|
||||
# extract tag from pyproject.toml
|
||||
get-tag-version:
|
||||
#!/usr/bin/env bash
|
||||
uvx --from=toml-cli toml get --toml-path=pyproject.toml "project.version"
|
||||
|
||||
# create tag from pyproject.toml
|
||||
tag:
|
||||
git tag v$(just tag_version)
|
||||
#!/usr/bin/env bash
|
||||
git tag v$(just get-tag-version)
|
||||
|
||||
# this will kick of ci for release
|
||||
# use this when release branch is merged to main
|
||||
tag-push:
|
||||
just tag
|
||||
git push origin tag v$(just 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)
|
||||
|
||||
# get commit messages for a release
|
||||
# create release notes latest tag..HEAD
|
||||
release-notes:
|
||||
git log --pretty=format:"- %s" v$(just tag_version)..HEAD
|
||||
#!/usr/bin/env bash
|
||||
git log --pretty=format:"- %s" v$(just get-tag-version)..HEAD
|
||||
|
||||
# setup langfuse server
|
||||
langfuse-server:
|
||||
./scripts/setup_langfuse.sh
|
||||
#!/usr/bin/env bash
|
||||
./scripts/setup_langfuse.sh
|
||||
|
||||
Reference in New Issue
Block a user