From a708d47c26a39a75207fdd5709b7ab21569845c9 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Fri, 2 Oct 2026 15:19:44 +0200 Subject: [PATCH 1/2] Test MATLAB-based tutorials --- .github/workflows/test-matlab.yml | 75 +++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/test-matlab.yml diff --git a/.github/workflows/test-matlab.yml b/.github/workflows/test-matlab.yml new file mode 100644 index 000000000..07eb0d71b --- /dev/null +++ b/.github/workflows/test-matlab.yml @@ -0,0 +1,75 @@ +name: 'Test MATLAB-based tutorials' + +on: + schedule: + - cron: "0 3 * * WED" + timezone: "Europe/Berlin" + workflow_dispatch: + push: + paths: + - '**/*matlab/**' + +jobs: + test-matlab: + name: Test MATLAB-based tutorials + runs-on: ubuntu-latest + container: + image: precice/precice:nightly + strategy: + fail-fast: true + steps: + - name: Checkout the tutorials repository + uses: actions/checkout@v7 + - name: Install Dependencies + run: | + apt-get -qq update + apt-get -qq install wget + rm -rf /var/lib/apt/lists/* + - name: Set up MATLAB + uses: matlab-actions/setup-matlab@v3 + with: + release: R2024a + - name: Get the matlab-bindings repository + run: | + git clone --depth=1 https://github.com/precice/matlab-bindings.git + cd matlab-bindings && git status + - name: Run compilation script + uses: matlab-actions/run-command@v3 + with: + command: "addpath('matlab-bindings'), compile_matlab_bindings_for_precice" + - name: Get run-matlab-command + run: | + wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command + chmod +x /usr/local/bin/run-matlab-command + - name: Run solver dummies + working-directory: matlab-bindings/examples/solverdummy + env: + LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5 + run: | + run-matlab-command "addpath('../..'), solverdummy precice-config.xml SolverOne" & run-matlab-command "addpath('../..'), solverdummy precice-config.xml SolverTwo" + - name: Run resonant-circuit + working-directory: resonant-circuit + env: + LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5 + run: | + sed -i 's%% %g' precice-config.xml && + cd capacitor-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), capacitor;exit" & + cd coil-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), coil;exit" + - name: Archive logs + if: ${{ always() }} + uses: actions/upload-artifact@v7 + with: + name: test-matlab-logs + path: | + resonant-circuit/*.log + resonant-circuit/*/*.log + resonant-circuit/capacitor-matlab/Curves.png + if-no-files-found: warn + - name: Archive exports + if: ${{ always() }} + uses: actions/upload-artifact@v7 + with: + name: test-matlab-exports + path: | + resonant-circuit/precice-exports/* + if-no-files-found: warn \ No newline at end of file From cd623b0cfdef3c0cd5f815487eaa6214fb56103f Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Fri, 2 Oct 2026 17:52:39 +0200 Subject: [PATCH 2/2] Add an error check in capacitor.m --- .github/workflows/test-matlab.yml | 10 ++-------- changelog-entries/942.md | 1 + resonant-circuit/capacitor-matlab/capacitor.m | 7 +++++++ resonant-circuit/capacitor-matlab/run.sh | 6 ++++++ resonant-circuit/coil-matlab/run.sh | 6 ++++++ 5 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 changelog-entries/942.md diff --git a/.github/workflows/test-matlab.yml b/.github/workflows/test-matlab.yml index 07eb0d71b..49efb0ec4 100644 --- a/.github/workflows/test-matlab.yml +++ b/.github/workflows/test-matlab.yml @@ -41,20 +41,14 @@ jobs: run: | wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command chmod +x /usr/local/bin/run-matlab-command - - name: Run solver dummies - working-directory: matlab-bindings/examples/solverdummy - env: - LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5 - run: | - run-matlab-command "addpath('../..'), solverdummy precice-config.xml SolverOne" & run-matlab-command "addpath('../..'), solverdummy precice-config.xml SolverTwo" - name: Run resonant-circuit working-directory: resonant-circuit env: LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5 run: | sed -i 's%% %g' precice-config.xml && - cd capacitor-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), capacitor;exit" & - cd coil-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), coil;exit" + cd coil-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), coil" & + cd capacitor-matlab/ && run-matlab-command "addpath('../../matlab-bindings'), capacitor" - name: Archive logs if: ${{ always() }} uses: actions/upload-artifact@v7 diff --git a/changelog-entries/942.md b/changelog-entries/942.md new file mode 100644 index 000000000..6af7c23d8 --- /dev/null +++ b/changelog-entries/942.md @@ -0,0 +1 @@ +- Added a CI workflow to test MATLAB-based tutorials [#942](https://github.com/precice/tutorials/pull/942) \ No newline at end of file diff --git a/resonant-circuit/capacitor-matlab/capacitor.m b/resonant-circuit/capacitor-matlab/capacitor.m index e56f93bf3..e513b8545 100644 --- a/resonant-circuit/capacitor-matlab/capacitor.m +++ b/resonant-circuit/capacitor-matlab/capacitor.m @@ -104,3 +104,10 @@ save('outputs.mat', 'I', 'U') saveas(gcf, 'Curves.png') + +% Error thresholds based on a reference run +if error_I > 0.47 || error_U > 0.12 + error("Voltage or current differs more than expected from the analytical solution."); + quit(1) +end + diff --git a/resonant-circuit/capacitor-matlab/run.sh b/resonant-circuit/capacitor-matlab/run.sh index 906b25220..c69894470 100755 --- a/resonant-circuit/capacitor-matlab/run.sh +++ b/resonant-circuit/capacitor-matlab/run.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash +set -e -u + +. ../../tools/log.sh +exec > >(tee --append "$LOGFILE") 2>&1 # Run MATLAB code without GUI matlab -nodisplay -r "capacitor;exit;" + +close_log \ No newline at end of file diff --git a/resonant-circuit/coil-matlab/run.sh b/resonant-circuit/coil-matlab/run.sh index 085ae73f2..c189e82ee 100755 --- a/resonant-circuit/coil-matlab/run.sh +++ b/resonant-circuit/coil-matlab/run.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash +set -e -u + +. ../../tools/log.sh +exec > >(tee --append "$LOGFILE") 2>&1 # Run MATLAB code without GUI matlab -nodisplay -r "coil;exit;" + +close_log \ No newline at end of file