Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
'

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/msl-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
'
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ main(
version = "<Modelica library version>",
filter = "<Modelica class filter>",
omc_exe = "path/to/omc",
results_root = "results",
ref_root = "path/to/ReferenceResults"
)
```
Expand All @@ -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"
)
```
Expand Down
1 change: 1 addition & 0 deletions src/BaseModelicaLibraryTesting.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module BaseModelicaLibraryTesting

import Pkg
import OMJulia
import OMJulia: sendExpression
import BaseModelica
Expand Down
67 changes: 64 additions & 3 deletions src/pipeline.jl
Original file line number Diff line number Diff line change
@@ -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 ─────────────────────────────────────────────────────

"""
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
15 changes: 10 additions & 5 deletions src/report.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ function generate_report(results::Vector{ModelResult}, results_root::String,
$(_cmp_cell(r, results_root))
</tr>""" for r in results], "\n")

filter_row = isempty(info.filter) ? "" : "<br>Filter: $(info.filter)"
ref_row = isempty(info.ref_root) ? "" : "<br>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) ? "" :
""" (<a href="https://github.com/SciML/BaseModelica.jl/commit/$(info.bm_sha)">$(info.bm_sha)</a>)"""
basemodelica_jl_version = info.bm_version * bm_sha_link
var_filter = isempty(info.filter) ? "None" : "<code>$(info.filter)</code>"
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 = """<!DOCTYPE html>
<html lang="en">
Expand All @@ -106,7 +109,9 @@ function generate_report(results::Vector{ModelResult}, results_root::String,
<p>Generated: $(now())<br>
OpenModelica: $(info.omc_version)<br>
OMC options: <code>$(info.omc_options)</code><br>
BaseModelica.jl: $(info.bm_version)$(filter_row)$(ref_row)</p>
BaseModelica.jl: $(basemodelica_jl_version)<br>
Filter: $(var_filter)<br>
Reference results: $(ref_results)</p>
<p>CPU: $(info.cpu_model) ($(info.cpu_threads) threads)<br>
RAM: $(ram_str) GiB<br>
Total run time: $(time_str)</p>
Expand Down
6 changes: 5 additions & 1 deletion src/summary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"),
Expand Down
4 changes: 3 additions & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down