name: Build on: push: branches: - main pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: docker-build: name: Docker Run Test on ${{ matrix.platform }}-${{ matrix.python_tag_type }} runs-on: ubuntu-22.04 strategy: matrix: platform: - linux/amd64 - linux/arm64 python_tag_type: - slim - alpine exclude: # amd64 with glibc have full direct test - platform: linux/amd64 python_tag_type: slim # test alpine only on amd64 - platform: linux/arm64 python_tag_type: alpine steps: - uses: actions/checkout@v4 with: submodules: recursive - name: Set up QEMU if: matrix.platform == 'linux/arm64' uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Docker Build uses: docker/build-push-action@v5 with: context: . file: ./ci/Dockerfile.${{ matrix.python_tag_type }}.test platforms: ${{ matrix.platform }} tags: cyvcf2:${{ matrix.python_tag_type }}-test push: false load: true cache-from: type=gha,scope=docker-test-${{ matrix.python_tag_type }} cache-to: type=gha,mode=max,scope=docker-test-${{ matrix.python_tag_type }} build-args: | PYTHON_VERSION=${{ matrix.python_tag_type }} - name: Docker Run Tests run: | docker run --rm --platform ${{ matrix.platform }} cyvcf2:${{ matrix.python_tag_type }}-test pytest -q build: name: Run tests on Python ${{ matrix.python-version }} ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-22.04, macos-14] python-version: ["pypy3.10", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] exclude: # Run only the latest versions on macOS and windows - os: macos-14 python-version: "pypy3.10" - os: macos-14 python-version: "3.9" - os: macos-14 python-version: "3.10" - os: macos-14 python-version: "3.11" steps: - uses: actions/checkout@v4 with: submodules: recursive - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Set macOS env if: runner.os == 'macOS' run: | BREW_PREFIX="$(brew --prefix)" LIBDEFLATE_PREFIX="${BREW_PREFIX}/opt/libdeflate" # Homebrew on arm64 installs under /opt/homebrew, which is not in default compiler search paths. echo "CPPFLAGS=-I${BREW_PREFIX}/include -I${LIBDEFLATE_PREFIX}/include ${CPPFLAGS:-}" >> "$GITHUB_ENV" echo "LDFLAGS=-L${BREW_PREFIX}/lib -L${LIBDEFLATE_PREFIX}/lib ${LDFLAGS:-}" >> "$GITHUB_ENV" echo "PKG_CONFIG_PATH=${LIBDEFLATE_PREFIX}/lib/pkgconfig:${BREW_PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}" >> "$GITHUB_ENV" # arm64 requires a newer deployment target than x86_64. if [ "${{ runner.arch }}" = "X64" ]; then echo "MACOSX_DEPLOYMENT_TARGET=10.9" >> "$GITHUB_ENV" echo "ARCHFLAGS=-arch x86_64" >> "$GITHUB_ENV" else echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> "$GITHUB_ENV" fi - name: Install Linux build prerequisites if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install -y --no-install-recommends cmake ninja-build libcurl4-openssl-dev zlib1g-dev \ libssl-dev liblzma-dev libbz2-dev libdeflate-dev - name: Install macOS build prerequisites if: runner.os == 'macOS' run: | brew install automake cmake libdeflate ninja pkg-config - name: Install run: | python -m pip install --upgrade pip python -m pip install pytest pytest-cov CYVCF2_HTSLIB_CONFIGURE_OPTIONS="--enable-libcurl --enable-s3 --enable-lzma --enable-bz2 --with-libdeflate" \ python -m pip install -v -e . - name: Test run: | pytest --cov cyvcf2 --cov-report term-missing # make sure to keep this numpy version in sync with pyproject.toml - name: Test with oldest numpy that we support if: contains(fromJson('["3.9"]'), matrix.python-version) run: | pip install --force-reinstall --no-cache-dir 'numpy==2.0.0' pytest --cov cyvcf2 --cov-report term-missing - name: Test with newest available numpy if: matrix.os == 'ubuntu-22.04' && matrix.python-version == '3.14' run: | pip install -U numpy pytest --cov cyvcf2 --cov-report term-missing windows_build: name: Run tests on Python windows-2022 MSYS2 UCRT64 runs-on: windows-2022 defaults: run: shell: msys2 {0} steps: - uses: actions/checkout@v4 with: submodules: recursive - name: "Setup MSYS2" uses: msys2/setup-msys2@v2 with: msystem: UCRT64 path-type: inherit install: >- mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-make mingw-w64-ucrt-x86_64-libdeflate mingw-w64-ucrt-x86_64-xz mingw-w64-ucrt-x86_64-curl mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-zlib mingw-w64-ucrt-x86_64-bzip2 mingw-w64-ucrt-x86_64-tools-git mingw-w64-ucrt-x86_64-python-pkgconfig mingw-w64-ucrt-x86_64-pkg-config mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-python mingw-w64-ucrt-x86_64-python-pip make automake autoconf git - name: Install Windows build prerequisites run: | cd htslib autoreconf -i ./configure --enable-libcurl --enable-s3 --enable-lzma --enable-bz2 --with-libdeflate make make install - name: Install run: | python -m venv .venv . .venv/bin/activate python -m pip install --upgrade pip python -m pip install pytest pytest-cov python -m pip install -v -e . - name: Test run: | . .venv/bin/activate pytest --cov cyvcf2 --cov-report term-missing - name: Test with newest available numpy run: | . .venv/bin/activate pip install -U numpy pytest --cov cyvcf2 --cov-report term-missing conda_external_htslib: name: Conda external htslib ${{ matrix.htslib-version }} runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: htslib-version: ["1.21", "1.22.1", "1.23.1"] steps: - uses: actions/checkout@v4 with: submodules: recursive - name: Set up micromamba uses: mamba-org/setup-micromamba@v2 with: environment-name: cyvcf2-conda-external condarc: | channels: - conda-forge - bioconda channel_priority: strict create-args: >- python=3.12 pip scikit-build-core>=0.11 cmake>=3.20 ninja cython>=3 numpy>=2.0.0 htslib=${{ matrix.htslib-version }} pkg-config setuptools wheel - name: Install against conda htslib shell: micromamba-shell {0} run: | export CYVCF2_HTSLIB_MODE=EXTERNAL export CMAKE_PREFIX_PATH="${CONDA_PREFIX}${CMAKE_PREFIX_PATH:+:${CMAKE_PREFIX_PATH}}" export PKG_CONFIG_PATH="${CONDA_PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}" python -m pip install . --no-deps --no-build-isolation -v > conda-external-build.log 2>&1 cat conda-external-build.log if grep -E "building bundled( shared)? htslib" conda-external-build.log; then echo "Expected external htslib, but build used bundled htslib" exit 1 fi - name: Verify external htslib linkage shell: micromamba-shell {0} run: | extension="$(cd "${RUNNER_TEMP}" && python -c 'import cyvcf2.cyvcf2 as module; print(module.__file__)')" echo "Extension path: ${extension}" cd "${RUNNER_TEMP}" python -c 'from cyvcf2 import VCF; print(VCF)' ldd "${extension}" | tee "${GITHUB_WORKSPACE}/conda-external-linkage.txt" grep -E "libhts\.so" "${GITHUB_WORKSPACE}/conda-external-linkage.txt" sdist: runs-on: ubuntu-22.04 strategy: matrix: python-version: ["3.14"] steps: - uses: actions/checkout@v4 with: submodules: recursive - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install sdist prerequisites run: | python -m pip install --upgrade pip build - name: Create source distribution run: python -m build --sdist - name: Install Linux build prerequisites if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install -y --no-install-recommends libcurl4-openssl-dev zlib1g-dev libssl-dev liblzma-dev \ libbz2-dev libdeflate-dev - name: Build (via sdist tarball) run: python -m pip install --verbose --no-binary='cyvcf2' cyvcf2-*.tar.gz working-directory: dist - name: Install test prerequisites # pytest 8.2.0~8.2.1 changed the behaivour of --import-mode, can't ignore local cyvcf2 folder. # So we need to pin it before it breaks again. run: | pip install pytest==8.1.2 pytest-cov - name: Test run: | pytest --import-mode importlib --cov cyvcf2 --cov-report term-missing - name: Test with newest available numpy run: | pip install -U numpy pytest --import-mode importlib --cov cyvcf2 --cov-report term-missing - name: Upload sdist tarball if: runner.os == 'Linux' uses: actions/upload-artifact@v4 with: name: sdist path: dist/cyvcf2-*.tar.gz retention-days: 7