Skip to content
Draft
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
51 changes: 38 additions & 13 deletions .github/actions/build-gk/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,26 @@ runs:

- name: create build env
if: ${{ steps.restore_gk_pkg.outputs.cache-hit != 'true' }}
shell: bash -l -e {0}
shell: bash
run: |
set -e
if [[ "$RUNNER_OS" != "Windows" ]]; then
source ${HOME}/.bash_profile 2>/dev/null || true
fi
# Determine env directory
if [[ "$RUNNER_OS" == "Windows" ]]; then
ENV_DIR="$MAMBA_ROOT_PREFIX/envs/build"
else
ENV_DIR="${HOME}/micromamba/envs/build"
fi
set -x
# boa required for the mambabuild subcommand
if [ ! -d "${HOME}/micromamba/envs/build" ]; then
micromamba create -yqn build -c conda-forge boa==0.17.0 mamba==1.5.8 conda=24.5 ccache
if [ ! -d "$ENV_DIR" ]; then
# boa required for the mambabuild subcommand
PKGS="boa==0.17.0 mamba==1.5.8 conda=24.5"
if [[ "$RUNNER_OS" != "Windows" ]]; then
PKGS="$PKGS ccache"
fi
micromamba create -yqn build -c conda-forge $PKGS
fi
set +x

Expand All @@ -53,7 +67,7 @@ runs:
env: build

- name: save mamba gk ccache
if: ${{ steps.restore_gk_pkg.outputs.cache-hit != 'true' }}
if: ${{ steps.restore_gk_pkg.outputs.cache-hit != 'true' && runner.os != 'Windows' }}
id: save_mamba_gk_ccache
uses: actions/cache@v4
with:
Expand All @@ -65,9 +79,10 @@ runs:
~/.ccache

- name: set compiler cache size
if: ${{ steps.restore_gk_pkg.outputs.cache-hit != 'true' }}
shell: bash -l -e {0}
if: ${{ steps.restore_gk_pkg.outputs.cache-hit != 'true' && runner.os != 'Windows' }}
shell: bash
run: |
source ${HOME}/.bash_profile 2>/dev/null || true
set -x
micromamba activate build
ccache -M 100M
Expand All @@ -76,14 +91,24 @@ runs:

- if: ${{ steps.restore_gk_pkg.outputs.cache-hit != 'true' }}
name: build conda package
shell: bash -l -e {0}
shell: bash
run: |
set -e
if [[ "$RUNNER_OS" != "Windows" ]]; then
source ${HOME}/.bash_profile 2>/dev/null || true
fi
set -x
micromamba activate build
mkdir ~/conda-bld
conda mambabuild --croot ~/conda-bld -q --no-test conda-recipe
conda build --croot ~/conda-bld purge
conda clean -it
mkdir -p ~/conda-bld
if [[ "$RUNNER_OS" == "Windows" ]]; then
micromamba run -n build conda mambabuild --croot ~/conda-bld -q --no-test conda-recipe
micromamba run -n build conda build --croot ~/conda-bld purge
micromamba run -n build conda clean -it
else
micromamba activate build
conda mambabuild --croot ~/conda-bld -q --no-test conda-recipe
conda build --croot ~/conda-bld purge
conda clean -it
fi

- name: cache mamba env
if: ${{ steps.restore_gk_pkg.outputs.cache-hit != 'true' }}
Expand Down
28 changes: 20 additions & 8 deletions .github/actions/configure-conda/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,29 @@ inputs:
runs:
using: "composite"
steps:
- shell: bash -l -e {0}
- shell: bash
run: |
source ${HOME}/.bash_profile # for macos
set -x
if [ ! -e "${HOME}/.condarc" ]; then
set -eo pipefail
# Determine condarc location and how to run conda commands
if [[ "$RUNNER_OS" == "Windows" ]]; then
CONDARC="$USERPROFILE/.condarc"
PKGS_ROOT="$MAMBA_ROOT_PREFIX"
RUN_PREFIX="micromamba run -n ${{ inputs.env }}"
else
source ${HOME}/.bash_profile 2>/dev/null || true # for macos
CONDARC="${HOME}/.condarc"
PKGS_ROOT="${HOME}/micromamba"
micromamba activate ${{ inputs.env }}
conda config --set always_yes yes --set changeps1 no --set auto_update_conda no
RUN_PREFIX=""
fi

set -x
if [ ! -e "$CONDARC" ]; then
$RUN_PREFIX conda config --set always_yes yes --set changeps1 no --set auto_update_conda no
# cache additional pkgs separately from docker pre-install
conda config --prepend pkgs_dirs ${HOME}/micromamba/envs/${{ inputs.env }}/pkgs
$RUN_PREFIX conda config --prepend pkgs_dirs "$PKGS_ROOT/envs/${{ inputs.env }}/pkgs"
# fallback to docker pre-installed packages
conda config --append pkgs_dirs ${HOME}/micromamba/pkgs
conda config --prepend channels conda-forge
$RUN_PREFIX conda config --append pkgs_dirs "$PKGS_ROOT/pkgs"
$RUN_PREFIX conda config --prepend channels conda-forge
fi
set +x
3 changes: 2 additions & 1 deletion .github/actions/curl-meta-yaml/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ description: 'Download meta.yaml from the conda-forge GK feedstock'
runs:
using: "composite"
steps:
- shell: bash -l -e {0}
- shell: bash
run: |
set -euo pipefail
# Fail if on main branch and conda-recipe/meta.yaml exists
if [[ "${GITHUB_REF_NAME}" == "main" && -f "conda-recipe/meta.yaml" ]]; then
echo "ERROR: conda-recipe/meta.yaml should not be committed to main. Failing build."
Expand Down
45 changes: 33 additions & 12 deletions .github/actions/install-mamba/action.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
name: 'Install Mamba'
description: 'Install Mamba'
description: 'Install micromamba'
inputs:
installer-url:
description: 'Installer URL'
required: true
runs:
using: "composite"
steps:
- shell: bash -l -e {0}
- shell: bash
run: |
set -x
if [ ! -e ${HOME}/bin/micromamba ]; then
echo "Downloading ${{inputs.installer-url}}"
curl --retry 5 -Lfs "${{ inputs.installer-url }}" | tar -xvj -C ${HOME}/ bin/micromamba
set -eux
if [[ "$RUNNER_OS" == "Windows" ]]; then
MAMBA_DIR="$USERPROFILE/micromamba"
MAMBA_EXE="$MAMBA_DIR/micromamba.exe"
if [ ! -e "$MAMBA_EXE" ]; then
echo "Downloading ${{ inputs.installer-url }}"
ARCHIVE="$RUNNER_TEMP/micromamba.tar.bz2"
EXTRACT_DIR="$RUNNER_TEMP/micromamba-extract"
curl --retry 5 -Lfs -o "$ARCHIVE" "${{ inputs.installer-url }}"
mkdir -p "$EXTRACT_DIR" "$MAMBA_DIR"
# Git Bash tar can't handle Windows drive-letter paths (the colon
# is interpreted as a remote host separator), so use 7z instead.
7z x "$ARCHIVE" -o"$EXTRACT_DIR" -y > /dev/null
7z x "$EXTRACT_DIR"/*.tar -o"$EXTRACT_DIR" -y > /dev/null
cp "$EXTRACT_DIR/Library/bin/micromamba.exe" "$MAMBA_EXE"
[ -e "$MAMBA_EXE" ] || { echo "micromamba.exe not found after extraction"; exit 1; }
echo "micromamba installed at $MAMBA_EXE"
fi
# Add to PATH and set MAMBA_ROOT_PREFIX for subsequent steps
echo "$MAMBA_DIR" >> "$GITHUB_PATH"
echo "MAMBA_ROOT_PREFIX=$MAMBA_DIR" >> "$GITHUB_ENV"
else
if [ ! -e ${HOME}/bin/micromamba ]; then
echo "Downloading ${{ inputs.installer-url }}"
curl --retry 5 -Lfs "${{ inputs.installer-url }}" | tar -xvj -C ${HOME}/ bin/micromamba
fi
# `command -vp` and `hash` don't work on macos for some reason
if ! grep -F "bin/micromamba shell hook -s posix" ${HOME}/.bash_profile >/dev/null 2>&1 ; then
echo "Adding micromamba init to bash profile"
echo "$(~/bin/micromamba shell hook -s posix)" >> ${HOME}/.bash_profile
fi
fi
# `command -vp` and `hash` don't work on macos for some reason
if ! grep -F "bin/micromamba shell hook -s posix" ${HOME}/.bash_profile >/dev/null 2>&1 ; then
echo "Adding micromamba init to bash profile"
echo "$(~/bin/micromamba shell hook -s posix)" >> ${HOME}/.bash_profile
fi
set +x
124 changes: 123 additions & 1 deletion .github/workflows/build-wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,112 @@ jobs:
path: wheelhouse/*.whl


build-wheel-windows:
name: Build windows wheels
runs-on: windows-2022

steps:
- uses: actions/checkout@v4

- name: try to restore the windows wheels cache
id: restore_windows_wheels
uses: actions/cache/restore@v4
with:
key: windows-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
path: wheelhouse/*.whl

# skip remaining steps on cache hit

- if: ${{ steps.restore_windows_wheels.outputs.cache-hit != 'true' }}
name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'


- if: ${{ steps.restore_windows_wheels.outputs.cache-hit != 'true' }}
name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.23.3

- if: ${{ steps.restore_windows_wheels.outputs.cache-hit != 'true' }}
name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse && dir wheelhouse\
env:
GK_BUILD_WHEELS: "1"
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-*"
CIBW_ARCHS_WINDOWS: AMD64
CIBW_ENVIRONMENT_PASS_WINDOWS: GK_BUILD_WHEELS
CIBW_ENVIRONMENT_WINDOWS: >-
INCLUDE="C:\\vcpkg\\installed\\x64-windows-static\\include"
LIB="C:\\vcpkg\\installed\\x64-windows-static\\lib"
CIBW_BEFORE_BUILD_WINDOWS: vcpkg install zlib:x64-windows-static
CIBW_BUILD_VERBOSITY: "3"

- if: ${{ steps.restore_windows_wheels.outputs.cache-hit != 'true' }}
name: cache windows wheels
uses: actions/cache/save@v4
with:
key: ${{ steps.restore_windows_wheels.outputs.cache-primary-key }}
path: wheelhouse/*.whl


test-wheel-windows:
needs: build-wheel-windows
name: Test wheels on windows / Python ${{ matrix.pyver }}
runs-on: windows-2022
strategy:
matrix:
include:
- {"pyver": "3.10", "pyvershort": "310"}
- {"pyver": "3.11", "pyvershort": "311"}
- {"pyver": "3.12", "pyvershort": "312"}
- {"pyver": "3.13", "pyvershort": "313"}

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyver }}

- uses: actions/checkout@v4

- name: Download built wheels
uses: actions/cache/restore@v4
with:
key: windows-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
path: wheelhouse/*.whl
fail-on-cache-miss: true

- name: Install wheel
shell: bash
run: |
wheel=$(ls wheelhouse/*cp${{ matrix.pyvershort }}*win*.whl | head -1)
echo "Installing wheel: $wheel"
pip install "$wheel"

# separate step from above b/c GITHUB_PATH updates don't take effect until the next step
- name: Verify GK loads
shell: bash
run: |
cd "$RUNNER_TEMP"
python -c "import genome_kit; print(genome_kit.__version__)"

- name: Run unit tests
shell: bash
run: |
# Run from a temp dir so that the local genome_kit/ source folder
# doesn't shadow the installed wheel.
test_dir="$RUNNER_TEMP/gk_tests"
mkdir -p "$test_dir"
cp -r tests "$test_dir/tests"
cd "$test_dir"
for f in tests/test_*.py; do
module="tests.$(basename "$f" .py)"
echo "Running: $module"
CI=1 python -m unittest "$module" || exit $?
done


test-wheel-macos:
needs: build-wheel-macos
name: Test wheels on ${{ matrix.os }}
Expand Down Expand Up @@ -215,6 +321,14 @@ jobs:
# path: wheelhouse/*.whl
# fail-on-cache-miss: true
#
# - name: Restore the windows wheels cache
# id: restore_windows_wheels
# uses: actions/cache/restore@v4
# with:
# key: windows-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
# path: wheelhouse/*.whl
# fail-on-cache-miss: true
#
# - name: Debug see what's in wheelhouse dir
# run: |
# set -euxo pipefail
Expand All @@ -231,7 +345,7 @@ jobs:

publish-to-pypi:
name: Publish to PyPI
needs: [build-wheel-linux, test-wheel-macos]
needs: [build-wheel-linux, test-wheel-macos, test-wheel-windows]
runs-on: ubuntu-latest

environment:
Expand Down Expand Up @@ -268,6 +382,14 @@ jobs:
path: wheelhouse/*.whl
fail-on-cache-miss: true

- name: Restore the windows wheels cache
id: restore_windows_wheels
uses: actions/cache/restore@v4
with:
key: windows-wheels-${{ hashFiles('.github/workflows/build-wheels.yaml', '.github/actions/**', 'src/**', 'genome_kit/**', 'pyproject.toml', 'setup.py', 'setup/**') }}
path: wheelhouse/*.whl
fail-on-cache-miss: true

- name: Publish distribution to PyPI
# don't use a version tag with 3rd party actions
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
Expand Down
Loading
Loading