Replace Poetry with UV #3662
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache UV virtualenv | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/uv | |
~/.uv | |
.venv | |
key: ${{ runner.os }}-uv-${{ hashFiles('**/requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-uv- | |
- name: Install UV | |
run: | | |
curl -LsSf https://astral.sh/uv/install.sh | sh | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
echo "$USERPROFILE/.cargo/bin" >> $GITHUB_PATH | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
else | |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
fi | |
export PATH="$HOME/.cargo/bin:$PATH" | |
uv --version | |
- name: Create and activate venv | |
run: | | |
python -m venv .venv | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
source .venv/Scripts/activate | |
else | |
source .venv/bin/activate | |
fi | |
python --version # Verify Python version | |
shell: bash | |
- name: Install dependencies | |
run: | | |
source .venv/bin/activate # Ensure venv is activated | |
python --version # Verify Python version | |
uv pip install -e ".[test-docs,anthropic,groq,cohere,mistralai,litellm,google-generativeai,vertexai,cerebras_cloud_sdk,fireworks-ai,writer]" | |
uv pip install -r requirements-dev.txt | |
uv pip install --upgrade "typing-extensions>=4.12.2" "requests>=2.32.3" "regex>=2024.11.6" | |
uv pip list # List installed packages for debugging | |
shell: bash | |
- name: Run tests | |
if: matrix.python-version != '3.11' | |
run: | | |
source .venv/bin/activate | |
python --version | |
pytest tests/ -k 'not llm and not openai and not gemini and not anthropic and not cohere and not vertexai' && pytest tests/llm/test_cohere | |
shell: bash | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} | |
- name: Generate coverage report | |
if: matrix.python-version == '3.11' | |
run: | | |
source .venv/bin/activate | |
python --version | |
coverage run -m pytest tests/ -k "not docs and not anthropic and not gemini and not cohere and not vertexai and not fireworks" | |
coverage report | |
coverage html | |
shell: bash | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |