Skip to content

Moving to uv + hatch #1803

Moving to uv + hatch

Moving to uv + hatch #1803

Workflow file for this run

name: CI
on:
schedule:
- cron: 00 00 * * 1 # every Monday at 00:00
push:
branches:
- main
- "[0-9]+.[0-9]+.x"
pull_request:
env:
PYTEST_ADDOPTS: "-v --color=yes -n auto"
FORCE_COLOR: "1"
MPLBACKEND: agg
# It's impossible to ignore SyntaxWarnings for a single module,
# so because leidenalg 0.10.0 has them, we pre-compile things: https://github.com/vtraag/leidenalg/issues/173
UV_COMPILE_BYTECODE: "1"
jobs:
get-environments:
runs-on: ubuntu-latest
outputs:
envs: ${{ steps.get-envs.outputs.envs }}
steps:
- uses: actions/checkout@v5
with:
filter: blob:none
fetch-depth: 0
- uses: astral-sh/setup-uv@v6
with:
enable-cache: false
- id: get-envs
run: |
ENVS_JSON=$(NO_COLOR=1 uvx hatch env show --json | jq -c 'to_entries
| map(
select(.key | startswith("hatch-test"))
| {
name: .key,
"test-type": (if (.key | test("pre|min")) then "coverage" else null end),
python: .value.python | sub("3[.]13"; "3.13.3"), # https://github.com/numba/numba/issues/10101
}
)
| map(
. as $env |
if $env.python == "3.12" then
[$env + {"os": "ubuntu-latest"}, $env + {"os": "macos-latest"}]
else
[$env + {"os": "ubuntu-latest"}]
end
)
| flatten')
echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT
test:
needs: get-environments
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.get-environments.outputs.envs) }}
env: # environment variable for use in codecov's env_vars tagging
ENV_NAME: ${{ matrix.name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
filter: blob:none
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
python-version: ${{ matrix.python }}
cache-dependency-glob: pyproject.toml
- name: Ensure figure directory exists
run: mkdir -p "$GITHUB_WORKSPACE/tests/figures"
- name: Restore data cache
id: data-cache
uses: actions/cache@v4
with:
path: |
~/.cache/squidpy/*.h5ad
key: data-${{ hashFiles('**/download_data.py') }}
- name: Download datasets
if: steps.data-cache.outputs.cache-hit != 'true'
run: |
uvx hatch run ${{ matrix.name }}:download
- name: System dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -y
sudo apt-get install automake -y
# PyQt5 related
sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 -y
sudo Xvfb :42 -screen 0 1920x1080x24 -ac +extension GLX </dev/null &
- name: System dependencies (macOS)
if: matrix.os == 'macos-latest'
run: brew install automake
- name: Install dependencies
run: uvx hatch -v env create ${{ matrix.name }}
- name: Run tests
if: matrix.test-type == null
run: uvx hatch run ${{ matrix.name }}:run
- name: Run tests (coverage)
if: matrix.test-type == 'coverage'
run: uvx hatch run ${{ matrix.name }}:run-cov --cov --cov-report=xml
- name: Archive figures generated during testing
if: always()
uses: actions/upload-artifact@v4
with:
name: visual_test_results_${{ runner.os }}_py${{ matrix.name }}
path: ${{ github.workspace }}/tests/figures/*
- name: Upload coverage data
if: matrix.test-type == 'coverage'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: ENV_NAME
fail_ci_if_error: true
check:
if: always()
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}