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
2 changes: 1 addition & 1 deletion bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if [[ -z "$_version" ]]; then
exit 1
fi

_changelog_version=$(awk '/^## / {for (i = 1; i <= NF; i++) if ($i ~ /^v[0-9]/) {print $i; exit}}' CHANGELOG.md)
_changelog_version=$(awk '/^## / {for (i = 1; i <= NF; i++) if ($i ~ /^v[0-9]/) print $i; exit}' CHANGELOG.md)
if [[ "$_changelog_version" != "v$_version" ]]; then
echo "Version mismatch: Project.toml is $_version but CHANGELOG top is" \
"$_changelog_version (expected v$_version)." >&2
Expand Down
70 changes: 70 additions & 0 deletions test/bin/test_release.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Test

"""
dry_run_release(top_header, older_header) -> (exit_code, stderr_text)

Run `bin/release --dry-run` against a throwaway repository at version 5.0.0
whose `CHANGELOG.md` holds a section under each of the two headers, with a stub
`gh` on `PATH` so nothing reaches GitHub.
"""
function dry_run_release(top_header, older_header)
root = mktempdir()
repo = mkpath(joinpath(root, "repo"))
write(joinpath(repo, "Project.toml"), """
name = "Fixture"
version = "5.0.0"
""")
write(joinpath(repo, "CHANGELOG.md"), """
# Changelog

$top_header

### Added

- the newer note

$older_header

### Fixed

- the older note
""")
run(`git -C $repo init --quiet`)
run(`git -C $repo add --all`)
run(`git -C $repo -c user.email=fixture@example.com -c user.name=Fixture
commit --quiet -m "fixture"`)

stub = mkpath(joinpath(root, "stub"))
gh_stub = joinpath(stub, "gh")
write(gh_stub, """
#!/bin/bash
case "\$1" in
repo) echo "OpenSourceAWE/Fixture" ;;
esac
""")
chmod(gh_stub, 0o755)

script = normpath(joinpath(@__DIR__, "..", "..", "bin", "release"))
stderr_file = joinpath(root, "stderr.txt")
env = copy(ENV)
env["PATH"] = stub * ":" * ENV["PATH"]
command = setenv(`bash $script --dry-run`, env; dir=repo)
process = run(pipeline(ignorestatus(command); stdout=devnull, stderr=stderr_file))
return process.exitcode, read(stderr_file, String)
end

@testset "bin/release" begin
@testset "release refuses an unversioned top section above the last release" begin
exit_code, stderr_text =
dry_run_release("## Unreleased", "## Fixture v5.0.0 2026-09-07")
@test exit_code != 0
@test occursin("Version mismatch", stderr_text)
end

@testset "release accepts a top section naming the package version" begin
exit_code, stderr_text =
dry_run_release("## Fixture v5.0.0 2026-09-07", "## Fixture v4.3.1 2026-08-01")
@test exit_code == 0
@test isempty(stderr_text)
end
end
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ function include_selected_tests()
should_run_test("airfoil_aero/test_live_polar.jl") && include("airfoil_aero/test_live_polar.jl")
should_run_test("obj_adapter/test_obj_adapter.jl") && include("obj_adapter/test_obj_adapter.jl")
should_run_test("surfplan/test_surfplan.jl") && include("surfplan/test_surfplan.jl")
# bin/release is a bash script, so only the unix runners can run it.
Sys.isunix() && should_run_test("bin/test_release.jl") && include("bin/test_release.jl")
should_run_test("Aqua.jl") && include("Aqua.jl")
end

Expand Down
Loading