GHA: Test composite actions #9469
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: C++/Python Tests | |
on: | |
push: | |
merge_group: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Tests Ubuntu | |
# TODO: prepare image with more deps preinstalled | |
runs-on: ubuntu-22.04 | |
env: | |
AMICI_PARALLEL_COMPILE: "" | |
ENABLE_GCOV_COVERAGE: "TRUE" | |
CI_SONARCLOUD: "TRUE" | |
strategy: | |
matrix: | |
python-version: [ 3.9 ] | |
steps: | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: actions/checkout@v3 | |
- run: git fetch --prune --unshallow | |
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV | |
- run: echo "BNGPATH=${GITHUB_WORKSPACE}/ThirdParty/BioNetGen-2.7.0" >> $GITHUB_ENV | |
# sonar cloud | |
- run: echo "SONAR_SCANNER_VERSION=5.0.1.3006" >> $GITHUB_ENV | |
- run: echo "SONAR_SCANNER_HOME=${HOME}/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux" >> $GITHUB_ENV | |
- run: echo "SONAR_SCANNER_OPTS=-server" >> $GITHUB_ENV | |
- run: echo "${SONAR_SCANNER_HOME}/bin" >> $GITHUB_PATH | |
- run: echo "${HOME}/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH | |
# TODO: add to ci image | |
- name: Install sonarcloud tools | |
run: | | |
sudo apt-get install nodejs curl unzip \ | |
&& curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip \ | |
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip \ | |
&& unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ \ | |
&& curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \ | |
https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip \ | |
&& unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ \ | |
- name: Install apt dependencies | |
uses: ./.github/actions/install-apt-dependencies | |
# install amici dependencies | |
- name: apt | |
run: | | |
sudo apt-get update \ | |
&& sudo apt-get install -y \ | |
cmake \ | |
g++ \ | |
python3-venv \ | |
lcov \ | |
libboost-math-dev | |
- name: Build AMICI dependencies | |
run: | | |
scripts/buildDependencies.sh | |
- name: Build AMICI | |
run: | | |
CI_SONARCLOUD=TRUE scripts/buildAmici.sh | |
- name: C++ tests | |
run: | | |
scripts/run-cpp-tests.sh | |
- name: Install python package | |
run: | | |
scripts/installAmiciSource.sh | |
- name: Python tests | |
run: | | |
source build/venv/bin/activate \ | |
&& pytest \ | |
--ignore-glob=*petab* \ | |
--ignore-glob=*test_splines.py \ | |
--cov=amici \ | |
--cov-report=xml:"${AMICI_DIR}/build/coverage_py.xml" \ | |
--cov-append \ | |
--durations=10 \ | |
${AMICI_DIR}/python/tests | |
- name: Python tests splines | |
if: ${{ github.base_ref == 'master' || github.event.merge_group.base_ref == 'master'}} | |
run: | | |
source build/venv/bin/activate \ | |
&& pytest \ | |
--cov=amici \ | |
--cov-report=xml:"${AMICI_DIR}/build/coverage_py.xml" \ | |
--cov-append \ | |
--durations=10 \ | |
${AMICI_DIR}/python/tests/test_splines.py | |
- name: Install notebook dependencies | |
run: | | |
source build/venv/bin/activate \ | |
&& pip install jax[cpu] | |
- name: example notebooks | |
run: | | |
scripts/runNotebook.sh python/examples/example_*/ | |
- name: doc notebooks | |
run: | | |
scripts/runNotebook.sh documentation/GettingStarted.ipynb | |
- name: Codecov Python | |
uses: codecov/[email protected] | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: build/coverage_py.xml | |
flags: python | |
fail_ci_if_error: true | |
verbose: true | |
- name: lcov | |
run: | | |
lcov --compat-libtool --no-external \ | |
-d ${AMICI_DIR}/build/CMakeFiles/amici.dir/src \ | |
-b ${AMICI_DIR} -c -o coverage_cpp.info \ | |
&& lcov --compat-libtool --no-external \ | |
-d ${AMICI_DIR}/python/sdist/build/temp_amici/CMakeFiles/amici.dir/src \ | |
-b ${AMICI_DIR}/python/sdist -c -o coverage_py.info \ | |
&& lcov -a coverage_cpp.info -a coverage_py.info -o coverage.info | |
- name: Codecov CPP | |
uses: codecov/[email protected] | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: coverage.info | |
flags: cpp | |
fail_ci_if_error: true | |
- name: Run sonar-scanner | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
sonar-scanner \ | |
-Dsonar.cfamily.build-wrapper-output=bw-output \ | |
-Dsonar.projectVersion="$(git describe --abbrev=4 --dirty=-dirty --always --tags | tr -d '\n')" | |
osx: | |
name: Tests OSX | |
runs-on: macos-latest | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- uses: actions/checkout@v3 | |
- run: git fetch --prune --unshallow | |
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV | |
- run: echo "BNGPATH=${AMICI_DIR}/ThirdParty/BioNetGen-2.7.0" >> $GITHUB_ENV | |
# Ensure CMake is using the python version that we will use for the python tests later on | |
- run: echo "PYTHON_EXECUTABLE=${Python3_ROOT_DIR}/bin/python3" >> $GITHUB_ENV | |
# install amici dependencies | |
- name: homebrew | |
run: | | |
brew install hdf5 swig gcc cppcheck libomp boost \ | |
&& brew ls -v boost \ | |
&& brew ls -v libomp \ | |
&& echo LDFLAGS="-L/usr/local/lib/ -L/usr/local/Cellar/boost/1.81.0_1/lib/" >> $GITHUB_ENV \ | |
&& echo CPPFLAGS="-I /usr/local/Cellar/boost/1.81.0_1/include/" >> $GITHUB_ENV | |
- name: Build AMICI | |
run: | | |
scripts/buildAll.sh | |
- name: Install python package | |
run: | | |
scripts/installAmiciSource.sh | |
- name: cppcheck | |
run: | | |
scripts/run-cppcheck.sh | |
- name: Python tests | |
run: | | |
scripts/run-python-tests.sh | |
- name: C++ tests | |
run: | | |
scripts/run-cpp-tests.sh |