Skip to content

Optimize CI

Optimize CI #380

Workflow file for this run

# Copyright (C) 2023 Roberto Rossini ([email protected])
# SPDX-License-Identifier: MIT
name: Build wheels
on:
workflow_dispatch:
push:
branches: [main]
paths:
- ".github/workflows/wheels.yml"
- "cmake/**"
- "src/**"
- "test/**"
- "utils/devel/stubgen.py"
- "utils/devel/symlink_pyarrow_libs.py"
- "CMakeLists.txt"
- "conanfile.py"
- "pyproject.toml"
tags:
- "v*.*.*"
pull_request:
paths:
- ".github/workflows/wheels.yml"
- "cmake/**"
- "src/**"
- "test/**"
- "utils/devel/stubgen.py"
- "utils/devel/symlink_pyarrow_libs.py"
- "CMakeLists.txt"
- "conanfile.py"
- "pyproject.toml"
release:
types:
- published
# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
matrix-factory:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-result.outputs.matrix }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install cibuildwheel
run: pip install 'cibuildwheel>=2.21'
- name: Generate matrix
id: set-result
run: |
CIBW_ARCHS_LINUX=x86_64 cibuildwheel \
--print-build-identifiers \
--platform linux |
jq -nRc '{"wheel-config": inputs, "os": "ubuntu-latest", "arch": "x86_64"}' |
tee configs.json
if [ '${{ github.event_name }}' != 'pull_request' ]; then
CIBW_ARCHS_LINUX=aarch64 cibuildwheel \
--print-build-identifiers \
--platform linux |
jq -nRc '{"wheel-config": inputs, "os": "ubuntu-latest", "arch": "aarch64"}' |
tee -a configs.json
fi
CIBW_ARCHS_MACOS=x86_64 cibuildwheel \
--print-build-identifiers \
--platform macos |
jq -nRc '{"wheel-config": inputs, "os": "macos-13", "arch": "x86_64"}' |
tee -a configs.json
CIBW_ARCHS_MACOS=arm64 cibuildwheel \
--print-build-identifiers \
--platform macos |
jq -nRc '{"wheel-config": inputs, "os": "macos-14", "arch": "arm64"}' |
tee -a configs.json
CIBW_ARCHS_WINDOWS=AMD64 cibuildwheel \
--print-build-identifiers \
--platform windows |
jq -nRc '{"wheel-config": inputs, "os": "windows-2019", "arch": "AMD64"}' |
tee -a configs.json
MATRIX="$(jq -sc < configs.json)"
echo "matrix=include: $MATRIX" | tee -a "$GITHUB_OUTPUT"
build-conan-deps-linux-x86:
name: Build Conan deps (Linux x86_64)
uses: paulsengroup/hictkpy/.github/workflows/build-conan-deps.yml@main
with:
arch: x86_64
os: manylinux_2_28
build-conan-deps-linux-arm64:
name: Build Conan deps (Linux arm64)
if: github.event_name != 'pull_request'
uses: paulsengroup/hictkpy/.github/workflows/build-conan-deps.yml@main
with:
arch: aarch64
os: manylinux_2_28
build-conan-deps-macos-x86:
name: Build Conan deps (macOS x86_64)
uses: paulsengroup/hictkpy/.github/workflows/build-conan-deps.yml@main
with:
arch: x86_64
os: macos-13
build-conan-deps-macos-arm64:
name: Build Conan deps (macOS arm64)
uses: paulsengroup/hictkpy/.github/workflows/build-conan-deps.yml@main
with:
arch: arm64
os: macos-14
build-conan-deps-windows-x86:
name: Build Conan deps (Windows x86_64)
uses: paulsengroup/hictkpy/.github/workflows/build-conan-deps.yml@main
with:
arch: AMD64
os: windows-2019
build-sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build SDist
run: pipx run build --sdist
- name: Check metadata
run: pipx run twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
build-wheels:
name: Build Wheels
needs:
- matrix-factory
- build-conan-deps-linux-x86
- build-conan-deps-linux-arm64
- build-conan-deps-macos-x86
- build-conan-deps-macos-arm64
- build-conan-deps-windows-x86
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix-factory.outputs.matrix) }}
env:
CONAN_HOME: "${{ github.workspace }}/.conan2/"
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
if: matrix.os == 'linux'
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Restore Conan cache (Linux; x86_64)
if: matrix.os == 'linux' && matrix.arch == 'x86_64'
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps-linux-x86.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}/p
fail-on-cache-miss: true
- name: Restore Conan cache (Linux; aarch64)
if: |
github.event_name != 'pull_request' &&
matrix.os == 'linux' &&
matrix.arch == 'aarch64'
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps-linux-arm64.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}/p
fail-on-cache-miss: true
- name: Restore Conan cache (macOS; x86_64)
if: startsWith(matrix.os, 'macos') && matrix.arch == 'x86_64'
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps-macos-x86.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}/p
fail-on-cache-miss: true
- name: Restore Conan cache (macOS; aarch64)
if: startsWith(matrix.os, 'macos') && matrix.arch == 'arm64'
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps-macos-arm64.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}/p
fail-on-cache-miss: true
- name: Restore Conan cache (Windows; AMD64)
if: startsWith(matrix.os, 'windows') && matrix.arch == 'AMD64'
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps-windows-x86.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}\p
fail-on-cache-miss: true
- name: Build wheels
uses: pypa/[email protected]
with:
only: ${{ matrix.wheel-config }}
env:
CIBW_ENVIRONMENT: "PIP_VERBOSE=1 HICTK_CI=1"
CIBW_ENVIRONMENT_MACOS: "CC=clang CXX=clang++ MACOSX_DEPLOYMENT_TARGET=10.15"
CIBW_ENVIRONMENT_PASS_LINUX: "CONAN_HOME"
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28"
CIBW_MANYLINUX_AARCH64_IMAGE: "manylinux_2_28"
- name: Verify clean directory
run: git diff --exit-code
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: "wheels-${{ matrix.os }}-${{ matrix.arch }}"
path: wheelhouse/*.whl
if-no-files-found: error
retention-days: 1
package-artifacts:
name: Package artifacts
runs-on: ubuntu-latest
needs:
- build-sdist
- build-wheels
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Archive artifacts
run: |
mkdir dist/
find artifacts -type f -name "hictkpy*.whl" -exec cp '{}' dist/ \;
find artifacts -type f -name "hictkpy*.tar.gz" -exec cp '{}' dist/ \;
tar -cf dist.tar dist/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist.tar
if-no-files-found: error
retention-days: 30
build-wheels-status-check:
name: Status Check (Build wheels)
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- build-sdist
- build-wheels
- package-artifacts
steps:
- name: Collect job results
if: |
needs.build-sdist.result != 'success' ||
needs.build-wheels.result != 'success' ||
needs.package-artifacts.result != 'success'
run: exit 1