-
Notifications
You must be signed in to change notification settings - Fork 7
132 lines (126 loc) · 4.57 KB
/
CI-test.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
# This workflow will reformat all python files with yapf
name: CI-test
on:
# push:
# branches:
# - main
workflow_dispatch:
permissions:
contents: read
jobs:
build_and_test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-13]
# macos-latest should be added later as soon as libsbml support is back up
python-version: ['3.9', '3.10', '3.11', '3.12']
package-manager: ['pip','conda','conda_env']
# exclude:
# - os: macos-latest
# package-manager: 'pip'
steps:
- uses: actions/checkout@v4
- name: Cache Conda packages
uses: actions/cache@v4
with:
path: |
~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ hashFiles('**/environment.yml') }}
restore-keys: |
${{ runner.os }}-conda-
- name: Cache pip packages
uses: actions/cache@v4
with:
path: |
~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Java Setup
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
- name: Set JAVA_HOME for mac OS
if: runner.os == 'macOS'
run: export JAVA_HOME=$(/usr/libexec/java_home)
- name: Set up Conda Environment with Micromamba (conda environment test)
if: matrix.package-manager == 'conda_env'
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.5.8-0'
environment-file: environment.yml
create-args: >-
python=${{ matrix.python-version }}
post-cleanup: 'none'
- name: Build for PyPI (if pip)
if: matrix.package-manager == 'pip'
run: |
pip install setuptools wheel
python setup.py sdist bdist_wheel
- name: Install package using pip
if: matrix.package-manager == 'pip'
run: pip install ./dist/*.whl
- name: Install gurobi (pip)
if: matrix.package-manager == 'pip'
run: |
pip install gurobipy
- name: Install cplex (pip)
if: matrix.package-manager == 'pip' && runner.os != 'macOS' && matrix.python-version != '3.12' && matrix.python-version != '3.13'
run: |
pip install cplex
- name: Install pytest (pip)
if: matrix.package-manager == 'pip'
run: |
pip install pytest pytest-timeout
- name: Set up Conda Environment with Micromamba
if: matrix.package-manager == 'conda'
uses: mamba-org/setup-micromamba@v1
with:
environment-name: straindesign
micromamba-version: latest
create-args: >-
python=${{ matrix.python-version }}
post-cleanup: 'none'
- name: Activate Micromamba environment
if: matrix.package-manager == 'conda'
run: |
micromamba activate straindesign
- name: Build for Conda (if conda)
if: matrix.package-manager == 'conda'
run: |
micromamba install anaconda-client conda-build
run: rm -rf conda-bld
conda build conda-recipe/. -c conda-forge --croot conda-bld --output-folder ./build
- name: Install package using conda
if: matrix.package-manager == 'conda'
run: |
conda install straindesign -c ./build
- name: Install gurobi (conda)
if: matrix.package-manager == 'conda'
run: |
micromamba install -c gurobi gurobi
- name: Install cplex (conda)
if: matrix.package-manager == 'conda' && matrix.python-version != '3.12' && matrix.python-version != '3.13'
run: |
micromamba install -c ibmdecisionoptimization cplex
- name: Install scip (conda)
if: matrix.package-manager == 'conda' && matrix.python-version != '3.12' && matrix.python-version != '3.13'
run: |
micromamba install -c conda-forge pyscipopt scip
- name: Install pytest (conda)
if: matrix.package-manager == 'conda'
run: |
micromamba install pytest pytest-timeout
- name: Test with pytest
if: matrix.package-manager == 'conda' || matrix.package-manager == 'pip'
run: pytest tests -v --log-cli-level=INFO