From f34b6b0986fbaab0be32ed57ef2de57e56588630 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:15:41 +0200 Subject: [PATCH] thread `new_package_waiting_period` through to AutoMerge comment (#552) * add reference test for AutoMerge comment * up * fix test on old Julia versions * refactor comment * thread `new_package_waiting_period` through to AutoMerge comment * rm type annotation * try to make old Julia's happy * fix? * Update src/AutoMerge/pull_requests.jl * Apply suggestions from code review * add kwarg --- src/AutoMerge/public.jl | 1 + src/AutoMerge/pull_requests.jl | 8 +++++--- src/AutoMerge/util.jl | 6 +++--- test/automerge-unit.jl | 6 +++++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/AutoMerge/public.jl b/src/AutoMerge/public.jl index 2bf9fab3..f759fe27 100644 --- a/src/AutoMerge/public.jl +++ b/src/AutoMerge/public.jl @@ -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) diff --git a/src/AutoMerge/pull_requests.jl b/src/AutoMerge/pull_requests.jl index 72570f29..4f2188f5 100644 --- a/src/AutoMerge/pull_requests.jl +++ b/src/AutoMerge/pull_requests.jl @@ -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) @@ -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( @@ -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 diff --git a/src/AutoMerge/util.jl b/src/AutoMerge/util.jl index 9286843a..550e38f3 100644 --- a/src/AutoMerge/util.jl +++ b/src/AutoMerge/util.jl @@ -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" @@ -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 @@ -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), "", diff --git a/test/automerge-unit.jl b/test/automerge-unit.jl index eafa4e1d..95a6e020 100644 --- a/test/automerge-unit.jl +++ b/test/automerge-unit.jl @@ -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) @@ -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")