From 487e6bfa248df4721f9bc441af0ebd3057ac7b8b Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 9 Dec 2023 01:46:32 +0100 Subject: [PATCH 01/13] respect `Override AutoMerge: name similarity is okay` labels --- src/AutoMerge/guidelines.jl | 22 +++++++++++++++++++++- src/AutoMerge/pull_requests.jl | 1 + test/automerge-unit.jl | 12 +++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/AutoMerge/guidelines.jl b/src/AutoMerge/guidelines.jl index eda343bb..9a673531 100644 --- a/src/AutoMerge/guidelines.jl +++ b/src/AutoMerge/guidelines.jl @@ -373,6 +373,24 @@ function meets_distance_check( return (false, message) end +# Used in `pull_request_build` to determine if we should +# perform the distance check or not. +# We expect to be passed the `labels` field of a PullRequest: +# +function perform_distance_check(labels) + # No labels? Do the check + isnothing(labels) && return true + for label in labels + if label.name === "Override AutoMerge: name similarity is okay" + # found the override! Skip the check + @debug "Found label; skipping distance check" label.name + return false + end + end + # Did not find the override. Perform the check. + return true +end + const guideline_normal_capitalization = Guideline(; info="Normal capitalization", docs=string( @@ -956,6 +974,7 @@ function get_automerge_guidelines( check_license::Bool, this_is_jll_package::Bool, this_pr_can_use_special_jll_exceptions::Bool, + use_distance_check::Bool ) guidelines = [ (guideline_registry_consistency_tests_pass, true), @@ -987,7 +1006,7 @@ function get_automerge_guidelines( # prints the list of similar package names in # the automerge comment. To make the comment easy # to read, we want this list to be at the end. - (guideline_distance_check, true), + (guideline_distance_check, use_distance_check), ] return guidelines end @@ -997,6 +1016,7 @@ function get_automerge_guidelines( check_license::Bool, this_is_jll_package::Bool, this_pr_can_use_special_jll_exceptions::Bool, + use_distance_check::Bool # unused for new versions ) guidelines = [ (guideline_registry_consistency_tests_pass, true), diff --git a/src/AutoMerge/pull_requests.jl b/src/AutoMerge/pull_requests.jl index a1e32dcb..54e8553b 100644 --- a/src/AutoMerge/pull_requests.jl +++ b/src/AutoMerge/pull_requests.jl @@ -195,6 +195,7 @@ function pull_request_build(data::GitHubAutoMergeData; check_license)::Nothing check_license=check_license, this_is_jll_package=this_is_jll_package, this_pr_can_use_special_jll_exceptions=this_pr_can_use_special_jll_exceptions, + use_distance_check=perform_distance_check(data.pr.labels) ) checked_guidelines = Guideline[] diff --git a/test/automerge-unit.jl b/test/automerge-unit.jl index 6d844e47..19dab411 100644 --- a/test/automerge-unit.jl +++ b/test/automerge-unit.jl @@ -123,6 +123,12 @@ end "ReallyLooooongNameCD", ["ReallyLooooongNameAB"] )[1] end + @testset "perform_distance_check" begin + @test AutoMerge.perform_distance_check(nothing) + @test AutoMerge.perform_distance_check([GitHub.Label(; name="hi")]) + @test !AutoMerge.perform_distance_check([GitHub.Label(; name="Override AutoMerge: name similarity is okay")]) + @test !AutoMerge.perform_distance_check([GitHub.Label(; name="hi"), GitHub.Label(; name="Override AutoMerge: name similarity is okay")]) + end @testset "`get_all_non_jll_package_names`" begin registry_path = joinpath(DEPOT_PATH[1], "registries", "General") packages = AutoMerge.get_all_non_jll_package_names(registry_path) @@ -617,7 +623,7 @@ end @test result[1] result = has_osi_license_in_depot("VisualStringDistances") @test result[1] - + # Now, what happens if there's also a non-OSI license in another file? pkg_path = pkgdir_from_depot(tmp_depot, "UnbalancedOptimalTransport") open(joinpath(pkg_path, "LICENSE2"); write=true) do io @@ -627,12 +633,12 @@ end end result = has_osi_license_in_depot("UnbalancedOptimalTransport") @test result[1] - + # What if we also remove the original license, leaving only the CC0 license? rm(joinpath(pkg_path, "LICENSE")) result = has_osi_license_in_depot("UnbalancedOptimalTransport") @test !result[1] - + # What about no license at all? pkg_path = pkgdir_from_depot(tmp_depot, "VisualStringDistances") rm(joinpath(pkg_path, "LICENSE")) From 58e3a6ad3bbdee98915519bacbd81993c5cb28c0 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 9 Dec 2023 01:51:25 +0100 Subject: [PATCH 02/13] update docs & example workflow --- example_github_workflow_files/automerge.yml | 2 ++ src/AutoMerge/guidelines.jl | 2 ++ 2 files changed, 4 insertions(+) diff --git a/example_github_workflow_files/automerge.yml b/example_github_workflow_files/automerge.yml index e36cc4ff..96287846 100644 --- a/example_github_workflow_files/automerge.yml +++ b/example_github_workflow_files/automerge.yml @@ -4,6 +4,8 @@ on: schedule: - cron: '05,17,29,41,53 * * * *' pull_request: + # Here we run when labels are applied, so that the "Override AutoMerge: name similarity is okay label is respected. + types: [labeled, synchronize] workflow_dispatch: jobs: diff --git a/src/AutoMerge/guidelines.jl b/src/AutoMerge/guidelines.jl index 9a673531..78a3ad61 100644 --- a/src/AutoMerge/guidelines.jl +++ b/src/AutoMerge/guidelines.jl @@ -265,6 +265,8 @@ To prevent confusion between similarly named packages, the names of new packages [VisualStringDistances.jl](https://github.com/ericphanson/VisualStringDistances.jl) between the package name and any existing package must exceeds a certain a hand-chosen threshold (currently 2.5). + +These checks can be overridden by applying a label `Override AutoMerge: name similarity is okay` to the PR. This will turn off the check as long as the label is applied to the PR. """, check=data -> meets_distance_check(data.pkg, data.registry_master), ) From 811b8ae041c689866eb064e0e50435fb581197fa Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 9 Dec 2023 01:58:22 +0100 Subject: [PATCH 03/13] only trigger on the correct label --- example_github_workflow_files/automerge.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/example_github_workflow_files/automerge.yml b/example_github_workflow_files/automerge.yml index 96287846..b0b8893d 100644 --- a/example_github_workflow_files/automerge.yml +++ b/example_github_workflow_files/automerge.yml @@ -10,6 +10,11 @@ on: jobs: AutoMerge: + # Run if the we are not triggered by a label OR we are triggered by a label, and that + # label is one that affects the execution of the workflow + # Note: since the label contains a colon, we need to use a workaround like https://github.com/actions/runner/issues/1019#issuecomment-810482716 + # for the syntax to parse correctly. + if: "${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && github.event.label.name == 'Override AutoMerge: name similarity is okay') }}" runs-on: ${{ matrix.os }} strategy: matrix: From feb2a61be951a8205be6ef3409178008a81943fc Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 9 Dec 2023 02:08:55 +0100 Subject: [PATCH 04/13] add kwargs to docs --- docs/src/guidelines.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/src/guidelines.md b/docs/src/guidelines.md index dd7f8bd5..745dd925 100644 --- a/docs/src/guidelines.md +++ b/docs/src/guidelines.md @@ -22,6 +22,7 @@ function guidelines_to_markdown_output(guidelines_function::Function) check_license = true, this_is_jll_package = false, this_pr_can_use_special_jll_exceptions = false, + use_distance_check = false, ) filter!(x -> x[1] != :update_status, guidelines) filter!(x -> !(x[1].docs isa Nothing), guidelines) @@ -50,6 +51,7 @@ function guidelines_to_markdown_output(guidelines_function::Function) check_license = true, this_is_jll_package = false, this_pr_can_use_special_jll_exceptions = false, + use_distance_check = false, ) filter!(x -> x[1] != :update_status, guidelines) filter!(x -> !(x[1].docs isa Nothing), guidelines) From e0a9236b7595d8f3bd99d062d3412e49cf8d4a2b Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 27 Jan 2024 22:19:55 +0100 Subject: [PATCH 05/13] allow skipping sequential version criteria with author approval mechanism --- docs/src/private-registries.md | 4 ++++ example_github_workflow_files/automerge.yml | 2 +- src/AutoMerge/guidelines.jl | 13 ++++++++++--- src/AutoMerge/pull_requests.jl | 3 ++- src/AutoMerge/util.jl | 16 ++++++++++++++++ test/automerge-unit.jl | 6 ++++++ 6 files changed, 39 insertions(+), 5 deletions(-) diff --git a/docs/src/private-registries.md b/docs/src/private-registries.md index eb55758a..59eddc66 100644 --- a/docs/src/private-registries.md +++ b/docs/src/private-registries.md @@ -99,3 +99,7 @@ In that case you will also have to add the following + - run: chmod +x .ci/instantiate.sh ``` in `ci.yml` and also `TagBotTriggers.yml` and `automerge.yml` (in which the above appears twice) files if those features are used. + +## Author approval workflow support + +Some guidelines allow the person invoking registration (typically the package author) to "approve" AutoMerge even if the guideline is not passing. This is facilitated by a labelling workflow `author_approval.yml` that must run on the registry in order to translate author-approval comments into labels that AutoMerge can use. The [General registry's workflows](https://github.com/JuliaRegistries/General/tree/master/.github/workflows) should once again be used as an example. diff --git a/example_github_workflow_files/automerge.yml b/example_github_workflow_files/automerge.yml index b0b8893d..d670c9e8 100644 --- a/example_github_workflow_files/automerge.yml +++ b/example_github_workflow_files/automerge.yml @@ -14,7 +14,7 @@ jobs: # label is one that affects the execution of the workflow # Note: since the label contains a colon, we need to use a workaround like https://github.com/actions/runner/issues/1019#issuecomment-810482716 # for the syntax to parse correctly. - if: "${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && github.event.label.name == 'Override AutoMerge: name similarity is okay') }}" + if: "${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && (github.event.label.name == 'Override AutoMerge: name similarity is okay' || github.event.label.name == 'package-author-approved')) }}" runs-on: ${{ matrix.os }} strategy: matrix: diff --git a/src/AutoMerge/guidelines.jl b/src/AutoMerge/guidelines.jl index 78a3ad61..b55958df 100644 --- a/src/AutoMerge/guidelines.jl +++ b/src/AutoMerge/guidelines.jl @@ -461,6 +461,10 @@ function _valid_change(old_version::VersionNumber, new_version::VersionNumber) end end +const AUTHOR_APPROVAL_INSTRUCTIONS = string( + "**If this was not a mistake and you wish to merge this PR anyway," + "write a comment that says \"merge approved\".**") + const guideline_sequential_version_number = Guideline(; info="Sequential version number", docs=string( @@ -471,6 +475,7 @@ const guideline_sequential_version_number = Guideline(; "valid new versions are `1.0.1`, `1.1.1`, `1.2.0` and `2.0.0`. ", "Invalid new versions include `1.0.2` (skips `1.0.1`), ", "`1.3.0` (skips `1.2.0`), `3.0.0` (skips `2.0.0`) etc.", + AUTHOR_APPROVAL_INSTRUCTIONS ), check=data -> meets_sequential_version_number( data.pkg, @@ -976,7 +981,8 @@ function get_automerge_guidelines( check_license::Bool, this_is_jll_package::Bool, this_pr_can_use_special_jll_exceptions::Bool, - use_distance_check::Bool + use_distance_check::Bool, + author_approved::Bool # currently unused for new packages ) guidelines = [ (guideline_registry_consistency_tests_pass, true), @@ -1018,12 +1024,13 @@ function get_automerge_guidelines( check_license::Bool, this_is_jll_package::Bool, this_pr_can_use_special_jll_exceptions::Bool, - use_distance_check::Bool # unused for new versions + use_distance_check::Bool, # unused for new versions + author_approved::Bool ) guidelines = [ (guideline_registry_consistency_tests_pass, true), (guideline_pr_only_changes_allowed_files, true), - (guideline_sequential_version_number, !this_pr_can_use_special_jll_exceptions), + (guideline_sequential_version_number, !this_pr_can_use_special_jll_exceptions && !author_approved), (guideline_version_number_no_prerelease, true), (guideline_version_number_no_build, !this_pr_can_use_special_jll_exceptions), (guideline_compat_for_julia, true), diff --git a/src/AutoMerge/pull_requests.jl b/src/AutoMerge/pull_requests.jl index 54e8553b..25d51572 100644 --- a/src/AutoMerge/pull_requests.jl +++ b/src/AutoMerge/pull_requests.jl @@ -195,7 +195,8 @@ function pull_request_build(data::GitHubAutoMergeData; check_license)::Nothing check_license=check_license, this_is_jll_package=this_is_jll_package, this_pr_can_use_special_jll_exceptions=this_pr_can_use_special_jll_exceptions, - use_distance_check=perform_distance_check(data.pr.labels) + use_distance_check=perform_distance_check(data.pr.labels), + author_approved=has_author_approved_label(data.pr.labels) ) checked_guidelines = Guideline[] diff --git a/src/AutoMerge/util.jl b/src/AutoMerge/util.jl index e887d168..538a59f7 100644 --- a/src/AutoMerge/util.jl +++ b/src/AutoMerge/util.jl @@ -288,3 +288,19 @@ function get_all_non_jll_package_names(registry_dir::AbstractString) unique!(packages) return packages end + +const AUTHOR_APPROVED_LABEL = "package-author-approved" + +function has_author_approved_label(labels) + # No labels? Not approved + isnothing(labels) && return false + for label in labels + if label.name === AUTHOR_APPROVED_LABEL + # found the approval + @debug "Found `$(AUTHOR_APPROVED_LABEL)` label" + return true + end + end + # Did not find approval + return false +end diff --git a/test/automerge-unit.jl b/test/automerge-unit.jl index 19dab411..ae829d0f 100644 --- a/test/automerge-unit.jl +++ b/test/automerge-unit.jl @@ -129,6 +129,12 @@ end @test !AutoMerge.perform_distance_check([GitHub.Label(; name="Override AutoMerge: name similarity is okay")]) @test !AutoMerge.perform_distance_check([GitHub.Label(; name="hi"), GitHub.Label(; name="Override AutoMerge: name similarity is okay")]) end + @testset "has_author_approved_label" begin + @test !AutoMerge.has_author_approved_label(nothing) + @test !AutoMerge.has_author_approved_label([GitHub.Label(; name="hi")]) + @test AutoMerge.has_author_approved_label([GitHub.Label(; name="package-author-approved")]) + @test AutoMerge.has_author_approved_label([GitHub.Label(; name="hi"), GitHub.Label(; name="package-author-approved")]) + end @testset "`get_all_non_jll_package_names`" begin registry_path = joinpath(DEPOT_PATH[1], "registries", "General") packages = AutoMerge.get_all_non_jll_package_names(registry_path) From cda2ef72354ca7accb26b6d7b5b34857b1ff8a34 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 27 Jan 2024 22:29:59 +0100 Subject: [PATCH 06/13] update `pr_comment_is_blocking` --- src/AutoMerge/cron.jl | 6 +++++- src/AutoMerge/guidelines.jl | 2 +- test/automerge-unit.jl | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/AutoMerge/cron.jl b/src/AutoMerge/cron.jl index 5d64d89e..5b24d27b 100644 --- a/src/AutoMerge/cron.jl +++ b/src/AutoMerge/cron.jl @@ -55,7 +55,11 @@ function all_specified_check_runs_passed( return all(values(check_passed)) end -pr_comment_is_blocking(c::GitHub.Comment) = !occursin("[noblock]", body(c)) +function pr_comment_is_blocking(c::GitHub.Comment) + # Note: `merge_approved` is not case sensitive, to match the semantics of `contains` on GHA + not_blocking = occursin("[noblock]", body(c)) || occursin("merge approved", lowercase(body(c))) + return !not_blocking +end function pr_has_no_blocking_comments( api::GitHub.GitHubAPI, diff --git a/src/AutoMerge/guidelines.jl b/src/AutoMerge/guidelines.jl index b55958df..2f1d6cd6 100644 --- a/src/AutoMerge/guidelines.jl +++ b/src/AutoMerge/guidelines.jl @@ -462,7 +462,7 @@ function _valid_change(old_version::VersionNumber, new_version::VersionNumber) end const AUTHOR_APPROVAL_INSTRUCTIONS = string( - "**If this was not a mistake and you wish to merge this PR anyway," + "**If this was not a mistake and you wish to merge this PR anyway,", "write a comment that says \"merge approved\".**") const guideline_sequential_version_number = Guideline(; diff --git a/test/automerge-unit.jl b/test/automerge-unit.jl index ae829d0f..78a2f99e 100644 --- a/test/automerge-unit.jl +++ b/test/automerge-unit.jl @@ -135,6 +135,13 @@ end @test AutoMerge.has_author_approved_label([GitHub.Label(; name="package-author-approved")]) @test AutoMerge.has_author_approved_label([GitHub.Label(; name="hi"), GitHub.Label(; name="package-author-approved")]) end + @testset "pr_comment_is_blocking" begin + @test AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="hi")) + @test AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="block")) + @test !AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="[noblock]")) + @test !AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="[noblock]hi")) + @test !AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="merge approved abc")) + end @testset "`get_all_non_jll_package_names`" begin registry_path = joinpath(DEPOT_PATH[1], "registries", "General") packages = AutoMerge.get_all_non_jll_package_names(registry_path) From e57556d659b80acf5943a9ac6ddf43d98d540540 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 27 Jan 2024 23:58:13 +0100 Subject: [PATCH 07/13] fix docs --- docs/src/guidelines.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/src/guidelines.md b/docs/src/guidelines.md index 745dd925..e9f2835e 100644 --- a/docs/src/guidelines.md +++ b/docs/src/guidelines.md @@ -23,6 +23,7 @@ function guidelines_to_markdown_output(guidelines_function::Function) this_is_jll_package = false, this_pr_can_use_special_jll_exceptions = false, use_distance_check = false, + author_approved = false ) filter!(x -> x[1] != :update_status, guidelines) filter!(x -> !(x[1].docs isa Nothing), guidelines) @@ -52,6 +53,7 @@ function guidelines_to_markdown_output(guidelines_function::Function) this_is_jll_package = false, this_pr_can_use_special_jll_exceptions = false, use_distance_check = false, + author_approved = false ) filter!(x -> x[1] != :update_status, guidelines) filter!(x -> !(x[1].docs isa Nothing), guidelines) From caf85a1a5f3f4e403b094e306213058ba95328c1 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Mon, 29 Jan 2024 00:59:14 +0100 Subject: [PATCH 08/13] Apply suggestions from code review Co-authored-by: Dilum Aluthge --- example_github_workflow_files/automerge.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/example_github_workflow_files/automerge.yml b/example_github_workflow_files/automerge.yml index b0b8893d..03dc8195 100644 --- a/example_github_workflow_files/automerge.yml +++ b/example_github_workflow_files/automerge.yml @@ -4,8 +4,9 @@ on: schedule: - cron: '05,17,29,41,53 * * * *' pull_request: - # Here we run when labels are applied, so that the "Override AutoMerge: name similarity is okay label is respected. - types: [labeled, synchronize] + # labeled = run when labels are applied, so that the "Override AutoMerge: name similarity is okay label is respected. + # synchronize = run when a commit is pushed to the PR + types: [opened, labeled, synchronize] workflow_dispatch: jobs: @@ -14,7 +15,7 @@ jobs: # label is one that affects the execution of the workflow # Note: since the label contains a colon, we need to use a workaround like https://github.com/actions/runner/issues/1019#issuecomment-810482716 # for the syntax to parse correctly. - if: "${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && github.event.label.name == 'Override AutoMerge: name similarity is okay') }}" + if: "${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && github.event.label.name == 'Override AutoMerge: name similarity is okay') }}" runs-on: ${{ matrix.os }} strategy: matrix: From 6386e934204750c21c229d1f21e2b39f0529c602 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Mon, 29 Jan 2024 01:13:39 +0100 Subject: [PATCH 09/13] Apply suggestions from code review Co-authored-by: Dilum Aluthge --- example_github_workflow_files/automerge.yml | 2 +- src/AutoMerge/guidelines.jl | 4 ++-- src/AutoMerge/util.jl | 2 +- test/automerge-unit.jl | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example_github_workflow_files/automerge.yml b/example_github_workflow_files/automerge.yml index d670c9e8..7a3fb29f 100644 --- a/example_github_workflow_files/automerge.yml +++ b/example_github_workflow_files/automerge.yml @@ -14,7 +14,7 @@ jobs: # label is one that affects the execution of the workflow # Note: since the label contains a colon, we need to use a workaround like https://github.com/actions/runner/issues/1019#issuecomment-810482716 # for the syntax to parse correctly. - if: "${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && (github.event.label.name == 'Override AutoMerge: name similarity is okay' || github.event.label.name == 'package-author-approved')) }}" + if: "${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && (github.event.label.name == 'Override AutoMerge: name similarity is okay' || github.event.label.name == 'Override AutoMerge: package author approved')) }}" runs-on: ${{ matrix.os }} strategy: matrix: diff --git a/src/AutoMerge/guidelines.jl b/src/AutoMerge/guidelines.jl index 2f1d6cd6..20848fd1 100644 --- a/src/AutoMerge/guidelines.jl +++ b/src/AutoMerge/guidelines.jl @@ -463,7 +463,7 @@ end const AUTHOR_APPROVAL_INSTRUCTIONS = string( "**If this was not a mistake and you wish to merge this PR anyway,", - "write a comment that says \"merge approved\".**") + "write a comment that says `[merge approved]`.**") const guideline_sequential_version_number = Guideline(; info="Sequential version number", @@ -475,7 +475,7 @@ const guideline_sequential_version_number = Guideline(; "valid new versions are `1.0.1`, `1.1.1`, `1.2.0` and `2.0.0`. ", "Invalid new versions include `1.0.2` (skips `1.0.1`), ", "`1.3.0` (skips `1.2.0`), `3.0.0` (skips `2.0.0`) etc.", - AUTHOR_APPROVAL_INSTRUCTIONS + AUTHOR_APPROVAL_INSTRUCTIONS, ), check=data -> meets_sequential_version_number( data.pkg, diff --git a/src/AutoMerge/util.jl b/src/AutoMerge/util.jl index 538a59f7..921beb6d 100644 --- a/src/AutoMerge/util.jl +++ b/src/AutoMerge/util.jl @@ -289,7 +289,7 @@ function get_all_non_jll_package_names(registry_dir::AbstractString) return packages end -const AUTHOR_APPROVED_LABEL = "package-author-approved" +const AUTHOR_APPROVED_LABEL = "Override AutoMerge: package author approved" function has_author_approved_label(labels) # No labels? Not approved diff --git a/test/automerge-unit.jl b/test/automerge-unit.jl index 78a2f99e..0d9baf2d 100644 --- a/test/automerge-unit.jl +++ b/test/automerge-unit.jl @@ -132,8 +132,8 @@ end @testset "has_author_approved_label" begin @test !AutoMerge.has_author_approved_label(nothing) @test !AutoMerge.has_author_approved_label([GitHub.Label(; name="hi")]) - @test AutoMerge.has_author_approved_label([GitHub.Label(; name="package-author-approved")]) - @test AutoMerge.has_author_approved_label([GitHub.Label(; name="hi"), GitHub.Label(; name="package-author-approved")]) + @test AutoMerge.has_author_approved_label([GitHub.Label(; name="Override AutoMerge: package author approved")]) + @test AutoMerge.has_author_approved_label([GitHub.Label(; name="hi"), GitHub.Label(; name="Override AutoMerge: package author approved")]) end @testset "pr_comment_is_blocking" begin @test AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="hi")) From 86a325d0c2b346274e4e085b9fd727f6fb5b4ce7 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Mon, 29 Jan 2024 01:14:05 +0100 Subject: [PATCH 10/13] Update test/automerge-unit.jl --- test/automerge-unit.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/automerge-unit.jl b/test/automerge-unit.jl index 0d9baf2d..3c0ec641 100644 --- a/test/automerge-unit.jl +++ b/test/automerge-unit.jl @@ -140,7 +140,7 @@ end @test AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="block")) @test !AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="[noblock]")) @test !AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="[noblock]hi")) - @test !AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="merge approved abc")) + @test !AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="[merge approved] abc")) end @testset "`get_all_non_jll_package_names`" begin registry_path = joinpath(DEPOT_PATH[1], "registries", "General") From 737e5c286854b97f562b0502e2d9614144208258 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:19:27 +0100 Subject: [PATCH 11/13] Apply suggestions from code review Co-authored-by: Dilum Aluthge --- docs/src/guidelines.md | 4 ++-- src/AutoMerge/cron.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/guidelines.md b/docs/src/guidelines.md index e9f2835e..70143077 100644 --- a/docs/src/guidelines.md +++ b/docs/src/guidelines.md @@ -23,7 +23,7 @@ function guidelines_to_markdown_output(guidelines_function::Function) this_is_jll_package = false, this_pr_can_use_special_jll_exceptions = false, use_distance_check = false, - author_approved = false + author_approved = false, ) filter!(x -> x[1] != :update_status, guidelines) filter!(x -> !(x[1].docs isa Nothing), guidelines) @@ -53,7 +53,7 @@ function guidelines_to_markdown_output(guidelines_function::Function) this_is_jll_package = false, this_pr_can_use_special_jll_exceptions = false, use_distance_check = false, - author_approved = false + author_approved = false, ) filter!(x -> x[1] != :update_status, guidelines) filter!(x -> !(x[1].docs isa Nothing), guidelines) diff --git a/src/AutoMerge/cron.jl b/src/AutoMerge/cron.jl index 5b24d27b..7d9b6ff9 100644 --- a/src/AutoMerge/cron.jl +++ b/src/AutoMerge/cron.jl @@ -57,7 +57,7 @@ end function pr_comment_is_blocking(c::GitHub.Comment) # Note: `merge_approved` is not case sensitive, to match the semantics of `contains` on GHA - not_blocking = occursin("[noblock]", body(c)) || occursin("merge approved", lowercase(body(c))) + not_blocking = occursin("[noblock]", body(c)) || occursin("[merge approved]", lowercase(body(c))) return !not_blocking end From 2f383b5cb355d7e89f95fe8751e60c9349a72b71 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:06:55 +0100 Subject: [PATCH 12/13] Update example_github_workflow_files/automerge.yml Co-authored-by: Dilum Aluthge --- example_github_workflow_files/automerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_github_workflow_files/automerge.yml b/example_github_workflow_files/automerge.yml index bc535d05..79aea526 100644 --- a/example_github_workflow_files/automerge.yml +++ b/example_github_workflow_files/automerge.yml @@ -16,7 +16,7 @@ jobs: # label is one that affects the execution of the workflow # Note: since the label contains a colon, we need to use a workaround like https://github.com/actions/runner/issues/1019#issuecomment-810482716 # for the syntax to parse correctly. - if: "${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && (github.event.label.name == 'Override AutoMerge: name similarity is okay' || github.event.label.name == 'Override AutoMerge: package author approved')) }}" + if: "${{ github.event.action != 'labeled' || (github.event.action == 'labeled' && (github.event.label.name == 'Override AutoMerge: name similarity is okay' || github.event.label.name == 'Override AutoMerge: package author approved')) }}" runs-on: ${{ matrix.os }} strategy: matrix: From d5fd1fa185c75e66fad8a68c0a33b9a5e0edcaae Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:31:07 +0100 Subject: [PATCH 13/13] Apply suggestions from code review Co-authored-by: Dilum Aluthge --- docs/src/guidelines.md | 4 ++-- src/AutoMerge/cron.jl | 2 +- src/AutoMerge/guidelines.jl | 10 +++++----- src/AutoMerge/pull_requests.jl | 2 +- src/AutoMerge/util.jl | 8 ++++---- test/automerge-unit.jl | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/src/guidelines.md b/docs/src/guidelines.md index 70143077..595c2548 100644 --- a/docs/src/guidelines.md +++ b/docs/src/guidelines.md @@ -23,7 +23,7 @@ function guidelines_to_markdown_output(guidelines_function::Function) this_is_jll_package = false, this_pr_can_use_special_jll_exceptions = false, use_distance_check = false, - author_approved = false, + package_author_approved = false, ) filter!(x -> x[1] != :update_status, guidelines) filter!(x -> !(x[1].docs isa Nothing), guidelines) @@ -53,7 +53,7 @@ function guidelines_to_markdown_output(guidelines_function::Function) this_is_jll_package = false, this_pr_can_use_special_jll_exceptions = false, use_distance_check = false, - author_approved = false, + package_author_approved = false, ) filter!(x -> x[1] != :update_status, guidelines) filter!(x -> !(x[1].docs isa Nothing), guidelines) diff --git a/src/AutoMerge/cron.jl b/src/AutoMerge/cron.jl index 7d9b6ff9..1be79f40 100644 --- a/src/AutoMerge/cron.jl +++ b/src/AutoMerge/cron.jl @@ -56,7 +56,7 @@ function all_specified_check_runs_passed( end function pr_comment_is_blocking(c::GitHub.Comment) - # Note: `merge_approved` is not case sensitive, to match the semantics of `contains` on GHA + # Note: `[merge approved]` is not case sensitive, to match the semantics of `contains` on GitHub Actions not_blocking = occursin("[noblock]", body(c)) || occursin("[merge approved]", lowercase(body(c))) return !not_blocking end diff --git a/src/AutoMerge/guidelines.jl b/src/AutoMerge/guidelines.jl index 20848fd1..f2aabf0d 100644 --- a/src/AutoMerge/guidelines.jl +++ b/src/AutoMerge/guidelines.jl @@ -461,7 +461,7 @@ function _valid_change(old_version::VersionNumber, new_version::VersionNumber) end end -const AUTHOR_APPROVAL_INSTRUCTIONS = string( +const PACKAGE_AUTHOR_APPROVAL_INSTRUCTIONS = string( "**If this was not a mistake and you wish to merge this PR anyway,", "write a comment that says `[merge approved]`.**") @@ -475,7 +475,7 @@ const guideline_sequential_version_number = Guideline(; "valid new versions are `1.0.1`, `1.1.1`, `1.2.0` and `2.0.0`. ", "Invalid new versions include `1.0.2` (skips `1.0.1`), ", "`1.3.0` (skips `1.2.0`), `3.0.0` (skips `2.0.0`) etc.", - AUTHOR_APPROVAL_INSTRUCTIONS, + PACKAGE_AUTHOR_APPROVAL_INSTRUCTIONS, ), check=data -> meets_sequential_version_number( data.pkg, @@ -982,7 +982,7 @@ function get_automerge_guidelines( this_is_jll_package::Bool, this_pr_can_use_special_jll_exceptions::Bool, use_distance_check::Bool, - author_approved::Bool # currently unused for new packages + package_author_approved::Bool # currently unused for new packages ) guidelines = [ (guideline_registry_consistency_tests_pass, true), @@ -1025,12 +1025,12 @@ function get_automerge_guidelines( this_is_jll_package::Bool, this_pr_can_use_special_jll_exceptions::Bool, use_distance_check::Bool, # unused for new versions - author_approved::Bool + package_author_approved::Bool, ) guidelines = [ (guideline_registry_consistency_tests_pass, true), (guideline_pr_only_changes_allowed_files, true), - (guideline_sequential_version_number, !this_pr_can_use_special_jll_exceptions && !author_approved), + (guideline_sequential_version_number, !this_pr_can_use_special_jll_exceptions && !package_author_approved), (guideline_version_number_no_prerelease, true), (guideline_version_number_no_build, !this_pr_can_use_special_jll_exceptions), (guideline_compat_for_julia, true), diff --git a/src/AutoMerge/pull_requests.jl b/src/AutoMerge/pull_requests.jl index 25d51572..72570f29 100644 --- a/src/AutoMerge/pull_requests.jl +++ b/src/AutoMerge/pull_requests.jl @@ -196,7 +196,7 @@ function pull_request_build(data::GitHubAutoMergeData; check_license)::Nothing this_is_jll_package=this_is_jll_package, this_pr_can_use_special_jll_exceptions=this_pr_can_use_special_jll_exceptions, use_distance_check=perform_distance_check(data.pr.labels), - author_approved=has_author_approved_label(data.pr.labels) + package_author_approved=has_package_author_approved_label(data.pr.labels) ) checked_guidelines = Guideline[] diff --git a/src/AutoMerge/util.jl b/src/AutoMerge/util.jl index c9b83c5b..3e0a074a 100644 --- a/src/AutoMerge/util.jl +++ b/src/AutoMerge/util.jl @@ -289,15 +289,15 @@ function get_all_non_jll_package_names(registry_dir::AbstractString) return packages end -const AUTHOR_APPROVED_LABEL = "Override AutoMerge: package author approved" +const PACKAGE_AUTHOR_APPROVED_LABEL = "Override AutoMerge: package author approved" -function has_author_approved_label(labels) +function has_package_author_approved_label(labels) # No labels? Not approved isnothing(labels) && return false for label in labels - if label.name === AUTHOR_APPROVED_LABEL + if label.name === PACKAGE_AUTHOR_APPROVED_LABEL # found the approval - @debug "Found `$(AUTHOR_APPROVED_LABEL)` label" + @debug "Found `$(PACKAGE_AUTHOR_APPROVED_LABEL)` label" return true end end diff --git a/test/automerge-unit.jl b/test/automerge-unit.jl index 3c0ec641..28bb8e30 100644 --- a/test/automerge-unit.jl +++ b/test/automerge-unit.jl @@ -130,10 +130,10 @@ end @test !AutoMerge.perform_distance_check([GitHub.Label(; name="hi"), GitHub.Label(; name="Override AutoMerge: name similarity is okay")]) end @testset "has_author_approved_label" begin - @test !AutoMerge.has_author_approved_label(nothing) - @test !AutoMerge.has_author_approved_label([GitHub.Label(; name="hi")]) - @test AutoMerge.has_author_approved_label([GitHub.Label(; name="Override AutoMerge: package author approved")]) - @test AutoMerge.has_author_approved_label([GitHub.Label(; name="hi"), GitHub.Label(; name="Override AutoMerge: package author approved")]) + @test !AutoMerge.has_package_author_approved_label(nothing) + @test !AutoMerge.has_package_author_approved_label([GitHub.Label(; name="hi")]) + @test AutoMerge.has_package_author_approved_label([GitHub.Label(; name="Override AutoMerge: package author approved")]) + @test AutoMerge.has_package_author_approved_label([GitHub.Label(; name="hi"), GitHub.Label(; name="Override AutoMerge: package author approved")]) end @testset "pr_comment_is_blocking" begin @test AutoMerge.pr_comment_is_blocking(GitHub.Comment(; body="hi"))