Skip to content

Commit

Permalink
💚 Add CI (#3)
Browse files Browse the repository at this point in the history
* 💚 Add MacOS CI

* 💚 Add Ubuntu CI

* adapt tests

* Include header in chip.cpp

* Add timeout

* Fix test run on ubuntu ci

* Update Droplet.tests.cpp
  • Loading branch information
MariaEmmerich authored Feb 13, 2025
1 parent 81728d0 commit c70ff70
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 2 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: 🍎 • CI

on:
push:
branches: [ 'main' ]
paths:
- '**/*.h'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- '.github/workflows/macos.yml'
pull_request:
branches: [ 'main' ]
paths:
- '**/*.h'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- '.github/workflows/macos.yml'
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
build_and_test:
strategy:
matrix:
os: [ macos-13, macos-14, macos-15 ]
compiler: [ g++-13, g++-14, clang++ ]
include:
- compiler: clang++
ccompiler: clang
- compiler: g++-13
ccompiler: gcc-13
- compiler: g++-14
ccompiler: gcc-14
exclude:
- os: macos-14
compiler: g++-13
- os: macos-14
compiler: g++-14
- os: macos-15
compiler: g++-13
- os: macos-15
compiler: g++-14

name: 🍎 ${{matrix.os}} with ${{matrix.compiler}}
runs-on: ${{matrix.os}}

steps:
- name: Clone Repository
uses: actions/checkout@v4
with:
submodules: recursive

# Remove existing 2to3 binary
- name: Remove existing 2to3 binary
run: sudo rm /usr/local/bin/2to3 || true

- if: matrix.os == 'macos-13'
name: Setup XCode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "^14.2"

- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: "${{matrix.os}}-${{matrix.compiler}}-Release"
variant: ccache
save: true
max-size: 10G

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build_release

- name: Configure CMake
working-directory: ${{github.workspace}}/build_release
run: >
cmake ${{github.workspace}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler}}
-DCMAKE_BUILD_TYPE=Release
- name: Build
working-directory: ${{github.workspace}}/build_release
run: cmake --build . --config Release -j4 # all macOS runners provide at least 3 cores

- name: Test
working-directory: ${{github.workspace}}/build_release
run: ./dropletTest
86 changes: 86 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: 🐧 • CI

on:
push:
branches: [ 'main' ]
paths:
- '**/*.h'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- '.github/workflows/ubuntu.yml'
pull_request:
branches: [ 'main' ]
paths:
- '**/*.h'
- '**/*.cpp'
- '**/*.cmake'
- '**/CMakeLists.txt'
- '.github/workflows/ubuntu.yml'
merge_group:

defaults:
run:
shell: bash

jobs:
build_and_test:
strategy:
matrix:
os: [ ubuntu-22.04, ubuntu-24.04 ]
compiler: [ g++-11, g++-12, g++-13, clang++-14, clang++-15, clang++-16 ]
exclude:
- os: ubuntu-22.04
compiler: g++-13
- os: ubuntu-22.04
compiler: clang++-16
- os: ubuntu-24.04
compiler: clang++-14
include:
- os: ubuntu-22.04
compiler: g++-10
- os: ubuntu-24.04
compiler: g++-14
- os: ubuntu-24.04
compiler: clang++-17
- os: ubuntu-24.04
compiler: clang++-18

name: 🐧 ${{matrix.os}} with ${{matrix.compiler}}
runs-on: ${{matrix.os}}

steps:
- name: Install libraries and the respective compiler
run: sudo apt-get update && sudo apt-get install -yq libtbb-dev ${{matrix.compiler}}

- name: Clone Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: "${{matrix.os}}-${{matrix.compiler}}-Release"
variant: ccache
save: true
max-size: 10G

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build_release

- name: Configure CMake
working-directory: ${{github.workspace}}/build_release
run: >
cmake ${{github.workspace}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler}}
-DCMAKE_BUILD_TYPE=Release
- name: Build
working-directory: ${{github.workspace}}/build_release
run: cmake --build . --config Release -j4

- name: Run Tests and Save Results
working-directory: ${{github.workspace}}/build_release
run: ./dropletTest
timeout-minutes: 10
1 change: 1 addition & 0 deletions src/architecture/Chip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <memory>
#include <unordered_map>
#include <stdexcept>

#include "FlowRatePump.h"
#include "PressurePump.h"
Expand Down
15 changes: 13 additions & 2 deletions tests/droplet/Droplet.tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ TEST(Droplet, RingNetworkE1) {
//--- API ---
droplet::Simulator sim;

std::cout << "Add Flow Rate Pump..." << std::endl;
// flowRate pump
auto flowRate = 3e-11;
auto pump = sim.addFlowRatePump(-1, 0, flowRate);
Expand Down Expand Up @@ -85,6 +86,8 @@ TEST(Droplet, RingNetworkE1) {
auto dLength3 = 42185e-6;
auto dLength4 = 41475e-6;

std::cout << "Add Channels..." << std::endl;

auto c1 = sim.addChannel(0, 1, cHeight, cWidth, iLength);
//Node 1
auto c2_n1 = sim.addChannel(1, 2, cHeight, cWidth, lIn1N1);
Expand Down Expand Up @@ -129,17 +132,23 @@ TEST(Droplet, RingNetworkE1) {
auto c6_n6 = sim.addChannel(64, -1, cHeight, cWidth, cLength);
auto c7_n6 = sim.addBypassChannel(62, 63, cHeight, bWidth, lByN6);

std::cout << "Add Sink and Ground..." << std::endl;

//--- sink ---
sim.addSink(-1);
//--- ground ---
sim.addGround(-1);

std::cout << "Add Fluid..." << std::endl;

// fluids
auto fluid0 = sim.addFluid(1e-3, 1e3, 0.0, 9e-10);
auto fluid0 = sim.addFluid(1e-3, 1e3, 1.0, 9e-10);
auto fluid1 = sim.addFluid(4e-3, 1e3, 1.0, 9e-10);
//--- continuousPhase ---
sim.setContinuousPhase(fluid0);

std::cout << "Add Droplet..." << std::endl;

// droplets
auto dropletVolume = lDroplet * cWidth * cHeight;
auto droplet0 = sim.addDroplet(fluid1, dropletVolume, 0.0, c1, 0.5);
Expand All @@ -150,9 +159,11 @@ TEST(Droplet, RingNetworkE1) {
auto droplet5 = sim.addDroplet(fluid1, dropletVolume, d_m5 * flowRate / cWidth * cHeight, c1, 0.5);
auto droplet6 = sim.addDroplet(fluid1, dropletVolume, d_m6 * flowRate / cWidth * cHeight, c1, 0.5);

std::cout << "Add Chip Validity..." << std::endl;
// check if chip is valid
sim.checkChipValidity();

std::cout << "Start Simulation..." << std::endl;
// simulate
droplet::SimulationResult result = sim.simulate();
//std::cout << result.toJson(4) << std::endl;
Expand Down Expand Up @@ -308,7 +319,7 @@ TEST(Droplet, RingNetworkE2) {
sim.addGround(-1);

// fluids
auto fluid0 = sim.addFluid(1e-3, 1e3, 0.0, 9e-10);
auto fluid0 = sim.addFluid(1e-3, 1e3, 1.0, 9e-10);
auto fluid1 = sim.addFluid(4e-3, 1e3, 1.0, 9e-10);
//--- continuousPhase ---
sim.setContinuousPhase(fluid0);
Expand Down

0 comments on commit c70ff70

Please sign in to comment.