From e427c8e7020a53148179a2c400361baf0eae7d65 Mon Sep 17 00:00:00 2001
From: thorstenhater <24411438+thorstenhater@users.noreply.github.com>
Date: Mon, 15 Mar 2021 11:04:59 +0100
Subject: [PATCH] Run C++ examples in CI (#1432)

- Add _running_ C++ examples to standard CI runs (compiling has been in since the start).
- Fix `bench.cpp` to set return value to 1 if exceptions are caught.
---
 .github/workflows/basic.yml | 24 ++++++++++++++++++++++++
 example/bench/bench.cpp     |  1 +
 2 files changed, 25 insertions(+)

diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml
index a12f8a4b..6ff2dee4 100644
--- a/.github/workflows/basic.yml
+++ b/.github/workflows/basic.yml
@@ -154,6 +154,30 @@ jobs:
       - if:   ${{ matrix.config.mpi == 'ON' }}
         name: Run MPI tests
         run:  mpirun -n 4 -oversubscribe build/bin/unit-mpi
+      - if:   ${{ matrix.config.mpi == 'OFF' }}
+        name: Run examples
+        run: |
+            build/bin/bench 
+            build/bin/brunel
+            build/bin/dryrun
+            build/bin/gap_junctions
+            build/bin/generators
+            build/bin/lfp
+            build/bin/probe-demo v
+            build/bin/ring 
+            build/bin/single-cell
+      - if:   ${{ matrix.config.mpi == 'ON' }}
+        name: Run examples with MPI
+        run: |
+            mpirun -n 4 -oversubscribe build/bin/bench 
+            mpirun -n 4 -oversubscribe build/bin/brunel
+            mpirun -n 4 -oversubscribe build/bin/dryrun
+            mpirun -n 4 -oversubscribe build/bin/gap_junctions
+            mpirun -n 4 -oversubscribe build/bin/generators
+            mpirun -n 4 -oversubscribe build/bin/lfp
+            mpirun -n 4 -oversubscribe build/bin/probe-demo v
+            mpirun -n 4 -oversubscribe build/bin/ring 
+            mpirun -n 4 -oversubscribe build/bin/single-cell     
       - name: Run python tests
         run: python python/test/unit/runner.py
       - if:   ${{ matrix.config.mpi == 'ON' }}
diff --git a/example/bench/bench.cpp b/example/bench/bench.cpp
index c1d913d3..ab5912e7 100644
--- a/example/bench/bench.cpp
+++ b/example/bench/bench.cpp
@@ -213,6 +213,7 @@ int main(int argc, char** argv) {
     }
     catch (std::exception& e) {
         std::cerr << "exception caught running benchmark miniapp:\n" << e.what() << std::endl;
+        return 1;
     }
 }
 
-- 
GitLab