Skip to content

Added a casadi function interface with tests (example to come) #652

Added a casadi function interface with tests (example to come)

Added a casadi function interface with tests (example to come) #652

name: Run the tests
on: [pull_request]
env:
PREFIX_LINUX: /usr/share/miniconda3/envs/bioptim
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
shard: [1, 2, 3, 4, 5, 6]
name: Tests on ${{ matrix.os }}-shard ${{ matrix.shard }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- name: Set prefix Linux
run: echo "PREFIX=${{ env.PREFIX_LINUX }}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v3
- name: Setup environment
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
activate-environment: bioptim
environment-file: environment.yml
- name: Print mamba info
run: |
mamba info
mamba list
- name: Install extra dependencies
run: |
mamba install pytest-cov black pytest pytest-cov codecov packaging -cconda-forge
sudo apt install -y librhash-dev
- name: Install ACADOS on Linux
run: |
pwd
cd external
./acados_install_linux.sh 4 ${{ env.PREFIX_LINUX }}
cd ..
if: matrix.shard == 1
- name: Test installed version of bioptim
run: |
python setup.py install
cd
python -c "import bioptim"
if: matrix.shard == 1
- name: Run tests with code coverage
run: pytest -v --color=yes --cov-report term-missing --cov=bioptim --cov-report=xml:coverage.xml tests/shard${{ matrix.shard }}
if: matrix.os == 'ubuntu-latest'
- name: Archive coverage report
id: archive
uses: actions/upload-artifact@v3
with:
name: coverage${{ matrix.shard }}
path: |
coverage.xml
.coverage
merge-coverage:
needs: build
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Set prefix Linux
run:
echo "PREFIX=${{ env.PREFIX_LINUX }}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v3
- name: Setup environment
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
activate-environment: bioptim
environment-file: environment.yml
- name: Print mamba info
run: |
mamba info
# mamba list
- name: Install extra dependencies
run: |
sudo apt-get install -y python3-pip
pip3 install coverage
- name: Download all workflow run artifacts
id: download
uses: actions/download-artifact@v3
- name: Rename coverage files
run: |
for shard in {1,2,3,4,5,6}; do
mv coverage${shard}/coverage.xml coverage${shard}.xml
mv coverage${shard}/.coverage* .coverage${shard}
done
- name: Show current dir content
run: pwd; ls -a -l
- name: Merge coverage reports
run: coverage combine .coverage1 .coverage2 .coverage3 .coverage4
- name: Show current dir content with new .coverage file
run: pwd; ls -a
- name: Generate XML report
run: |
coverage xml
coverage report -m
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
#token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
#files: ./coverage1.xml, ./coverage2.xml, ./coverage3.xml, ./coverage4.xml
flags: unittests
fail_ci_if_error: true
verbose: true