Skip to content

Commit

Permalink
use workflow matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv committed Oct 31, 2023
1 parent 4f259af commit 7a89c56
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 164 deletions.
14 changes: 9 additions & 5 deletions .github/actions/workspace/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ inputs:
- delete
path:
required: true
key:
key_prefix:
default: workspace
key_base:
required: true
default: workspace-${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-${{ github.sha }}
default: ${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-${{ github.sha }}
key_suffix:
default: ''
token:
required: false
default: ${{ github.token }}
Expand All @@ -27,18 +31,18 @@ runs:
uses: actions/cache/save@v3
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
key: ${{ inputs.key_prefix }}-${{ inputs.key_base }}-${{ inputs.key_suffix }}
- name: Restore workspace
if: ${{ inputs.action == 'restore' }}
uses: actions/cache/restore@v3
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
key: ${{ inputs.key_prefix }}-${{ inputs.key_base }}-${{ inputs.key_suffix }}
fail-on-cache-miss: true
- name: Delete workspace
if: ${{ inputs.action == 'delete' }}
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
gh cache delete ${{ inputs.key }}
gh cache delete '${{ inputs.key_prefix }}-${{ inputs.key_base }}-${{ inputs.key_suffix }}'
167 changes: 8 additions & 159 deletions .github/workflows/unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,165 +15,14 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
# micromamba activation
shell: bash -l {0}

jobs:
build_shared_unix:
name: Build binaries
strategy:
matrix:
os: [ubuntu-latest]
build_type: [release]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout mamba repository
uses: actions/checkout@v4
- name: Create build environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./dev/environment-dev.yml
environment-name: build_env
cache-environment: true
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ matrix.os }}
restore-keys: |
libmamba-${{ matrix.os }}
- name: Build libmamba
run: |
cmake -B build/ -G Ninja \
--preset mamba-unix-shared-${{ matrix.build_type }} \
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-D CMAKE_C_COMPILER_LAUNCHER=sccache
cmake --build build/ --parallel --parallel
- name: Show build cache statistics
run: sccache --show-stats
- name: Lock environment
run: micromamba env export --explicit > build/environment.lock
- name: Remove extra files before saving workspace
run: find build/ -type d -name CMakeFiles -exec rm -rf {} +
- name: Save workspace
uses: ./.github/actions/workspace
with:
action: save
path: build/

libmamba_tests_unix:
name: libmamba tests
needs: ["build_shared_unix"]
unix_tests:
strategy:
matrix:
os: [ubuntu-latest]
build_type: [release]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout mamba repository
uses: actions/checkout@v4
- name: Restore workspace
uses: ./.github/actions/workspace
with:
action: restore
path: build/
- name: Create build environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./build/environment.lock
environment-name: build_env
- name: Run libmamba tests
run: |
unset CONDARC # Interferes with tests
cd build/libmamba/tests/ && ./test_libmamba
libmambay_tests_unix:
name: libmamba Python bindings tests
needs: ["build_shared_unix"]
strategy:
matrix:
os: [ubuntu-latest]
build_type: [release]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout mamba repository
uses: actions/checkout@v4
- name: Restore workspace
uses: ./.github/actions/workspace
with:
action: restore
path: build/
- name: Create build environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./build/environment.lock
environment-name: build_env
- name: Install libmambapy
run: |
ln build/libmambapy/bindings* libmambapy/libmambapy/
cmake --install build/ --prefix "${CONDA_PREFIX}"
python -m pip install ./libmambapy/
- name: Run libmamba Python bindings tests
run: |
python -m pytest libmambapy/tests/
umamba_integration_tests_unix:
name: Micromamba integration tests
needs: ["build_shared_unix"]
strategy:
matrix:
os: [ubuntu-latest]
build_type: [release]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout mamba repository
uses: actions/checkout@v4
- name: Restore workspace
uses: ./.github/actions/workspace
with:
action: restore
path: build/
- name: Create build environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./build/environment.lock
environment-name: build_env
- name: install zsh, xonsh, fish and tcsh in linux
if: matrix.os == 'ubuntu-latest'
shell: bash -l -eo pipefail {0}
run: |
sudo apt-get install zsh xonsh fish tcsh -y
- name: install xonsh and fish in mac
if: matrix.os == 'macos-latest'
shell: bash -l -eo pipefail {0}
run: |
brew install fish xonsh
- name: micromamba python based tests
shell: bash -l -eo pipefail {0}
run: |
export TEST_MAMBA_EXE=$(pwd)/build/micromamba/micromamba
unset CONDARC # Interferes with tests
pytest -v --capture=tee-sys micromamba/tests/
- name: micromamba local channel test
shell: bash -l -eo pipefail {0}
run: |
unset CONDARC # Interferes with tests
export TEST_MAMBA_EXE=$(pwd)/build/micromamba/micromamba
if [ "$RUNNER_OS" == "Linux" ]; then
mkdir -p $MAMBA_ROOT_PREFIX/conda-bld/linux-64
wget -P $MAMBA_ROOT_PREFIX/conda-bld/linux-64 https://anaconda.org/conda-forge/xtensor/0.21.8/download/linux-64/xtensor-0.21.8-hc9558a2_0.tar.bz2
wget -P $MAMBA_ROOT_PREFIX/conda-bld/linux-64 https://anaconda.org/conda-forge/xtl/0.6.21/download/linux-64/xtl-0.6.21-h0efe328_0.tar.bz2
else
mkdir -p $MAMBA_ROOT_PREFIX/conda-bld/osx-64
wget -P $MAMBA_ROOT_PREFIX/conda-bld/osx-64 https://anaconda.org/conda-forge/xtensor/0.21.8/download/osx-64/xtensor-0.21.8-h879752b_0.tar.bz2
wget -P $MAMBA_ROOT_PREFIX/conda-bld/osx-64 https://anaconda.org/conda-forge/xtl/0.6.21/download/osx-64/xtl-0.6.21-h6516342_0.tar.bz2
fi
conda index $MAMBA_ROOT_PREFIX/conda-bld
"${TEST_MAMBA_EXE}" create -n l_o_cal_test xtensor -c local -c conda-forge -y
"${TEST_MAMBA_EXE}" list -n l_o_cal_test
"${TEST_MAMBA_EXE}" list -n l_o_cal_test | tail -n +3 > list.txt
if [ "$(grep -c "conda-bld" list.txt)" -ne 2 ]; then
exit 1
fi
os: [ubuntu-latest, macos-latest]
build_type: [release, debug]
fail-fast: false
uses: ./.github/workflows/unix_impl.yml
with:
os: ${{ matrix.os }}
build_type: ${{ matrix.build_type }}
158 changes: 158 additions & 0 deletions .github/workflows/unix_impl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
name: Unix tests impl

on:
workflow_call:
inputs:
os:
required: true
type: string
build_type:
required: true
type: string

defaults:
run:
# micromamba activation
shell: bash -l -eo pipefail {0}

jobs:
build_shared_unix:
name: Build binaries
runs-on: ${{ inputs.os }}
steps:
- name: Checkout mamba repository
uses: actions/checkout@v4
- name: Create build environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./dev/environment-dev.yml
environment-name: build_env
cache-environment: true
- uses: hendrikmuhs/ccache-action@main
with:
variant: sccache
key: ${{ github.job }}-${{ inputs.os }}
restore-keys: |
libmamba-${{ inputs.os }}
- name: Build libmamba
run: |
cmake -B build/ -G Ninja \
--preset mamba-unix-shared-${{ inputs.build_type }} \
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-D CMAKE_C_COMPILER_LAUNCHER=sccache
cmake --build build/ --parallel --parallel
- name: Show build cache statistics
run: sccache --show-stats
- name: Lock environment
run: micromamba env export --explicit > build/environment.lock
- name: Remove extra files before saving workspace
run: find build/ -type d -name CMakeFiles -exec rm -rf {} +
- name: Save workspace
uses: ./.github/actions/workspace
with:
action: save
path: build/
key_suffix: ${{ inputs.os }}-${{ inputs.build_type }}

libmamba_tests_unix:
name: libmamba tests
needs: ["build_shared_unix"]
runs-on: ${{ inputs.os }}
steps:
- name: Checkout mamba repository
uses: actions/checkout@v4
- name: Restore workspace
uses: ./.github/actions/workspace
with:
action: restore
path: build/
key_suffix: ${{ inputs.os }}-${{ inputs.build_type }}
- name: Create build environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./build/environment.lock
environment-name: build_env
- name: Run libmamba tests
run: |
unset CONDARC # Interferes with tests
cd build/libmamba/tests/ && ./test_libmamba
libmambay_tests_unix:
name: libmamba Python bindings tests
needs: ["build_shared_unix"]
runs-on: ${{ inputs.os }}
steps:
- name: Checkout mamba repository
uses: actions/checkout@v4
- name: Restore workspace
uses: ./.github/actions/workspace
with:
action: restore
path: build/
key_suffix: ${{ inputs.os }}-${{ inputs.build_type }}
- name: Create build environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./build/environment.lock
environment-name: build_env
- name: Install libmambapy
run: |
ln build/libmambapy/bindings* libmambapy/libmambapy/
cmake --install build/ --prefix "${CONDA_PREFIX}"
python -m pip install ./libmambapy/
- name: Run libmamba Python bindings tests
run: |
python -m pytest libmambapy/tests/
umamba_integration_tests_unix:
name: Micromamba integration tests
needs: ["build_shared_unix"]
runs-on: ${{ inputs.os }}
steps:
- name: Checkout mamba repository
uses: actions/checkout@v4
- name: Restore workspace
uses: ./.github/actions/workspace
with:
action: restore
path: build/
key_suffix: ${{ inputs.os }}-${{ inputs.build_type }}
- name: Create build environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ./build/environment.lock
environment-name: build_env
- name: install zsh, xonsh, fish and tcsh in linux
if: startsWith(inputs.os, 'ubuntu')
run: |
sudo apt-get install zsh xonsh fish tcsh -y
- name: install xonsh and fish in mac
if: startsWith(inputs.os, 'macos')
run: |
brew install fish xonsh
- name: micromamba python based tests
run: |
export TEST_MAMBA_EXE=$(pwd)/build/micromamba/micromamba
unset CONDARC # Interferes with tests
pytest -v --capture=tee-sys micromamba/tests/
- name: micromamba local channel test
run: |
unset CONDARC # Interferes with tests
export TEST_MAMBA_EXE=$(pwd)/build/micromamba/micromamba
if [ "$RUNNER_OS" == "Linux" ]; then
mkdir -p $MAMBA_ROOT_PREFIX/conda-bld/linux-64
wget -P $MAMBA_ROOT_PREFIX/conda-bld/linux-64 https://anaconda.org/conda-forge/xtensor/0.21.8/download/linux-64/xtensor-0.21.8-hc9558a2_0.tar.bz2
wget -P $MAMBA_ROOT_PREFIX/conda-bld/linux-64 https://anaconda.org/conda-forge/xtl/0.6.21/download/linux-64/xtl-0.6.21-h0efe328_0.tar.bz2
else
mkdir -p $MAMBA_ROOT_PREFIX/conda-bld/osx-64
wget -P $MAMBA_ROOT_PREFIX/conda-bld/osx-64 https://anaconda.org/conda-forge/xtensor/0.21.8/download/osx-64/xtensor-0.21.8-h879752b_0.tar.bz2
wget -P $MAMBA_ROOT_PREFIX/conda-bld/osx-64 https://anaconda.org/conda-forge/xtl/0.6.21/download/osx-64/xtl-0.6.21-h6516342_0.tar.bz2
fi
conda index $MAMBA_ROOT_PREFIX/conda-bld
"${TEST_MAMBA_EXE}" create -n l_o_cal_test xtensor -c local -c conda-forge -y
"${TEST_MAMBA_EXE}" list -n l_o_cal_test
"${TEST_MAMBA_EXE}" list -n l_o_cal_test | tail -n +3 > list.txt
if [ "$(grep -c "conda-bld" list.txt)" -ne 2 ]; then
exit 1
fi

0 comments on commit 7a89c56

Please sign in to comment.