| 1 |
name: Build |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
pull_request: |
| 8 |
|
| 9 |
concurrency: |
| 10 |
group: ${{ github.workflow }}-${{ github.ref }} |
| 11 |
cancel-in-progress: true |
| 12 |
|
| 13 |
jobs: |
| 14 |
docker-build: |
| 15 |
name: Docker Run Test on ${{ matrix.platform }}-${{ matrix.python_tag_type }} |
| 16 |
runs-on: ubuntu-22.04 |
| 17 |
strategy: |
| 18 |
matrix: |
| 19 |
platform: |
| 20 |
- linux/amd64 |
| 21 |
- linux/arm64 |
| 22 |
python_tag_type: |
| 23 |
- slim |
| 24 |
- alpine |
| 25 |
exclude: |
| 26 |
# amd64 with glibc have full direct test |
| 27 |
- platform: linux/amd64 |
| 28 |
python_tag_type: slim |
| 29 |
|
| 30 |
# test alpine only on amd64 |
| 31 |
- platform: linux/arm64 |
| 32 |
python_tag_type: alpine |
| 33 |
|
| 34 |
steps: |
| 35 |
- uses: actions/checkout@v4 |
| 36 |
with: |
| 37 |
submodules: recursive |
| 38 |
- name: Set up QEMU |
| 39 |
if: matrix.platform == 'linux/arm64' |
| 40 |
uses: docker/setup-qemu-action@v3 |
| 41 |
- name: Set up Docker Buildx |
| 42 |
uses: docker/setup-buildx-action@v3 |
| 43 |
|
| 44 |
- name: Docker Build |
| 45 |
uses: docker/build-push-action@v5 |
| 46 |
with: |
| 47 |
context: . |
| 48 |
file: ./ci/Dockerfile.${{ matrix.python_tag_type }}.test |
| 49 |
platforms: ${{ matrix.platform }} |
| 50 |
tags: cyvcf2:${{ matrix.python_tag_type }}-test |
| 51 |
push: false |
| 52 |
load: true |
| 53 |
cache-from: type=gha,scope=docker-test-${{ matrix.python_tag_type }} |
| 54 |
cache-to: type=gha,mode=max,scope=docker-test-${{ matrix.python_tag_type }} |
| 55 |
build-args: | |
| 56 |
PYTHON_VERSION=${{ matrix.python_tag_type }} |
| 57 |
|
| 58 |
- name: Docker Run Tests |
| 59 |
run: | |
| 60 |
docker run --rm --platform ${{ matrix.platform }} cyvcf2:${{ matrix.python_tag_type }}-test pytest -q |
| 61 |
|
| 62 |
build: |
| 63 |
name: Run tests on Python ${{ matrix.python-version }} ${{ matrix.os }} |
| 64 |
runs-on: ${{ matrix.os }} |
| 65 |
strategy: |
| 66 |
matrix: |
| 67 |
os: [ubuntu-22.04, macos-14] |
| 68 |
python-version: |
| 69 |
["pypy3.10", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
| 70 |
exclude: |
| 71 |
# Run only the latest versions on macOS and windows |
| 72 |
- os: macos-14 |
| 73 |
python-version: "pypy3.10" |
| 74 |
- os: macos-14 |
| 75 |
python-version: "3.9" |
| 76 |
- os: macos-14 |
| 77 |
python-version: "3.10" |
| 78 |
- os: macos-14 |
| 79 |
python-version: "3.11" |
| 80 |
|
| 81 |
steps: |
| 82 |
- uses: actions/checkout@v4 |
| 83 |
with: |
| 84 |
submodules: recursive |
| 85 |
- name: Set up Python ${{ matrix.python-version }} |
| 86 |
uses: actions/setup-python@v5 |
| 87 |
with: |
| 88 |
python-version: ${{ matrix.python-version }} |
| 89 |
|
| 90 |
- name: Set macOS env |
| 91 |
if: runner.os == 'macOS' |
| 92 |
run: | |
| 93 |
BREW_PREFIX="$(brew --prefix)" |
| 94 |
LIBDEFLATE_PREFIX="${BREW_PREFIX}/opt/libdeflate" |
| 95 |
|
| 96 |
# Homebrew on arm64 installs under /opt/homebrew, which is not in default compiler search paths. |
| 97 |
echo "CPPFLAGS=-I${BREW_PREFIX}/include -I${LIBDEFLATE_PREFIX}/include ${CPPFLAGS:-}" >> "$GITHUB_ENV" |
| 98 |
echo "LDFLAGS=-L${BREW_PREFIX}/lib -L${LIBDEFLATE_PREFIX}/lib ${LDFLAGS:-}" >> "$GITHUB_ENV" |
| 99 |
echo "PKG_CONFIG_PATH=${LIBDEFLATE_PREFIX}/lib/pkgconfig:${BREW_PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}" >> "$GITHUB_ENV" |
| 100 |
|
| 101 |
# arm64 requires a newer deployment target than x86_64. |
| 102 |
if [ "${{ runner.arch }}" = "X64" ]; then |
| 103 |
echo "MACOSX_DEPLOYMENT_TARGET=10.9" >> "$GITHUB_ENV" |
| 104 |
echo "ARCHFLAGS=-arch x86_64" >> "$GITHUB_ENV" |
| 105 |
else |
| 106 |
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> "$GITHUB_ENV" |
| 107 |
fi |
| 108 |
|
| 109 |
- name: Install Linux build prerequisites |
| 110 |
if: runner.os == 'Linux' |
| 111 |
run: | |
| 112 |
sudo apt-get update |
| 113 |
sudo apt-get install -y --no-install-recommends cmake ninja-build libcurl4-openssl-dev zlib1g-dev \ |
| 114 |
libssl-dev liblzma-dev libbz2-dev libdeflate-dev |
| 115 |
|
| 116 |
- name: Install macOS build prerequisites |
| 117 |
if: runner.os == 'macOS' |
| 118 |
run: | |
| 119 |
brew install automake cmake libdeflate ninja pkg-config |
| 120 |
|
| 121 |
- name: Install |
| 122 |
run: | |
| 123 |
python -m pip install --upgrade pip |
| 124 |
python -m pip install pytest pytest-cov |
| 125 |
CYVCF2_HTSLIB_CONFIGURE_OPTIONS="--enable-libcurl --enable-s3 --enable-lzma --enable-bz2 --with-libdeflate" \ |
| 126 |
python -m pip install -v -e . |
| 127 |
|
| 128 |
- name: Test |
| 129 |
run: | |
| 130 |
pytest --cov cyvcf2 --cov-report term-missing |
| 131 |
|
| 132 |
# make sure to keep this numpy version in sync with pyproject.toml |
| 133 |
- name: Test with oldest numpy that we support |
| 134 |
if: contains(fromJson('["3.9"]'), matrix.python-version) |
| 135 |
run: | |
| 136 |
pip install --force-reinstall --no-cache-dir 'numpy==2.0.0' |
| 137 |
pytest --cov cyvcf2 --cov-report term-missing |
| 138 |
|
| 139 |
- name: Test with newest available numpy |
| 140 |
if: matrix.os == 'ubuntu-22.04' && matrix.python-version == '3.14' |
| 141 |
run: | |
| 142 |
pip install -U numpy |
| 143 |
pytest --cov cyvcf2 --cov-report term-missing |
| 144 |
|
| 145 |
windows_build: |
| 146 |
name: Run tests on Python windows-2022 MSYS2 UCRT64 |
| 147 |
runs-on: windows-2022 |
| 148 |
defaults: |
| 149 |
run: |
| 150 |
shell: msys2 {0} |
| 151 |
|
| 152 |
steps: |
| 153 |
- uses: actions/checkout@v4 |
| 154 |
with: |
| 155 |
submodules: recursive |
| 156 |
|
| 157 |
- name: "Setup MSYS2" |
| 158 |
uses: msys2/setup-msys2@v2 |
| 159 |
with: |
| 160 |
msystem: UCRT64 |
| 161 |
path-type: inherit |
| 162 |
install: >- |
| 163 |
mingw-w64-ucrt-x86_64-gcc |
| 164 |
mingw-w64-ucrt-x86_64-make |
| 165 |
mingw-w64-ucrt-x86_64-libdeflate |
| 166 |
mingw-w64-ucrt-x86_64-xz |
| 167 |
mingw-w64-ucrt-x86_64-curl |
| 168 |
mingw-w64-ucrt-x86_64-cmake |
| 169 |
mingw-w64-ucrt-x86_64-zlib |
| 170 |
mingw-w64-ucrt-x86_64-bzip2 |
| 171 |
mingw-w64-ucrt-x86_64-tools-git |
| 172 |
mingw-w64-ucrt-x86_64-python-pkgconfig |
| 173 |
mingw-w64-ucrt-x86_64-pkg-config |
| 174 |
mingw-w64-ucrt-x86_64-ninja |
| 175 |
mingw-w64-ucrt-x86_64-python |
| 176 |
mingw-w64-ucrt-x86_64-python-pip |
| 177 |
make |
| 178 |
automake |
| 179 |
autoconf |
| 180 |
git |
| 181 |
|
| 182 |
- name: Install Windows build prerequisites |
| 183 |
run: | |
| 184 |
cd htslib |
| 185 |
autoreconf -i |
| 186 |
./configure --enable-libcurl --enable-s3 --enable-lzma --enable-bz2 --with-libdeflate |
| 187 |
make |
| 188 |
make install |
| 189 |
|
| 190 |
- name: Install |
| 191 |
run: | |
| 192 |
python -m venv .venv |
| 193 |
. .venv/bin/activate |
| 194 |
python -m pip install --upgrade pip |
| 195 |
python -m pip install pytest pytest-cov |
| 196 |
python -m pip install -v -e . |
| 197 |
|
| 198 |
- name: Test |
| 199 |
run: | |
| 200 |
. .venv/bin/activate |
| 201 |
pytest --cov cyvcf2 --cov-report term-missing |
| 202 |
|
| 203 |
- name: Test with newest available numpy |
| 204 |
run: | |
| 205 |
. .venv/bin/activate |
| 206 |
pip install -U numpy |
| 207 |
pytest --cov cyvcf2 --cov-report term-missing |
| 208 |
|
| 209 |
conda_external_htslib: |
| 210 |
name: Conda external htslib ${{ matrix.htslib-version }} |
| 211 |
runs-on: ubuntu-22.04 |
| 212 |
strategy: |
| 213 |
fail-fast: false |
| 214 |
matrix: |
| 215 |
htslib-version: ["1.21", "1.22.1", "1.23.1"] |
| 216 |
|
| 217 |
steps: |
| 218 |
- uses: actions/checkout@v4 |
| 219 |
with: |
| 220 |
submodules: recursive |
| 221 |
|
| 222 |
- name: Set up micromamba |
| 223 |
uses: mamba-org/setup-micromamba@v2 |
| 224 |
with: |
| 225 |
environment-name: cyvcf2-conda-external |
| 226 |
condarc: | |
| 227 |
channels: |
| 228 |
- conda-forge |
| 229 |
- bioconda |
| 230 |
channel_priority: strict |
| 231 |
create-args: >- |
| 232 |
python=3.12 |
| 233 |
pip |
| 234 |
scikit-build-core>=0.11 |
| 235 |
cmake>=3.20 |
| 236 |
ninja |
| 237 |
cython>=3 |
| 238 |
numpy>=2.0.0 |
| 239 |
htslib=${{ matrix.htslib-version }} |
| 240 |
pkg-config |
| 241 |
setuptools |
| 242 |
wheel |
| 243 |
|
| 244 |
- name: Install against conda htslib |
| 245 |
shell: micromamba-shell {0} |
| 246 |
run: | |
| 247 |
export CYVCF2_HTSLIB_MODE=EXTERNAL |
| 248 |
export CMAKE_PREFIX_PATH="${CONDA_PREFIX}${CMAKE_PREFIX_PATH:+:${CMAKE_PREFIX_PATH}}" |
| 249 |
export PKG_CONFIG_PATH="${CONDA_PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}" |
| 250 |
|
| 251 |
python -m pip install . --no-deps --no-build-isolation -v > conda-external-build.log 2>&1 |
| 252 |
cat conda-external-build.log |
| 253 |
if grep -E "building bundled( shared)? htslib" conda-external-build.log; then |
| 254 |
echo "Expected external htslib, but build used bundled htslib" |
| 255 |
exit 1 |
| 256 |
fi |
| 257 |
|
| 258 |
- name: Verify external htslib linkage |
| 259 |
shell: micromamba-shell {0} |
| 260 |
run: | |
| 261 |
extension="$(cd "${RUNNER_TEMP}" && python -c 'import cyvcf2.cyvcf2 as module; print(module.__file__)')" |
| 262 |
echo "Extension path: ${extension}" |
| 263 |
|
| 264 |
cd "${RUNNER_TEMP}" |
| 265 |
python -c 'from cyvcf2 import VCF; print(VCF)' |
| 266 |
|
| 267 |
ldd "${extension}" | tee "${GITHUB_WORKSPACE}/conda-external-linkage.txt" |
| 268 |
grep -E "libhts\.so" "${GITHUB_WORKSPACE}/conda-external-linkage.txt" |
| 269 |
|
| 270 |
sdist: |
| 271 |
runs-on: ubuntu-22.04 |
| 272 |
strategy: |
| 273 |
matrix: |
| 274 |
python-version: ["3.14"] |
| 275 |
|
| 276 |
steps: |
| 277 |
- uses: actions/checkout@v4 |
| 278 |
with: |
| 279 |
submodules: recursive |
| 280 |
- name: Set up Python ${{ matrix.python-version }} |
| 281 |
uses: actions/setup-python@v5 |
| 282 |
with: |
| 283 |
python-version: ${{ matrix.python-version }} |
| 284 |
|
| 285 |
- name: Install sdist prerequisites |
| 286 |
run: | |
| 287 |
python -m pip install --upgrade pip build |
| 288 |
|
| 289 |
- name: Create source distribution |
| 290 |
run: python -m build --sdist |
| 291 |
|
| 292 |
- name: Install Linux build prerequisites |
| 293 |
if: runner.os == 'Linux' |
| 294 |
run: | |
| 295 |
sudo apt-get update |
| 296 |
sudo apt-get install -y --no-install-recommends libcurl4-openssl-dev zlib1g-dev libssl-dev liblzma-dev \ |
| 297 |
libbz2-dev libdeflate-dev |
| 298 |
|
| 299 |
- name: Build (via sdist tarball) |
| 300 |
run: python -m pip install --verbose --no-binary='cyvcf2' cyvcf2-*.tar.gz |
| 301 |
working-directory: dist |
| 302 |
|
| 303 |
- name: Install test prerequisites |
| 304 |
# pytest 8.2.0~8.2.1 changed the behaivour of --import-mode, can't ignore local cyvcf2 folder. |
| 305 |
# So we need to pin it before it breaks again. |
| 306 |
run: | |
| 307 |
pip install pytest==8.1.2 pytest-cov |
| 308 |
|
| 309 |
- name: Test |
| 310 |
run: | |
| 311 |
pytest --import-mode importlib --cov cyvcf2 --cov-report term-missing |
| 312 |
|
| 313 |
- name: Test with newest available numpy |
| 314 |
run: | |
| 315 |
pip install -U numpy |
| 316 |
pytest --import-mode importlib --cov cyvcf2 --cov-report term-missing |
| 317 |
|
| 318 |
- name: Upload sdist tarball |
| 319 |
if: runner.os == 'Linux' |
| 320 |
uses: actions/upload-artifact@v4 |
| 321 |
with: |
| 322 |
name: sdist |
| 323 |
path: dist/cyvcf2-*.tar.gz |
| 324 |
retention-days: 7 |