Skip to content

WIP: initial mamba / micromamba support #359

WIP: initial mamba / micromamba support

WIP: initial mamba / micromamba support #359

Workflow file for this run

name: Build and test the package
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
defaults:
run:
shell: bash
jobs:
testbed:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest,macos-latest,windows-latest]
steps:
- name: Retrieve the source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- id: conda-root
name: Set CONDA_ROOT
run: |
CONDA_ROOT=$(dirname $GITHUB_WORKSPACE)/conda
echo "value=$CONDA_ROOT" >> $GITHUB_OUTPUT
echo "CONDA_ROOT=$CONDA_ROOT" >> $GITHUB_ENV
# Use a smaller cache entry to enable a quicker exit if we
# have already built the testbed. Any small file will do
- id: cache-key
name: Retrieve cache key
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: ./LICENSE
key: key-${{ matrix.os }}-${{ hashFiles('testbed') }}
- id: cache
name: Retrieve or create the conda cache
if: steps.cache-key.outputs.cache-hit != 'true'
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: ${{ steps.conda-root.outputs.value }}
key: testbed-${{ matrix.os }}-${{ hashFiles('testbed') }}
- name: Install Miniconda
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3
if: steps.cache-key.outputs.cache-hit != 'true'
with:
auto-activate-base: true
activate-environment: ""
- name: Verify or build the testbed
if: steps.cache-key.outputs.cache-hit != 'true'
# The argument tells the script we are in caching mode
run: testbed/build.sh
build:
runs-on: ubuntu-latest
steps:
- name: Retrieve the source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Build the package
id: build
run: |
source $CONDA/etc/profile.d/conda.sh
conda install conda conda-build --yes
conda build conda-recipe
mv $CONDA/conda-bld .
- name: Upload the build artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: package-${{ github.sha }}
path: conda-bld
tests:
runs-on: ${{ matrix.os }}
needs: [build,testbed]
strategy:
fail-fast: false
matrix:
os: [macos-latest,ubuntu-latest,windows-latest]
pyver: ["3.9","3.12"]
solver: ["conda", "mamba", "micromamba"]
steps:
- name: Retrieve the source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- id: conda-root
name: Set CONDA_ROOT and artifact suffix
run: |
if [ "$RUNNER_OS" = "Windows" ]; then sfx=win; else sfx=unx; fi
echo "::set-output name=suffix::$sfx"
CONDA_ROOT=$(dirname $GITHUB_WORKSPACE)/conda
echo "::set-output name=value::$CONDA_ROOT"
echo "CONDA_ROOT=$CONDA_ROOT" >> $GITHUB_ENV
echo "PACKAGE SUFFIX: $sfx"
echo "CONDA_ROOT: $CONDA_ROOT"
- name: Retrieve the build artfiact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: package-${{ github.sha }}
path: conda-bld
- name: Retrieve the testbed
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: ${{ steps.conda-root.outputs.value }}
key: testbed-${{ matrix.os }}-${{ hashFiles('testbed') }}
- name: Verify the testbed
run: testbed/build.sh
- name: Test the package
run: |
source $CONDA_ROOT/etc/profile.d/conda.sh
[ "$RUNNER_OS" = "Windows" ] && export PYTHONIOENCODING=UTF-8
export PYTHONUNBUFFERED=1
export NBVER=6
[ 3.12 = ${{ matrix.pyver }} ] && export NBVER=7
conda create -n testbase -c ./conda-bld nb_conda_kernels python=${{ matrix.pyver }} notebook=$NBVER pytest pytest-cov mock requests
conda activate testbase
solver=${{ matrix.solver }}
[ $solver = conda ] || export CONDA_EXE=$(echo $CONDA_EXE | sed -E "s@^(.*/)conda(.*)@\\1${solver}\\2@")
[ $solver = mamba ] && export NBCK_NO_ACTIVATE_SCRIPT=yes
[ $solver = micromamba ] && export MAMBA_EXE=$CONDA_EXE
[ $solver = micromamba ] && export MAMBA_ROOT_PREFIX=$CONDA_ROOT
python -m nb_conda_kernels list
python -m pytest -v --cov=nb_conda_kernels tests 2>&1 | tee build.log
# Because Windows refuses to preserve the error code
if grep -E '^(FAILED|ERROR) ' build.log; then exit -1; fi
upload:
needs: tests
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Retrieve the source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Retrieve the artfiact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: package-${{ github.sha }}
path: conda-bld
- name: Upload to anaconda.org
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
source $CONDA/bin/activate
conda install -y anaconda-client
git describe --exact-match --tags HEAD || export LABEL="--label dev"
anaconda --verbose --token $ANACONDA_TOKEN upload --user jupycon $LABEL conda-bld/*/*.tar.bz2 --force
- name: Clean up older artifacts
uses: glassechidna/artifact-cleaner@master
with:
minimumAge: 86400