Skip to content

Replace pip with uv for test workflow #1523

Replace pip with uv for test workflow

Replace pip with uv for test workflow #1523

Workflow file for this run

name: Test
on:
push:
branches: [main]
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches: "*"
jobs:
test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -e {0} # -e to fail on error
strategy:
fail-fast: false
matrix:
python: ["3.10"] #, "3.12"
os: [ubuntu-latest]
# include:
# - os: macos-latest
# python: "3.10"
# - os: macos-latest
# python: "3.12"
# pip-flags: "--pre"
# name: "Python 3.12 (pre-release)"
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python }}
steps:
- uses: actions/checkout@v2
- uses: astral-sh/setup-uv@v5
id: setup-uv
with:
version: "latest"
python-version: ${{ matrix.python }}
enable-cache: true
# cache-suffix: "${{ runner.os }}-${{ matrix.python }}"
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock
# - name: Clean uv cache
# # Uncomment this step if you want to regenerate the cache
# run: |
# uv cache clean -v
# echo "CACHE_JUST_CLEARED=true" >> $GITHUB_ENV
- name: Install dependencies
run: |
if [ "${{ steps.setup-uv.outputs.cache-hit }}" != "true" ]; then
echo "uv cache miss"
elif [ "${CACHE_JUST_CLEARED}" == "true" ]; then
echo "uv cache just cleared"
else
echo "uv cache hit"
fi
uv sync --group test
- name: Test
env:
MPLBACKEND: agg
PLATFORM: ${{ matrix.os }}
DISPLAY: :42
run: |
uv run pytest --cov --color=yes --cov-report=xml --collect-only
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
name: coverage
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}