Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/integration-test-r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
test:
strategy:
Expand Down
68 changes: 26 additions & 42 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,148 +12,133 @@
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
get-packages:
runs-on: ubuntu-slim
outputs:
packages: ${{ steps.get-packages.outputs.packages }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
filter: blob:none
- name: Get packages to tes
id: get-packages
run: |
PKGS=$(cat packages.json | jq -c)
echo "packages=$PKGS" | tee $GITHUB_OUTPUT

test:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
needs: get-packages
strategy:
fail-fast: false
matrix:
python: ["3.13", "3.14"]
is_pre: [true, false]
package:
# extras should be a comma seperated list of strings, like `extras: "lazy,accelerated"`
# The 'test' extra is always installed
- {name: "mudata", extras: ""}
- {name: "spatialdata", extras: ""}
- {name: "scirpy", extras: ""}
- {name: "muon", extras: ""}
- {name: "scanpy", extras: "scanpy2"}
- {name: "squidpy", extras: ""}
- {name: "scvi-tools", extras: "optional"}
- {name: "pertpy", extras: "de,tcoda"}
- {name: "decoupler", extras: ""}
- {name: "SnapATAC2", extras: ""}
- {name: "rapids-singlecell", extras: "rapids-cu13", gpu: true}
- {name: "liana", extras: "extras"}
- {name: "PyDESeq2", extras: ""}
package: ${{ fromJSON(needs.get-packages.outputs.packages) }}
exclude:
- { python: "3.13", is_pre: true }

defaults:
run:
shell: bash -leo pipefail {0}

runs-on: ${{ matrix.package.gpu && format('cirun-aws-gpu--{0}', github.run_id) || 'ubuntu-latest' }}

steps:

- uses: actions/checkout@v7
with:
fetch-depth: 0
filter: blob:none
path: integration-testing

- uses: actions/checkout@v7
with:
repository: scverse/${{ matrix.package.name }}
fetch-depth: 0
filter: blob:none
path: ${{ matrix.package.name }}

- name: Nvidia SMI sanity check
if: matrix.package.gpu
run: nvidia-smi

# https://github.com/scverse/gpu-ci-config/issues/5
- name: Add CUDA to PATH
if: matrix.package.gpu
run: |
echo "/usr/local/cuda/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV

- name: Install Python
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}

- name: Install UV
uses: hynek/setup-cached-uv@v2
with:
uv-cache-path: ${{ runner.temp }}/uv-cache

- name: Cache Rust dependencies
if: ${{ hashFiles(format('{0}/Cargo.toml', matrix.package.name)) != '' }}
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ matrix.package.name }}

- name: Install toml parsers
run: |
uv pip install --system toml-cli

- name: Install AnnData and scverse package
- name: Install scverse package and dependencies
env:
UV_EXTRA_INDEX_URL: ${{ matrix.package.gpu && 'https://pypi.nvidia.com' || '' }}
run: |
EXTRAS=""
GROUP=""
if toml get 'dependency-groups.test' --toml-path pyproject.toml > /dev/null; then
GROUP="--group test"
if [ -n "${{ matrix.package.extras }}" ]; then
EXTRAS="${{ matrix.package.extras }}"
fi
else
if [ -n "${{ matrix.package.extras }}" ]; then
EXTRAS="test,${{ matrix.package.extras }}"
else
EXTRAS="test"
fi
fi
uv pip install ${{ matrix.is_pre && '--prerelease allow' || '' }} --compile --system ".[$EXTRAS]" git+https://github.com/scverse/anndata -c ../integration-testing/constraints.txt ${{ matrix.is_pre && '--override ../integration-testing/overrides.txt' || ''}} $GROUP -v
PACKAGE: ${{ matrix.package.name }}
EXTRAS: ${{ toJSON(matrix.package.extras) }}
IS_PRE: ${{ matrix.is_pre }}
run: python ../integration-testing/scripts/install.py
working-directory: ${{ matrix.package.name }}

- name: Set failure type for install
if: failure()
run: |
echo "Installation failed for ${{ matrix.package.name }}"
echo "failure_type=install" >> $GITHUB_ENV

- name: Env list
run: uv pip freeze

- name: Run test
env:
DISPLAY: :42
COLUMNS: 120
run: |
pytest
working-directory: ${{ matrix.package.name }}

- name: Set failure type for test
if: failure() && env.failure_type != 'install'
run: |
echo "Test failed for ${{ matrix.package.name }}"
echo "failure_type=test" >> $GITHUB_ENV

# https://github.com/scverse/gpu-ci-config/issues/4
- name: Install GitHub CLI
if: matrix.package.gpu
uses: sersoft-gmbh/setup-gh-cli-action@v3
with:
version: stable

- name: Manage failure issue
if: always()
uses: ./integration-testing/.github/actions/failure-issue
with:
package: ${{ matrix.package.name }}
python: ${{ matrix.python }}
is-pre: ${{ matrix.is_pre }}
status: ${{ job.status }}
failure-type: ${{ env.failure_type }}
app-id: ${{ vars.ISSUE_CREATOR_APP_ID }}
private-key: ${{ secrets.ISSUE_CREATOR_PRIVATE_KEY }}

keepalive-job:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: Keepalive Workflow
runs-on: ubuntu-latest
permissions:
Expand All @@ -162,7 +147,6 @@
- name: Re-enable workflow
env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN || github.token }}
shell: sh
run: |
for WORKFLOW in integration-test.yml integration-test-r.yml; do
gh api --verbose -X PUT "repos/${GITHUB_REPOSITORY}/actions/workflows/${WORKFLOW}/enable"
Expand Down
1 change: 0 additions & 1 deletion overrides.txt

This file was deleted.

15 changes: 15 additions & 0 deletions packages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{"name": "mudata"},
{"name": "spatialdata"},
{"name": "scirpy"},
{"name": "muon"},
{"name": "scanpy", "extras": ["scanpy2"]},
{"name": "squidpy"},
{"name": "scvi-tools", "extras": ["optional"]},
{"name": "pertpy", "extras": ["de", "tcoda"]},
{"name": "decoupler"},
{"name": "SnapATAC2"},
{"name": "rapids-singlecell", "extras": ["rapids-cu13"], "gpu": true},
{"name": "liana", "extras": ["extras"]},
{"name": "PyDESeq2"}
]
55 changes: 55 additions & 0 deletions scripts/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""Install the scverse package checked out in the current directory, with its test dependencies.

Inputs (environment variables):
- ``PACKAGE``: the package's name, as in ``packages.json``
- ``EXTRAS``: JSON list of extras to install (or ``null``)
- ``IS_PRE``: ``true`` to test against pre-releases and the scverse packages' ``main`` branches
"""

import json
import os
import subprocess
import sys
import tomllib
from pathlib import Path
from tempfile import TemporaryDirectory

ROOT = Path(__file__).parent.parent

# always installed from their main branch
DATASTRUCTURES = ("anndata", "mudata", "spatialdata")
# overrides when testing pre-releases
OVERRIDES_PRE = ("pandas>=3",)

package = os.environ["PACKAGE"]
extras_matrix: tuple[str, ...] = tuple(json.loads(os.environ.get("EXTRAS") or "null") or ())
is_pre = os.environ.get("IS_PRE") == "true"

pyproject = tomllib.loads(Path("pyproject.toml").read_text())
has_test_group = "test" in pyproject.get("dependency-groups", {})
extras = extras_matrix if has_test_group else ("test", *extras_matrix)

from_git = (
*DATASTRUCTURES,
*(p["name"] for p in json.loads((ROOT / "packages.json").read_text()) if is_pre),
)
# the package under test comes from its checkout, so don't constrain it
constraints = tuple(
f"{name} @ git+https://github.com/scverse/{name}@main"
for name in dict.fromkeys(from_git)
if name != package
)

with TemporaryDirectory() as tmp:
constraints_file, overrides_file = Path(tmp, "constraints.txt"), Path(tmp, "overrides.txt")
constraints_file.write_text("\n".join(constraints) + "\n")
overrides_file.write_text("\n".join(OVERRIDES_PRE) + "\n")
cmd = (
*("uv", "pip", "install", "--compile", "--system", "-v"),
f".[{','.join(extras)}]" if extras else ".",
*("-c", ROOT / "constraints.txt", "-c", constraints_file),
*(("--group", "test") if has_test_group else ()),
*(("--prerelease", "allow", "--override", overrides_file) if is_pre else ()),
)
print(*cmd, flush=True)
sys.exit(subprocess.run(cmd, check=False).returncode)
Loading