Skip to content

Commit

Permalink
Fix test_version during release process and simplify versions in READ…
Browse files Browse the repository at this point in the history
…ME.md (#1938)

In the README.md we had version info like this:

```md
release = "$tag"
commit = "$url/$short_commit"
branch = "$url/$short_name"
julia_version = "$julia_version"
core_version = "$version"
```

This cuts it down to just this:

```md
version = "$tag"
commit = "$url/$short_commit"
branch = "$url/$short_name"
```

Where `tag` is of the form `2024.10.0-128-ge09eeb5` if it is after tag
v2024.10.0, otherwise just `2024.10.0`
The `test_version` just checks the form, because we bump the versions
before doing a git tag, so they can be off by one version temporarily. I
think that's simpler than introducing more difficult logic in
`set_version` to handle this.

Fixes #1655
  • Loading branch information
visr authored Nov 18, 2024
1 parent a407479 commit fe3b789
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
26 changes: 7 additions & 19 deletions build/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tag>-g<short-commit>"
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

"""
Expand Down Expand Up @@ -82,15 +81,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)
Expand Down Expand Up @@ -120,17 +110,15 @@ 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

# 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()
6 changes: 5 additions & 1 deletion build/tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import subprocess
from pathlib import Path

Expand Down Expand Up @@ -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+\.\d+"
assert re.match(version_pattern, result.stdout)


def test_help():
Expand Down

0 comments on commit fe3b789

Please sign in to comment.