forked from phoenix/litellm-mirror
129 lines
4.1 KiB
YAML
129 lines
4.1 KiB
YAML
version: 2.1
|
|
jobs:
|
|
local_testing:
|
|
docker:
|
|
- image: circleci/python:3.8
|
|
working_directory: ~/project
|
|
|
|
steps:
|
|
- checkout
|
|
|
|
- run:
|
|
name: Check if litellm dir was updated or if pyproject.toml was modified
|
|
command: |
|
|
if [ -n "$(git diff --name-only $CIRCLE_SHA1^..$CIRCLE_SHA1 | grep -E 'pyproject\.toml|litellm/')" ]; then
|
|
echo "litellm updated"
|
|
else
|
|
echo "No changes to litellm or pyproject.toml. Skipping tests."
|
|
circleci step halt
|
|
fi
|
|
- restore_cache:
|
|
keys:
|
|
- v1-dependencies-{{ checksum ".circleci/requirements.txt" }}
|
|
- run:
|
|
name: Install Dependencies
|
|
command: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install -r .circleci/requirements.txt
|
|
pip install pytest
|
|
pip install pytest-asyncio
|
|
pip install mypy
|
|
pip install -q google-generativeai
|
|
pip install "boto3>=1.28.57"
|
|
pip install appdirs
|
|
pip install langchain
|
|
pip install numpydoc
|
|
pip install traceloop-sdk==0.0.69
|
|
pip install openai
|
|
pip install prisma
|
|
- save_cache:
|
|
paths:
|
|
- ./venv
|
|
key: v1-dependencies-{{ checksum ".circleci/requirements.txt" }}
|
|
- run:
|
|
name: Linting Testing
|
|
command: |
|
|
cd litellm
|
|
python -m pip install types-requests types-setuptools types-redis
|
|
if ! python -m mypy . --ignore-missing-imports --explicit-package-bases; then
|
|
echo "mypy detected errors"
|
|
exit 1
|
|
fi
|
|
cd ..
|
|
|
|
|
|
# Run pytest and generate JUnit XML report
|
|
- run:
|
|
name: Run tests
|
|
command: |
|
|
pwd
|
|
ls
|
|
python -m pytest -vv litellm/tests/ -x --junitxml=test-results/junit.xml --durations=5
|
|
no_output_timeout: 120m
|
|
|
|
# Store test results
|
|
- store_test_results:
|
|
path: test-results
|
|
|
|
publish_to_pypi:
|
|
docker:
|
|
- image: cimg/python:3.8
|
|
working_directory: ~/project
|
|
|
|
environment:
|
|
TWINE_USERNAME: __token__
|
|
|
|
steps:
|
|
- checkout
|
|
|
|
- run:
|
|
name: Check if litellm dir was updated or if pyproject.toml was modified
|
|
command: |
|
|
if [ -n "$(git diff --name-only $CIRCLE_SHA1^..$CIRCLE_SHA1 | grep -E 'pyproject\.toml|litellm/')" ]; then
|
|
echo "litellm updated"
|
|
else
|
|
echo "No changes to litellm or pyproject.toml. Skipping PyPI publish."
|
|
circleci step halt
|
|
fi
|
|
|
|
- run:
|
|
name: Checkout code
|
|
command: git checkout $CIRCLE_SHA1
|
|
|
|
# Check if setup.py is modified and publish to PyPI
|
|
- run:
|
|
name: PyPI publish
|
|
command: |
|
|
echo "Install TOML package."
|
|
python -m pip install toml
|
|
VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")
|
|
PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['name'])")
|
|
if ! pip show -v $PACKAGE_NAME | grep -q "Version: ${VERSION}"; then
|
|
echo "pyproject.toml modified"
|
|
echo -e "[pypi]\nusername = $PYPI_PUBLISH_USERNAME\npassword = $PYPI_PUBLISH_PASSWORD" > ~/.pypirc
|
|
python -m pip install --upgrade pip
|
|
pip install build
|
|
pip install wheel
|
|
pip install --upgrade twine setuptools
|
|
rm -rf build dist
|
|
|
|
echo "Building package"
|
|
python -m build
|
|
|
|
echo "Twine upload to dist"
|
|
echo "Contents of dist directory:"
|
|
ls dist/
|
|
twine upload --verbose dist/*
|
|
else
|
|
echo "Version ${VERSION} of package is already published on PyPI. Skipping PyPI publish."
|
|
circleci step halt
|
|
fi
|
|
|
|
workflows:
|
|
version: 2
|
|
build_and_test:
|
|
jobs:
|
|
- local_testing
|
|
- publish_to_pypi:
|
|
requires:
|
|
- local_testing
|