forked from cavalab/srbench
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (147 loc) · 5.27 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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 }}