Update environment.yml #376
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
# Controls when the action will run. | |
on: | |
push: | |
paths: | |
- 'algorithms/**' | |
- 'experiment/**' | |
- '.github/workflows/**' | |
pull_request: | |
paths: | |
- 'algorithms/**' | |
- 'experiment/**' | |
- '.github/workflows/**' | |
workflow_dispatch: | |
env: | |
CACHE_NUMBER: 1 | |
jobs: | |
################################################################################ | |
# build the base environment | |
################################################################################ | |
base-env-build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- | |
name: Checkout code | |
uses: actions/checkout@v3 | |
- | |
name: Setup Mambaforge | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: srbench | |
use-mamba: true | |
- | |
name: Cache srbench environment | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: /usr/share/miniconda3/envs/srbench | |
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('base_environment.yml') }} | |
restore-keys: | | |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('base_environment.yml') }} | |
- | |
name: Update srbench environment | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
echo "Didn't find the cache for the srbench environment :(" | |
conda info --envs | |
mamba env update -n srbench -f base_environment.yml | |
################################################################################ | |
# get a list of algorithms | |
################################################################################ | |
list-algs: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: set-matrix | |
run: echo "::set-output name=matrix::$(ls algorithms/ | jq -R -s -c 'split("\n")[:-1]')" | |
################################################################################ | |
# build each algorithm in parallel and run tests | |
################################################################################ | |
build-and-test: | |
runs-on: ubuntu-latest | |
needs: | |
- base-env-build | |
- list-algs | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
matrix: | |
alg: ${{ fromJson(needs.list-algs.outputs.matrix) }} | |
fail-fast: false | |
steps: | |
- | |
name: Checkout code | |
uses: actions/checkout@v3 | |
- | |
name: Setup Mambaforge | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: srbench | |
use-mamba: true | |
- | |
name: Cache srbench environment | |
id: cache-srbench | |
uses: actions/cache@v3 | |
with: | |
path: /usr/share/miniconda3/envs/srbench | |
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | |
restore-keys: | | |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | |
- | |
name: Update srbench environment | |
if: steps.cache-srbench.outputs.cache-hit != 'true' | |
run: | | |
echo "Didn't find the cache for the srbench environment :(" | |
conda info --envs | |
mamba env update -n srbench -f base_environment.yml | |
################################################################################ | |
# install the algorithm | |
################################################################################ | |
# Try to restore alg from cache if none of the files in its directory have changed | |
- | |
name: Cache alg environment | |
id: cache-alg-env | |
uses: actions/cache@v3 | |
with: | |
path: /usr/share/miniconda3/envs/srbench-${{ matrix.alg }} | |
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles(format('./algorithms/{0}/**', matrix.alg)) }} | |
# If no cache, run the install script specifying this algo | |
- | |
name: Install method | |
if: | | |
${{ (steps.cache-alg-env.outputs.cache-hit != 'true') || ( matrix.alg == 'gpgomea') }} | |
run: bash install.sh ${{ matrix.alg }} | |
# If cache is restored, we still have to copy alg files in the experiment folder | |
- | |
name: Copy method files | |
if: | | |
steps.cache-alg-env.outputs.cache-hit == 'true' | |
run: bash scripts/copy_algorithm_files.sh ${{ matrix.alg }} | |
# Print the conda env for debugging purposes | |
- | |
name: Print conda environment | |
run: | | |
echo "/////// Conda Environment (conda env export)/////" | |
conda env export -n srbench-${{ matrix.alg }} | |
echo "/////////////////////////////////////////////////" | |
################################################################################ | |
# tests | |
################################################################################ | |
- | |
name: Test Method | |
run: | | |
cd experiment | |
pwd | |
ls | |
mamba run -n srbench-${{ matrix.alg }} python -m pytest -v test_algorithm.py --ml ${{ matrix.alg }} |