From 02d288634df434afbdbab737cceb8797054d9781 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 15 Nov 2024 11:49:14 +0100 Subject: [PATCH 1/4] List one version in README.md The `core_version` is like the `version`, but no info on dirty or post-tag status. The julia_version can be looked up from the commit, and is generally not very relevant for users. --- build/build.jl | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/build/build.jl b/build/build.jl index 15eaf614a..4235f6892 100644 --- a/build/build.jl +++ b/build/build.jl @@ -82,15 +82,6 @@ function add_metadata(project_dir, license_file, output_dir, git_repo, readme) force = true, ) - # since the exact Ribasim version may be hard to find in the Manifest.toml file - # we can also extract that information, and add it to the README.md - manifest = TOML.parsefile(normpath(git_repo, "Manifest.toml")) - if !haskey(manifest, "manifest_format") - error("Manifest.toml is in the old format, run Pkg.upgrade_manifest()") - end - julia_version = manifest["julia_version"] - ribasim_entry = only(manifest["deps"]["Ribasim"]) - version = ribasim_entry["version"] repo = GitRepo(git_repo) branch = LibGit2.head(repo) commit = LibGit2.peel(LibGit2.GitCommit, branch) @@ -120,11 +111,9 @@ function add_metadata(project_dir, license_file, output_dir, git_repo, readme) This build uses the Ribasim version mentioned below. ```toml - release = "$tag" + version = "$tag" commit = "$url/$short_commit" branch = "$url/$short_name" - julia_version = "$julia_version" - core_version = "$version" ```""" println(io, version_info) end From 5f70c44fd7d9926b848650b9c658529047e517bf Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 15 Nov 2024 12:20:01 +0100 Subject: [PATCH 2/4] Looser `test_version` that works during the release process. --- build/tests/test_cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/tests/test_cli.py b/build/tests/test_cli.py index 06b1ce83f..e88c843a7 100644 --- a/build/tests/test_cli.py +++ b/build/tests/test_cli.py @@ -1,3 +1,4 @@ +import re import subprocess from pathlib import Path @@ -30,7 +31,10 @@ def test_version(): [executable, "--version"], check=True, capture_output=True, text=True ) - assert ribasim.__version__ in result.stdout + # ribasim --version is based on the git tag so can be different from + # ribasim.__version__ during development + version_pattern = r"ribasim \d{4,}\.\d{1,}\.\d{1,}" + assert re.match(version_pattern, result.stdout) def test_help(): From 5431c610057bb91479b91f74b5f336515352f730 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 15 Nov 2024 12:21:32 +0100 Subject: [PATCH 3/4] Simplify set_version --- build/build.jl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/build/build.jl b/build/build.jl index 4235f6892..8e43d0cae 100644 --- a/build/build.jl +++ b/build/build.jl @@ -39,16 +39,15 @@ Usage: `ribasim path/to/model/ribasim.toml` Documentation: https://ribasim.org/ """ -function set_version(filename, version; group = nothing) +"Use the git tag for `ribasim --version`, +so dev builds can be identified by -g" +function set_version(filename::String, tag::String)::Nothing data = TOML.parsefile(filename) - if !isnothing(group) - data[group]["version"] = version - else - data["version"] = version - end + data["package"]["version"] = tag open(filename, "w") do io TOML.print(io, data) end + return nothing end """ @@ -119,7 +118,7 @@ function add_metadata(project_dir, license_file, output_dir, git_repo, readme) end # Override the Cargo.toml file with the git version - set_version("cli/Cargo.toml", tag; group = "package") + set_version("cli/Cargo.toml", tag) end main() From 5a8ea9fe88f9c50326cd3b42b32f61156617d152 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Fri, 15 Nov 2024 13:31:47 +0100 Subject: [PATCH 4/4] SonarCloud to the rescue --- build/tests/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tests/test_cli.py b/build/tests/test_cli.py index e88c843a7..fd849e80f 100644 --- a/build/tests/test_cli.py +++ b/build/tests/test_cli.py @@ -33,7 +33,7 @@ def test_version(): # ribasim --version is based on the git tag so can be different from # ribasim.__version__ during development - version_pattern = r"ribasim \d{4,}\.\d{1,}\.\d{1,}" + version_pattern = r"ribasim \d{4,}\.\d+\.\d+" assert re.match(version_pattern, result.stdout)