Skip to content

Commit

Permalink
Merge pull request #70 from n-claes/tests/improved_testing
Browse files Browse the repository at this point in the history
Improved CI, code coverage and test extensions
  • Loading branch information
n-claes authored Jul 8, 2021
2 parents 660979c + 515d366 commit 3c70a4f
Show file tree
Hide file tree
Showing 138 changed files with 7,078 additions and 4,129 deletions.
146 changes: 146 additions & 0 deletions .github/workflows/legolas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
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/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
coverage: true
- name: regression
coverage: true

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- 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
sudo apt-get install lcov
gfortran-9 --version
cmake --version
which gcov
which gcov-9
- name: Install Python dependencies & Pylbo
run: |
python -m pip install --upgrade pip
pip install pytest numpy matplotlib f90nml tqdm psutil pytest-mpl
cd post_processing
python setup.py develop
- name: Cache pFUnit
id: pfunit-cache
uses: actions/cache@v1
with:
path: tests/pFUnit/
key: ${{ runner.os }}-pfunitv1

- name: Build pFUnit
if: steps.pfunit-cache.outputs.cache-hit != 'true'
run: |
cd 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: |
mkdir build
cd build
if [[ "${{ matrix.coverage }}" ]]; then
cmake -DCoverage=ON ..
else
cmake ..
fi
make -j 2
- 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
mkdir coverage
cd coverage
lcov --capture --directory $LEGOLASDIR/build \
--output-file ${{ matrix.name }}.info \
--gcov-tool /usr/bin/gcov-9
fi
# filter out coverage files
find $LEGOLASDIR/build -name '*.gc*' -delete
- name: Archive failed logs
uses: actions/upload-artifact@v2
if: failure()
with:
name: failed_logs
path: tests/regression_tests/image_comparisons

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

This file was deleted.

27 changes: 3 additions & 24 deletions .github/workflows/pylbo_core.yml → .github/workflows/pylbo.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pylbo-core
name: pylbo

on:
push:
Expand Down Expand Up @@ -53,32 +53,11 @@ jobs:
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install pytest numpy matplotlib f90nml tqdm psutil pytest-mpl pytest-timeout
pip install pytest pytest-cov
cd post_processing
python setup.py develop
- name: Install Legolas 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: Compile Legolas
run: sh setup_tools/buildlegolas.sh

- name: Test Pylbo core
run: |
cd tests/pylbo_tests
pytest --mpl --mpl-results-path=results --verbose
- name: Archive failed logs
uses: actions/upload-artifact@v1
if: failure()
with:
name: failed_logs
path: tests/pylbo_tests/results
pytest -v
77 changes: 0 additions & 77 deletions .github/workflows/regression_tests.yml

This file was deleted.

1 change: 1 addition & 0 deletions post_processing/pylbo/automation/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
("sigma_1", (int, np.integer, float)),
("sigma_2", (int, np.integer, float)),
("force_r0", bool),
("coaxial", bool),
],
"equilibriumlist": [
("equilibrium_type", str),
Expand Down
12 changes: 12 additions & 0 deletions post_processing/pylbo/testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pickle


def pickle_dataseries_to_file(series, filepath):
with open(filepath, "wb") as ostream:
pickle.dump(series, ostream, pickle.HIGHEST_PROTOCOL)


def load_pickled_dataseries(filepath):
with open(filepath, "rb") as istream:
series = pickle.load(istream)
return series
Loading

0 comments on commit 3c70a4f

Please sign in to comment.