Skip to content

Commit

Permalink
updated CI workflow, added code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
n-claes committed Jun 15, 2021
1 parent 29ed6fc commit fd6aee1
Show file tree
Hide file tree
Showing 35 changed files with 157 additions and 167 deletions.
133 changes: 133 additions & 0 deletions .github/workflows/legolas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: legolas

on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]

env:
CC: /usr/bin/gcc-9
FC: /usr/bin/gfortran-9
PFUNIT_DIR: /home/runner/work/legolas/legolas/tests/core_tests/pFUnit/build/installed
LEGOLASDIR: /home/runner/work/legolas/legolas
ARPACK_ROOT: /home/runner/work/legolas/legolas/tests/arpack-ng

jobs:
test:
name: "${{ matrix.name }}"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- name: unit-tests
script: test_unit.sh
needs-pylbo: false
coverage: true
- name: regression
script: test_regression.sh
needs-pylbo: true
coverage: false

steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt-get install gfortran-9
sudo apt-get -y install cmake
sudo apt-get install libblas-dev
sudo apt-get install liblapack-dev
gfortran-9 --version
cmake --version
- name: Install Pylbo
if: matrix.needs-pylbo
run: |
python -m pip install --upgrade pip
pip install pytest numpy matplotlib f90nml tqdm psutil pytest-mpl gcovr
cd post_processing
python setup.py develop
- name: Cache pFUnit
id: pfunit-cache
uses: actions/cache@v1
with:
path: tests/core_tests/pFUnit/
key: ${{ runner.os }}-pfunitv1

- name: Build pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
run: |
cd tests/core_tests
git clone https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git
cd pFUnit
mkdir build
cd build
cmake .. -DSKIP_MPI=YES -DSKIP_OPENMP=YES -DSKIP_FHAMCREST=YES
make -j 2 tests
make -j 2 install
- name: Cache ARPACK
id: arpack-cache
uses: actions/cache@v1
with:
path: tests/arpack-ng/
key: ${{ runner.os }}-arpackv2

- name: Build ARPACK
if: steps.arpack-cache.outputs.cache-hit != 'true'
run: |
cd tests
git clone https://github.com/opencollab/arpack-ng.git
cd arpack-ng
mkdir build
mkdir installed
cd build
cmake -DEXAMPLES=OFF -DMPI=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=../installed ..
make -j 2
sudo make -j 2 install
- name: Compile Legolas
run: sh setup_tools/buildlegolas.sh coverage

- name: Run tests
run: |
# depending on unit or regression tests we use different coverage options
if [[ "${{ matrix.name }}" == "unit-tests" ]]; then
cd $LEGOLASDIR/tests/unit_tests
mkdir build
cd build
cmake -DCoverage=ON ..
make -j 2
cd ..
./test_legolas
elif [[ "${{ matrix.name }} == "regression" ]]; then
cd $LEGOLASDIR/tests/regression_tests
pytest -v regression.py test*
fi
if [[ "${{ matrix.coverage }}" ]]; then
# generate coverage report
cd $LEGOLASDIR/tests
mkdir coverage
cd $LEGOLASDIR/build
gcovr . -r $LEGOLASDIR/src --print-summary --xml --output $LEGOLASDIR/tests/coverage/${{ matrix.name }}.xml
fi
- name: Archive failed logs
uses: actions/upload-artifact@v2
if: failure() && ${{ matrix.name }} == 'regression'
with:
name: failed_logs
path: tests/regression_tests/image_comparisons
if-no-files-found: warn

- name: Upload coverage report
uses: codecov/codecov-action@v1
if: ${{ matrix.coverage }}
with:
files: $LEGOLASDIR/tests/coverage/${{ matrix.name }}.xml
verbose: true
84 changes: 0 additions & 84 deletions .github/workflows/legolas_core.yml

This file was deleted.

77 changes: 0 additions & 77 deletions .github/workflows/regression_tests.yml

This file was deleted.

5 changes: 4 additions & 1 deletion tests/regression_tests/test_multi_constant_current.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest
import numpy as np
import pylbo
from regression_tests.suite_utils import FIG_DPI, baseline_dir
from regression_tests.suite_utils import FIG_DPI

baseline_dir = ""

NB_RUNS = 24

Expand Down Expand Up @@ -31,6 +33,7 @@
)


@pytest.mark.skip(reason="needs update")
@pytest.mark.parametrize(**parametrisation)
@pytest.mark.mpl_image_compare(
baseline_dir=str(baseline_dir),
Expand Down
5 changes: 4 additions & 1 deletion tests/regression_tests/test_multi_coronal_fluxtube.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest
import numpy as np
import pylbo
from regression_tests.suite_utils import FIG_DPI, baseline_dir
from regression_tests.suite_utils import FIG_DPI

baseline_dir = ""

NB_RUNS = 24

Expand Down Expand Up @@ -31,6 +33,7 @@
)


@pytest.mark.skip(reason="needs update")
@pytest.mark.parametrize(**parametrisation)
@pytest.mark.mpl_image_compare(
baseline_dir=str(baseline_dir),
Expand Down
5 changes: 4 additions & 1 deletion tests/regression_tests/test_multi_gravito_HD.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest
import numpy as np
import pylbo
from regression_tests.suite_utils import FIG_DPI, baseline_dir
from regression_tests.suite_utils import FIG_DPI

baseline_dir = ""

NB_RUNS = 24

Expand Down Expand Up @@ -32,6 +34,7 @@
)


@pytest.mark.skip(reason="needs update")
@pytest.mark.parametrize(**parametrisation)
@pytest.mark.mpl_image_compare(
baseline_dir=str(baseline_dir),
Expand Down
5 changes: 4 additions & 1 deletion tests/regression_tests/test_multi_gravito_MHD.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest
import numpy as np
import pylbo
from regression_tests.suite_utils import FIG_DPI, baseline_dir
from regression_tests.suite_utils import FIG_DPI

baseline_dir = ""

NB_RUNS = 24

Expand Down Expand Up @@ -32,6 +34,7 @@
)


@pytest.mark.skip(reason="needs update")
@pytest.mark.parametrize(**parametrisation)
@pytest.mark.mpl_image_compare(
baseline_dir=str(baseline_dir),
Expand Down
5 changes: 4 additions & 1 deletion tests/regression_tests/test_multi_interchange.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest
import numpy as np
import pylbo
from regression_tests.suite_utils import FIG_DPI, baseline_dir
from regression_tests.suite_utils import FIG_DPI

baseline_dir = ""

NB_RUNS = 24

Expand Down Expand Up @@ -33,6 +35,7 @@
)


@pytest.mark.skip(reason="needs update")
@pytest.mark.parametrize(**parametrisation)
@pytest.mark.mpl_image_compare(
baseline_dir=str(baseline_dir),
Expand Down
Loading

0 comments on commit fd6aee1

Please sign in to comment.