Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_version during release process and simplify versions in README.md #1938

Merged
merged 4 commits into from
Nov 18, 2024
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
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