Skip to content

Add GitHub Actions CI (OpenModelica tests, mofmt formatting) and fix failing examples - #3

Merged
pascal2802 merged 19 commits into
masterfrom
pipeline
Sep 29, 2026
Merged

pascal2802 merged 19 commits into
masterfrom
pipeline

Conversation

@bmazurie

Copy link
Copy Markdown
Member

Summary

This PR adds two GitHub Actions workflows: automatic OpenModelica tests compared with master, and automatic formatting of the Modelica code with mofmt. It also fixes the 3 models that failed with OpenModelica. On the branch, 22/22 tested models simulate, against 19/22 on master.

CI: OpenModelica tests (.github/workflows/openmodelica-tests.yml)

  • What is tested: the non-partial models of the Examples and Tests packages (22 models). They are run with ModelicaTests in the openmodelica/openmodelica:v1.26.7-ompython image, with MSL 3.2.3.
  • Comparison with a reference version: the same models are run on the reference and compared with the branch.
    • Reference for a pull request: the target branch.
    • Reference for a push to master: the previous commit.
    • Configurations: .test/config_new_openmodelica.json (tested version) and .test/config_ref_openmodelica.json (reference, checked out in ref/TAeZoSysPro).
  • Report: .test/report.py writes the run summary.
    • The results table of the ModelicaTests HTML report for the tested version.
    • For each model, its status on both versions (✅ fixed, ❌ regression, ⚠️ still failing).
    • For models simulated in both, the relative differences of the final values of all variables, computed as in ModelicaTests. The 10 largest are listed for each changed model.
  • Artifacts, kept 7 days: the ModelicaTests CSV/HTML reports and the OpenModelica check, build and simulation logs of each model.
  • Failure policy: a failing model does not fail the workflow; it is only reported. The workflow fails on infrastructure errors only.
  • Triggers: push to master, pull requests to master, manual run.

Required setting: ModelicaTests is private. Add a repository secret MODELICATESTS_TOKEN, a GitLab token with read_repository access to ModelicaTests. For the same reason, pull requests from forks, including this one, cannot access the secret: the test job is skipped instead of failing. The results of this branch can be seen in the fork's runs: https://github.com/bmazurie/TAeZoSysPro/actions

CI: mofmt formatting (.github/workflows/mofmt.yml)

  • On pull requests from a branch of this repository, mofmt 0.6.0 formats the .mo files and github-actions[bot] pushes a style: format Modelica code with mofmt commit to the branch.
  • On pull requests from forks and pushes to master, nothing is pushed; the job fails if some files are not formatted.
  • A UTF-8 BOM, which makes mofmt panic, is stripped before formatting.

Library changes

  • Whole library reformatted with mofmt, in the bot commits f80a1f5, 665251e and 70983cd. This touches 170 .mo files, without semantic change: the test results of all unchanged models are identical. To review the rest, look at the other commits one by one.
  • UTF-8 BOM removed from 4 files (MoistAir.mo, GasNode_two_phases.mo, Conduction.mo, FanVentilation.mo).
  • FluidDynamics.Examples.Pressure_coocker:
    • SimpleOpening, removed in 53fb7ef, is replaced by Opening.
    • MoistAir is redeclared: GasNode_two_phases needs a condensable medium, and the default medium MyMedia has been SimpleAir since da9e7c9.
  • PDE.Examples.DiffusionGaussian and PDE.Examples.BoundaryStepDiffusion: add the missing ; after the last equation. The experiment annotation was attached to that equation and ignored. As a result, DiffusionGaussian started at t = 0 and divided by zero, and BoundaryStepDiffusion stopped at 1 s instead of 300 s.
  • HeatTransfer.Functions.ExchangerEffectiveness.Tests.test_counterCurrent: the Cr ramp now stops at 0.99. counterCurrent evaluates its general formula, which is 0/0 at Cr = 1, even where regStep only uses the Cr = 1 limit.

Test results (branch vs master)

master branch
Models simulated 19/22 22/22
  • Fixed: Pressure_coocker, test_counterCurrent, DiffusionGaussian.
  • Results changed: BoundaryStepDiffusion, which now runs until 300 s.
  • The 18 other models are unchanged: final values are identical within a relative tolerance of 1e-4.

Known limitations and follow-ups

  • The formatting commit pushed by the bot does not trigger the tests again (GitHub does not run workflows on commits pushed with GITHUB_TOKEN).
  • counterCurrent still divides by zero at Cr = 1. Components that use it (HeatExchanger, AnalyticExchanger, DiscreteExchanger) would fail if both heat capacity rates became equal. Not changed here.
  • Inverse.NTU_coCurrent has an inverse annotation pointing to counterCurrent instead of coCurrent, probably a copy-paste error. Not changed here.
  • ModelicaTests issues to report upstream:
    • Its git url feature clones into REPO_<lib>_<n>, which fails when package.mo is at the repository root, as here.
    • compare_res crashes when a result file has no variable.
    • The comparison CSV is written without model names.
  • A .git-blame-ignore-revs file listing the mofmt commits could be added, so that git blame skips the reformatting.

bmazurie and others added 15 commits September 29, 2026 10:43
- Pressure_coocker: replace the removed SimpleOpening with Opening and
  redeclare MoistAir, required by the two-phase gas node since the default
  medium MyMedia became SimpleAir
- DiffusionGaussian, BoundaryStepDiffusion: add the missing semicolon that
  attached the experiment annotation to the last equation, so it was
  ignored (DiffusionGaussian started at t = 0 and divided by zero,
  BoundaryStepDiffusion stopped at 1 s instead of 300 s)
- test_counterCurrent: stop the Cr ramp at 0.99, as counterCurrent
  evaluates its general formula even where only the Cr = 1 limit is used
  (0/0 at Cr = 1)
- CI: upload the OpenModelica logs of each model, and report JUnit results
  as job annotations instead of a separate check run that GitHub attached
  to the mofmt workflow and marked as failed
- Run ModelicaTests on the branch (config_new.json) and on a reference
  version checked out in ref/TAeZoSysPro (config_ref.json): the target
  branch for pull requests, the previous commit for pushes to master
- Add .test/compare_results.py, which writes to the run summary the status
  of each model on both versions and the changes (fixed, regression,
  results changed on final values)
- Save all variables (vars_filter ".*"): ModelicaTests' comparison fails
  on result files without variables, and function tests had none
- Report only the branch results in the JUnit annotations
- Rename .test/compare_results.py to .test/report.py, which now writes to
  the run summary the results table of the ModelicaTests HTML report for
  the tested configuration, followed by the comparison with the reference
- Compute relative differences with ModelicaTests' compute_relative_diff,
  and list the 10 largest ones for each model whose results changed, as in
  the ModelicaTests HTML comparison
- Remove the JUnit report step
…aster

- config_new_openmodelica.json: the library is now in src/TAeZoSysPro
- config_ref_openmodelica.json: let ModelicaTests clone master of
  EDF-Lab/TAeZoSysPro (package_path src/TAeZoSysPro/package.mo), as for
  ThermoSysPro, instead of checking it out in the workflow
- If the reference cannot be tested (master still has the library at the
  repository root until this layout is merged), test the checked out
  version alone and report the comparison as not available
Copy of the Modelica package of taezosyspro_testsuite (commit 01db269,
https://gitlab.pam-retd.fr/TAeZoSysPro/taezosyspro_testsuite), without its
Scripts folder. Files are UTF-8 without BOM, without non-ASCII characters.
@bmazurie bmazurie closed this Sep 29, 2026
@bmazurie
bmazurie deleted the pipeline branch September 29, 2026 13:31
@bmazurie bmazurie reopened this Sep 29, 2026
bmazurie and others added 3 commits September 29, 2026 16:02
- test_Condensation, test_MolecularDiffusion, test_GasNode_two_phases,
  test_Interface_liq_gas, test_ForcedConvection: redeclare MoistAir, as in
  Pressure_coocker. The default medium MyMedia (SimpleAir) has no water, no
  saturationPressure and no density in its thermodynamic state.
- test_CommissioningDamper: dp_nominal was removed from CommissioningDamper
  (ed9fd47), which now computes Kv at initialization from m_flow_nominal
  when m_flow is fixed: set m_flow(fixed = true)
- Add TAeZoSysPro_testsuite to config_new_openmodelica.json and
  config_ref_openmodelica.json (cloned from master of EDF-Lab/TAeZoSysPro)
- Select all its models except the ones defined inside a test model
  (e.g. test_Interface_liq_gas.LiquidNode_simulated), so that tests not
  named test_* such as h_rad are kept
@bmazurie bmazurie self-assigned this Sep 29, 2026
@bmazurie
bmazurie requested a review from pascal2802 September 29, 2026 14:13
@pascal2802

Copy link
Copy Markdown
Collaborator

ok

@pascal2802
pascal2802 merged commit 6e908d9 into master Sep 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants