Skip to content

Commit

Permalink
Merge pull request CRPropa#357 from lukasmerten/CICD
Browse files Browse the repository at this point in the history
Testing of CRPropa
  • Loading branch information
lukasmerten authored Dec 17, 2021
2 parents a93a821 + 250cff8 commit 7ceeba0
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 158 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: crpropa-testing
on: [push]

jobs:
linux:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: "ubuntu-20"
os: ubuntu-latest
cxx: "g++-9"
cc: "gcc-9"
fc: "gfortran-9"
swig_builtin: "Off" #uses swig 4.0.1
py: "/usr/bin/python3"
cov: "On"
- name: "ubuntu-18_py3"
os: ubuntu-18.04
cxx: "g++-7"
cc: "gcc-7"
fc: "gfortran-7"
swig_builtin: "Off" #uses swig 3.x
py: "/usr/bin/python3"
- name: "ubuntu-18_py2"
os: ubuntu-18.04
cxx: "g++-7"
cc: "gcc-7"
fc: "gfortran-7"
swig_builtin: "Off" #uses swig 3.x
py: "/usr/bin/python2"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Preinstall
run: |
sudo apt-get update
sudo apt-get install libmuparser-dev python3-dev python-dev python3-numpy python-numpy python3-setuptools python-setuptools libhdf5-serial-dev libomp5 libomp-dev libfftw3-dev libcfitsio-dev lcov
- name: Set up the build
env:
CXX: ${{ matrix.config.cxx }}
CC: ${{ matrix.config.cc }}
FC: ${{ matrix.config.fc }}
run: |
mkdir build
cd build
cmake .. -DENABLE_PYTHON=True -DPYTHON_EXECUTABLE=${{ matrix.config.py }} -DENABLE_TESTING=On -DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }} -DSIMD_EXTENSIONS=native
- name: Build CRPropa
run: |
cd build
make
- name: Run tests
run: |
cd build
make test
- name: Archive test results
if: always()
uses: actions/upload-artifact@v2
with:
name: "test-report_${{matrix.config.name}}"
path: build/Testing/Temporary/LastTest.log
mac:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: "macos-1015"
os: macos-10.15
cxx: "clang++"
cc: "clang"
fc: "gfortran-11"
swig_builtin: "On" #uses swig 4.0.2
py: "/usr/bin/python"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Preinstall
run: |
brew install hdf5 fftw cfitsio muparser libomp
- name: Set up the build
env:
CXX: ${{ matrix.config.cxx }}
CC: ${{ matrix.config.cc }}
FC: ${{ matrix.config.fc }}
CRPROPA_DATA_PATH: "/Users/runner/work/CRPropa3/CRPropa3/build/data"
run: |
mkdir build
cd build
cmake .. -DENABLE_PYTHON=True -DPYTHON_EXECUTABLE=${{ matrix.config.py }} -DENABLE_TESTING=On -DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }}
- name: Build CRPropa
run: |
cd build
make
- name: Run tests
env:
CRPROPA_DATA_PATH: "/Users/runner/work/CRPropa3/CRPropa3/build/data"
run: |
cd build
make test
- name: Archive test results
if: always()
uses: actions/upload-artifact@v2
with:
name: "test-report_${{matrix.config.name}}"
path: build/Testing/Temporary/LastTest.log


3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
.*
!.travis.yml

*~

build*
Expand Down
152 changes: 0 additions & 152 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ else()
endif(DOWNLOAD_DATA)
if(EXISTS ${CMAKE_BINARY_DIR}/data-${CRPROPA_DATAFILE_VER}.tar.gz)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${CMAKE_BINARY_DIR}/data-${CRPROPA_DATAFILE_VER}.tar.gz WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/data-${CRPROPA_DATAFILE_VER}/data ${CMAKE_BINARY_DIR}/data/ WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/data-${CRPROPA_DATAFILE_VER}/ WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
else()
message(WARNING "CRPropa data file not found at ${CMAKE_BINARY_DIR}/data-${CRPROPA_DATAFILE_VER}.tar.gz
CRPropa should compile, but will likely not work properly! Please install data file manually, or use the automatic download which is enabled by default.")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CRPropa3
========

[![Build Status](https://api.travis-ci.com/CRPropa/CRPropa3.svg?branch=master)](https://travis-ci.com/CRPropa/CRPropa3)
[![Build status](https://github.com/crpropa/crpropa3/actions/workflows/testing.yml/badge.svg)](https://github.com/crpropa/crpropa3/actions/)
[![Coverage Status](https://coveralls.io/repos/github/CRPropa/CRPropa3/badge.svg)](https://coveralls.io/github/CRPropa/CRPropa3)
[![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/CRPropa/CRPropa3.svg)](https://isitmaintained.com/project/CRPropa/CRPropa3 "Average time to resolve an issue")
[![Percentage of issues still open](https://isitmaintained.com/badge/open/CRPropa/CRPropa3.svg)](https://isitmaintained.com/project/CRPropa/CRPropa3 "Percentage of issues still open")
Expand Down
6 changes: 4 additions & 2 deletions test/testInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,22 +662,24 @@ TEST(EMPairProduction, secondaries) {
// Test if secondaries are correctly produced.
ref_ptr<PhotonField> CMB_instance = new CMB();
ref_ptr<PhotonField> IRB = new IRB_Gilmore12();
ref_ptr<PhotonField> URB = new URB_Protheroe96();
EMPairProduction m(CMB_instance);
m.setHaveElectrons(true);
m.setThinning(0.);

std::vector< ref_ptr<PhotonField> > fields;
fields.push_back(CMB_instance);
fields.push_back(IRB);
fields.push_back(URB);

// loop over photon backgrounds
for (int f = 0; f < fields.size(); f++) {
m.setPhotonField(fields[f]);
for (int i = 0; i < 140; i++) { // loop over energies Ep = (1e10 - 1e23) eV
double Ep = pow(10, 9.05 + 0.1 * i) * eV;
Candidate c(22, Ep);
c.setCurrentStep(std::numeric_limits<double>::max());
// c.setCurrentStep(1e10 * Mpc);
//c.setCurrentStep(std::numeric_limits<double>::max());
c.setCurrentStep(1e10 * Mpc);
m.process(&c);

// pass if no interaction has occured (no tabulated rates)
Expand Down

0 comments on commit 7ceeba0

Please sign in to comment.