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

thread new_package_waiting_period through to AutoMerge comment #552

Merged
merged 13 commits into from
Jun 12, 2024
1 change: 1 addition & 0 deletions src/AutoMerge/public.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ function run(;
public_registries=public_registries,
read_only=read_only,
environment_variables_to_pass=environment_variables_to_pass,
new_package_waiting_period=new_package_waiting_period,
)
else
always_assert(run_merge_build)
Expand Down
8 changes: 5 additions & 3 deletions src/AutoMerge/pull_requests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function pull_request_build(
public_registries::Vector{<:AbstractString}=String[],
read_only::Bool,
environment_variables_to_pass::Vector{<:AbstractString}=String[],
new_package_waiting_period=new_package_waiting_period,
)::Nothing
pr = my_retry(() -> GitHub.pull_request(api, registry, pr_number; auth=auth))
_github_api_pr_head_commit_sha = pull_request_head_sha(pr)
Expand Down Expand Up @@ -165,12 +166,12 @@ function pull_request_build(
read_only=read_only,
environment_variables_to_pass=environment_variables_to_pass,
)
pull_request_build(data; check_license=check_license)
pull_request_build(data; check_license=check_license, new_package_waiting_period=new_package_waiting_period)
rm(registry_master; force=true, recursive=true)
return nothing
end

function pull_request_build(data::GitHubAutoMergeData; check_license)::Nothing
function pull_request_build(data::GitHubAutoMergeData; check_license, new_package_waiting_period)::Nothing
kind = package_or_version(data.registration_type)
this_is_jll_package = is_jll_name(data.pkg)
@info(
Expand Down Expand Up @@ -231,7 +232,8 @@ function pull_request_build(data::GitHubAutoMergeData; check_license)::Nothing
data.registration_type,
data.suggest_onepointzero,
data.version,
this_pr_can_use_special_jll_exceptions,
this_pr_can_use_special_jll_exceptions;
new_package_waiting_period=new_package_waiting_period
)
my_retry(() -> update_automerge_comment!(data, this_pr_comment_pass))
else # failure
Expand Down
6 changes: 3 additions & 3 deletions src/AutoMerge/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function _comment_noblock(n)
end

function comment_text_pass(
::NewVersion, suggest_onepointzero::Bool, version::VersionNumber, is_jll::Bool
::NewVersion, suggest_onepointzero::Bool, version::VersionNumber, is_jll::Bool; new_package_waiting_period
)
# Need to know this ahead of time to get the section numbers right
suggest_onepointzero &= version < v"1.0.0"
Expand All @@ -171,7 +171,7 @@ function comment_text_pass(
end

function comment_text_pass(
::NewPackage, suggest_onepointzero::Bool, version::VersionNumber, is_jll::Bool
::NewPackage, suggest_onepointzero::Bool, version::VersionNumber, is_jll::Bool; new_package_waiting_period
)
suggest_onepointzero &= version < v"1.0.0"
if is_jll
Expand All @@ -192,7 +192,7 @@ function comment_text_pass(
_automerge_guidelines_passed_section_title(3),
"Your new package registration met all of the ",
"guidelines for auto-merging and is scheduled to ",
"be merged when the mandatory waiting period (3 days) has elapsed.\n\n",
"be merged when the mandatory waiting period ($new_package_waiting_period) has elapsed.\n\n",
_onepointzero_suggestion(4, suggest_onepointzero, version),
_comment_noblock(suggest_onepointzero ? 5 : 4),
"<!-- [noblock] -->",
Expand Down
6 changes: 5 additions & 1 deletion test/automerge-unit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function comment_reference_test()
name = string("comment", "_pass_", pass, "_type_", type_name,
"_suggest_onepointzero_", suggest_onepointzero,
"_version_", version, "_is_jll_", is_jll)
@test_reference "reference_comments/$name.md" AutoMerge.comment_text_pass(type, suggest_onepointzero, version, is_jll) by=strip_equal
@test_reference "reference_comments/$name.md" AutoMerge.comment_text_pass(type, suggest_onepointzero, version, is_jll, new_package_waiting_period=Day(3)) by=strip_equal
end
else
for point_to_slack in (true, false)
Expand All @@ -86,6 +86,10 @@ end
@testset "comment_reference_test" begin
comment_reference_test()
end
@testset "Customized `new_package_waiting_period` in AutoMerge comment " begin
text = AutoMerge.comment_text_pass(AutoMerge.NewPackage(), false, v"1", false; new_package_waiting_period=Minute(45))
@test occursin("(45 minutes)", text)
end
@testset "`AutoMerge.parse_registry_pkg_info`" begin
registry_path = joinpath(DEPOT_PATH[1], "registries", "General")
result = AutoMerge.parse_registry_pkg_info(registry_path, "RegistryCI", "1.0.0")
Expand Down
Loading