From f96d3f146964994c1f78a3d235d689fa073939b6 Mon Sep 17 00:00:00 2001
From: AnHeuermann <38031952+AnHeuermann@users.noreply.github.com>
Date: Mon, 9 Mar 2026 11:44:43 +0100
Subject: [PATCH] Log BaseModelica.jl SHA
Co-authored-by: Claude Sonnet 4.6
---
.github/workflows/CI.yml | 3 +-
.github/workflows/msl-test.yml | 1 -
Project.toml | 1 +
README.md | 2 -
src/BaseModelicaLibraryTesting.jl | 1 +
src/pipeline.jl | 67 +++++++++++++++++++++++++++++--
src/report.jl | 15 ++++---
src/summary.jl | 6 ++-
src/types.jl | 4 +-
9 files changed, 85 insertions(+), 15 deletions(-)
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index afc89c268..8a531b2e6 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -91,8 +91,7 @@ jobs:
main(
library = "Modelica",
version = "4.1.0",
- filter = "Modelica.Electrical.Analog.Examples.ChuaCircuit",
- results_root = "results/main/Modelica/4.1.0/"
+ filter = "Modelica.Electrical.Analog.Examples.ChuaCircuit"
)
'
diff --git a/.github/workflows/msl-test.yml b/.github/workflows/msl-test.yml
index 743e2fa91..9c161bb3b 100644
--- a/.github/workflows/msl-test.yml
+++ b/.github/workflows/msl-test.yml
@@ -120,7 +120,6 @@ jobs:
main(
library = ENV["LIB_NAME"],
version = ENV["LIB_VERSION"],
- results_root = "results/$(ENV["BM_VERSION"])/$(ENV["LIB_NAME"])/$(ENV["LIB_VERSION"])",
ref_root = "MAP-LIB_ReferenceResults",
)
'
diff --git a/Project.toml b/Project.toml
index 04752939a..4ce34f552 100644
--- a/Project.toml
+++ b/Project.toml
@@ -9,6 +9,7 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
OMJulia = "0f4fe800-344e-11e9-2949-fb537ad918e1"
+Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ZMQ = "c2297ded-f4af-51ae-bb23-16f91089e4e1"
diff --git a/README.md b/README.md
index ad7513686..6468562b1 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,6 @@ main(
version = "",
filter = "",
omc_exe = "path/to/omc",
- results_root = "results",
ref_root = "path/to/ReferenceResults"
)
```
@@ -50,7 +49,6 @@ main(
version = "4.1.0",
filter = "Modelica.Electrical.Analog.Examples.ChuaCircuit",
omc_exe = "omc",
- results_root = "results/main/Modelica/4.1.0/",
ref_root = "MAP-LIB_ReferenceResults"
)
```
diff --git a/src/BaseModelicaLibraryTesting.jl b/src/BaseModelicaLibraryTesting.jl
index 840fb5c9a..7610640fa 100644
--- a/src/BaseModelicaLibraryTesting.jl
+++ b/src/BaseModelicaLibraryTesting.jl
@@ -1,5 +1,6 @@
module BaseModelicaLibraryTesting
+import Pkg
import OMJulia
import OMJulia: sendExpression
import BaseModelica
diff --git a/src/pipeline.jl b/src/pipeline.jl
index 47b36377d..4bb7f9112 100644
--- a/src/pipeline.jl
+++ b/src/pipeline.jl
@@ -1,3 +1,56 @@
+# ── BaseModelica.jl version helpers ────────────────────────────────────────────
+
+"""
+ _bm_sha() → String
+
+Return the first 7 characters of the git commit SHA for the installed
+BaseModelica.jl package by resolving the package's tree SHA against the
+cached git clone in the Julia depot. Falls back to the tree SHA when the
+clone cannot be found, and returns `""` for registry installs (no git
+metadata available) or when the SHA cannot be determined.
+"""
+function _bm_sha()::String
+ try
+ for (_, info) in Pkg.dependencies()
+ info.name == "BaseModelica" || continue
+ tree_sha = info.tree_hash
+ tree_sha === nothing && return ""
+
+ # Resolve the tree SHA to a commit SHA via the cached git clone.
+ git_source = info.git_source
+ if git_source !== nothing
+ for depot in Base.DEPOT_PATH
+ clones_dir = joinpath(depot, "clones")
+ @show clones_dir
+ isdir(clones_dir) || continue
+ for clone in readdir(clones_dir; join=true)
+ isdir(clone) || continue
+ try
+ remote = strip(readchomp(`git -C $clone remote get-url origin`))
+ (remote == git_source || remote * ".git" == git_source ||
+ git_source * ".git" == remote) || continue
+ fmt = "%H %T"
+ log = readchomp(`git -C $clone log --all --format=$fmt`)
+ for line in split(log, '\n')
+ parts = split(strip(line))
+ length(parts) == 2 && parts[2] == tree_sha || continue
+ sha = parts[1]
+ return sha[1:min(7, length(sha))]
+ end
+ catch
+ end
+ end
+ end
+ end
+
+ # Fall back to the tree SHA when no clone is found.
+ return tree_sha[1:min(7, length(tree_sha))]
+ end
+ catch
+ end
+ return ""
+end
+
# ── Per-model orchestrator ─────────────────────────────────────────────────────
"""
@@ -69,8 +122,17 @@ function main(;
)
t0 = time()
+ # Set up working directory
+ bm_version = get(ENV, "BM_VERSION", string(pkgversion(BaseModelica)))
+ bm_sha = _bm_sha()
+ @info "Testing BaseModelica.jl version $(bm_version) ($(bm_sha))"
+
if isempty(results_root)
- results_root = joinpath(library, version)
+ if bm_version == "main"
+ results_root = joinpath("results", bm_sha, library, version)
+ else
+ results_root = joinpath("results", bm_version, library, version)
+ end
end
results_root = abspath(results_root)
mkpath(joinpath(results_root, "files"))
@@ -142,8 +204,6 @@ function main(;
end
cpu_info = Sys.cpu_info()
- bm_ver_env = get(ENV, "BM_VERSION", "")
- bm_version = isempty(bm_ver_env) ? string(pkgversion(BaseModelica)) : bm_ver_env
info = RunInfo(
library,
version,
@@ -154,6 +214,7 @@ function main(;
ref_root,
omc_version,
bm_version,
+ bm_sha,
isempty(cpu_info) ? "unknown" : strip(cpu_info[1].model),
length(cpu_info),
Sys.total_memory() / 1024^3,
diff --git a/src/report.jl b/src/report.jl
index 55777cc09..06e1df7d6 100644
--- a/src/report.jl
+++ b/src/report.jl
@@ -78,10 +78,13 @@ function generate_report(results::Vector{ModelResult}, results_root::String,
$(_cmp_cell(r, results_root))
""" for r in results], "\n")
- filter_row = isempty(info.filter) ? "" : "
Filter: $(info.filter)"
- ref_row = isempty(info.ref_root) ? "" : "
Reference results: $(info.ref_root)"
- ram_str = @sprintf("%.1f", info.ram_gb)
- time_str = _format_duration(info.total_time_s)
+ bm_sha_link = isempty(info.bm_sha) ? "" :
+ """ ($(info.bm_sha))"""
+ basemodelica_jl_version = info.bm_version * bm_sha_link
+ var_filter = isempty(info.filter) ? "None" : "$(info.filter)"
+ ref_results = isempty(info.ref_root) ? "None" : "$(info.ref_root)"
+ ram_str = @sprintf("%.1f", info.ram_gb)
+ time_str = _format_duration(info.total_time_s)
html = """
@@ -106,7 +109,9 @@ function generate_report(results::Vector{ModelResult}, results_root::String,
Generated: $(now())
OpenModelica: $(info.omc_version)
OMC options: $(info.omc_options)
-BaseModelica.jl: $(info.bm_version)$(filter_row)$(ref_row)
+BaseModelica.jl: $(basemodelica_jl_version)
+Filter: $(var_filter)
+Reference results: $(ref_results)
CPU: $(info.cpu_model) ($(info.cpu_threads) threads)
RAM: $(ram_str) GiB
Total run time: $(time_str)
diff --git a/src/summary.jl b/src/summary.jl
index 810bfeabe..53ba785ef 100644
--- a/src/summary.jl
+++ b/src/summary.jl
@@ -28,6 +28,7 @@ function write_summary(
print(io, " \"ref_root\": \"$(_esc_json(info.ref_root))\",\n")
print(io, " \"omc_version\": \"$(_esc_json(info.omc_version))\",\n")
print(io, " \"bm_version\": \"$(_esc_json(info.bm_version))\",\n")
+ print(io, " \"bm_sha\": \"$(_esc_json(info.bm_sha))\",\n")
print(io, " \"cpu_model\": \"$(_esc_json(info.cpu_model))\",\n")
print(io, " \"cpu_threads\": $(info.cpu_threads),\n")
print(io, " \"ram_gb\": $(@sprintf "%.2f" info.ram_gb),\n")
@@ -67,7 +68,8 @@ Parsed contents of a single `summary.json` file.
- `results_root` — absolute path where results were written
- `ref_root` — absolute path to reference results, or `""` when unused
- `omc_version` — OMC version string
-- `bm_version` — BaseModelica.jl version string (e.g. `"1.6.0"`)
+- `bm_version` — BaseModelica.jl version string (e.g. `"1.6.0"` or `"main"`)
+- `bm_sha` — git tree-SHA of the installed BaseModelica.jl, or `""`
- `cpu_model` — CPU model name
- `cpu_threads` — number of logical CPU threads
- `ram_gb` — total system RAM in GiB
@@ -85,6 +87,7 @@ struct RunSummary
ref_root :: String
omc_version :: String
bm_version :: String
+ bm_sha :: String
cpu_model :: String
cpu_threads :: Int
ram_gb :: Float64
@@ -142,6 +145,7 @@ function load_summary(results_root::String)::Union{RunSummary,Nothing}
_str("ref_root"),
_str("omc_version"),
_str("bm_version"),
+ _str("bm_sha"),
_str("cpu_model"),
_int("cpu_threads"),
_float("ram_gb"),
diff --git a/src/types.jl b/src/types.jl
index e11cdb0d7..e68eab3d0 100644
--- a/src/types.jl
+++ b/src/types.jl
@@ -50,7 +50,8 @@ Metadata about a single test run, collected by `main()` and written into both
- `results_root` — absolute path where results are written
- `ref_root` — absolute path to reference results, or `""` when unused
- `omc_version` — version string returned by `getVersion()`, e.g. `"v1.23.0"`
-- `bm_version` — BaseModelica.jl version string, e.g. `"1.6.0"`
+- `bm_version` — BaseModelica.jl version string, e.g. `"1.6.0"` or `"main"`
+- `bm_sha` — git tree-SHA of the installed BaseModelica.jl (first 7 chars), or `""`
- `cpu_model` — CPU model name from `Sys.cpu_info()`
- `cpu_threads` — number of logical CPU threads
- `ram_gb` — total system RAM in GiB
@@ -66,6 +67,7 @@ struct RunInfo
ref_root :: String # "" when no reference root was given
omc_version :: String
bm_version :: String
+ bm_sha :: String # git tree-SHA (short), "" for registry installs
cpu_model :: String
cpu_threads :: Int
ram_gb :: Float64