From 2cffdfeac615c869f4855b9a3a8ad69960c97ee0 Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Thu, 5 Sep 2024 09:05:46 +0200 Subject: [PATCH 1/7] Consider the extras block when checking for new versions --- src/dependencies.jl | 2 +- test/dependencies.jl | 6 +++++- test/deps/Project.toml | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/dependencies.jl b/src/dependencies.jl index a6c8519e..9851e8a9 100644 --- a/src/dependencies.jl +++ b/src/dependencies.jl @@ -21,7 +21,7 @@ function get_project_deps(project_file::AbstractString; include_jll::Bool=false) dep_section = Dict{DepInfo,String}() project = TOML.parsefile(project_file) - for section in ["deps", "weakdeps"] + for section in ["deps", "weakdeps", "extras"] if haskey(project, section) deps = project[section] add_compat_section!(project) diff --git a/test/dependencies.jl b/test/dependencies.jl index 257c1bb9..da69fa47 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -20,6 +20,8 @@ end for (k, s) in pairs(dep_section) if k.package.name ∈ ["Bex_jll", "Skix"] @test s == "weakdeps" + elseif k.package.name ∈ ["Baz"] + @test s == "extras" else @test s == "deps" end @@ -31,6 +33,8 @@ end for (k, s) in pairs(dep_section) if k.package.name == "Skix" @test s == "weakdeps" + elseif k.package.name == "Baz" + @test s == "extras" else @test s == "deps" end @@ -142,7 +146,7 @@ end project_file = joinpath(pkgdir(CompatHelper), "Project.toml") # Just for this test, we hardcode this list - unregistered_stdlibs = ["Base64", "Dates", "Pkg", "UUIDs"] + unregistered_stdlibs = ["Base64", "Dates", "Pkg", "Random", "Test", "UUIDs"] @test ispath(project_file) @test isfile(project_file) diff --git a/test/deps/Project.toml b/test/deps/Project.toml index ebe0127d..45911412 100644 --- a/test/deps/Project.toml +++ b/test/deps/Project.toml @@ -4,7 +4,6 @@ version = "1.0.0" [deps] Foobar_jll = "6ca821de-e512-569d-89d9-0b16ce691416" -Baz = "ea10d353-3f73-51f8-a26c-33c1cb351aa5" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [weakdeps] @@ -14,6 +13,9 @@ Skix = "3db6da90-6ed3-11ee-0779-f549c8e3e90d" [extensions] Ext = ["Bex_jll", "Skix"] +[extras] +Baz = "ea10d353-3f73-51f8-a26c-33c1cb351aa5" + [compat] Foobar_jll = "1" Baz = "1" From d8875db47dc33f17fe2f33ca46d4349e30089aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Wed, 13 Aug 2025 20:20:20 +0200 Subject: [PATCH 2/7] Add options for handling `[extras]` dependencies --- src/CompatHelper.jl | 1 + src/dependencies.jl | 16 ++++++++-- src/main.jl | 7 ++++- src/utilities/types.jl | 6 ++++ test/dependencies.jl | 70 ++++++++++++++++++++++++++++++++++++++---- test/deps/Project.toml | 1 + 6 files changed, 91 insertions(+), 10 deletions(-) diff --git a/src/CompatHelper.jl b/src/CompatHelper.jl index a11fd063..30ccb422 100644 --- a/src/CompatHelper.jl +++ b/src/CompatHelper.jl @@ -12,6 +12,7 @@ using UUIDs: UUIDs, UUID using RegistryInstances: RegistryInstances export DropEntry, KeepEntry, NewEntry +export AllExtras, IfExistingCompatExtras, NoExtras export CIService, GitHubActions, GitLabCI @static if Base.VERSION >= v"1.7-" diff --git a/src/dependencies.jl b/src/dependencies.jl index 9851e8a9..aaf1afff 100644 --- a/src/dependencies.jl +++ b/src/dependencies.jl @@ -16,12 +16,17 @@ function get_local_clone( return local_path end -function get_project_deps(project_file::AbstractString; include_jll::Bool=false) +function get_project_deps(project_file::AbstractString; include_jll::Bool, open_prs_for_extras::ExtrasType) project_deps = Set{DepInfo}() dep_section = Dict{DepInfo,String}() project = TOML.parsefile(project_file) - for section in ["deps", "weakdeps", "extras"] + sections = if open_prs_for_extras isa NoExtras + ["deps", "weakdeps"] + else + ["deps", "weakdeps", "extras"] + end + for section in sections if haskey(project, section) deps = project[section] add_compat_section!(project) @@ -38,7 +43,12 @@ function get_project_deps(project_file::AbstractString; include_jll::Bool=false) compat_entry = DepInfo(package) dep_entry = convert(String, strip(get(compat, name, ""))) - if !isempty(dep_entry) + if isempty(dep_entry) + # Ignore dependencies in `[extras]` without a compat entry if `open_prs_for_extras` is `IfExistingCompatExtras()` + if section == "extras" && open_prs_for_extras isa IfExistingCompatExtras + continue + end + else compat_entry.version_spec = semver_spec(dep_entry) compat_entry.version_verbatim = dep_entry end diff --git a/src/main.jl b/src/main.jl index 8a1e9a16..ecf0504b 100644 --- a/src/main.jl +++ b/src/main.jl @@ -15,6 +15,7 @@ cc_user=false, bump_version=false, include_yanked=false, + open_prs_for_extras::ExtrasType=IfExistingCompatExtras(), ) Main entry point for the package. @@ -37,6 +38,10 @@ Main entry point for the package. - `cc_user=false`: CC the user on the pull requests - `bump_version=false`: When set to true, the version in Project.toml will be bumped if a pull request is made. Minor bump if >= 1.0, or patch bump if < 1.0 - `include_yanked=false`: When set to true, yanked versions will be included when calculating what the latest version of a package is +- `open_prs_for_extras::ExtrasType=IfExistingCompatExtras()`: How to handle dependencies in `[extras]`. + Can be `IfExistingCompatExtras()` (only open a pull request for a dependency in `[extras]` if a compat entry for it exists), + `AllExtras()` (open pull requests for all dependencies in `[extras]`), + or `NoExtras()` (do not open pull requests for dependencies in `[extras]`). """ function main( env::AbstractDict=ENV, ci_cfg::CIService=auto_detect_ci_service(; env=env); kwargs... @@ -51,7 +56,7 @@ function main( for subdir in options.subdirs project_file = @mock joinpath(local_clone_path, subdir, "Project.toml") - deps, dep_sections = get_project_deps(project_file; include_jll=options.include_jll) + deps, dep_sections = get_project_deps(project_file; include_jll=options.include_jll, open_prs_for_extras=options.open_prs_for_extras) populate_dep_versions_from_reg!(deps; options) diff --git a/src/utilities/types.jl b/src/utilities/types.jl index 523a1972..61aa4818 100644 --- a/src/utilities/types.jl +++ b/src/utilities/types.jl @@ -26,6 +26,11 @@ mutable struct DepInfo end end +abstract type ExtrasType end +struct AllExtras <: ExtrasType end +struct IfExistingCompatExtras <: ExtrasType end +struct NoExtras <: ExtrasType end + function Base.in(p::Package, s::Set{DepInfo}) for i in s if i.package == p @@ -56,4 +61,5 @@ Base.@kwdef struct Options cc_user::Bool = false bump_version::Bool = false include_yanked::Bool = false + open_prs_for_extras::ExtrasType = IfExistingCompatExtras() end diff --git a/test/dependencies.jl b/test/dependencies.jl index da69fa47..db60d202 100644 --- a/test/dependencies.jl +++ b/test/dependencies.jl @@ -14,28 +14,82 @@ end @testset "get_project_deps" begin project = joinpath(@__DIR__, "deps", "Project.toml") - deps, dep_section = CompatHelper.get_project_deps(project; include_jll=true) + deps, dep_section = CompatHelper.get_project_deps(project; include_jll=true, open_prs_for_extras = AllExtras()) + @test length(deps) == 6 + @test issetequal([dep.package.name for dep in deps], ["Baz", "Bex_jll", "Car", "Foobar_jll", "LinearAlgebra", "Skix"]) + @test issetequal(keys(dep_section), deps) + for (k, s) in pairs(dep_section) + if k.package.name ∈ ["Bex_jll", "Skix"] + @test s == "weakdeps" + elseif k.package.name ∈ ["Baz", "Car"] + @test s == "extras" + else # k.package.name ∈ ["Foobar_jll", "LinearAlgebra"] + @test s == "deps" + end + end + + deps, dep_section = CompatHelper.get_project_deps(project; include_jll=false, open_prs_for_extras = AllExtras()) + @test length(deps) == 4 + @test issetequal([dep.package.name for dep in deps], ["Baz", "Car", "LinearAlgebra", "Skix"]) + @test issetequal(keys(dep_section), deps) + for (k, s) in pairs(dep_section) + if k.package.name == "Skix" + @test s == "weakdeps" + elseif k.package.name ∈ ["Baz", "Car"] + @test s == "extras" + else # k.package.name == "LinearAlgebra" + @test s == "deps" + end + end + + deps, dep_section = CompatHelper.get_project_deps(project; include_jll=true, open_prs_for_extras = IfExistingCompatExtras()) @test length(deps) == 5 + @test issetequal([dep.package.name for dep in deps], ["Baz", "Bex_jll", "Foobar_jll", "LinearAlgebra", "Skix"]) @test issetequal(keys(dep_section), deps) for (k, s) in pairs(dep_section) if k.package.name ∈ ["Bex_jll", "Skix"] @test s == "weakdeps" - elseif k.package.name ∈ ["Baz"] + elseif k.package.name == "Baz" @test s == "extras" - else + else # k.package.name ∈ ["Foobar_jll", "LinearAlgebra"] @test s == "deps" end end - deps, dep_section = CompatHelper.get_project_deps(project; include_jll=false) + deps, dep_section = CompatHelper.get_project_deps(project; include_jll=false, open_prs_for_extras = IfExistingCompatExtras()) @test length(deps) == 3 + @test issetequal([dep.package.name for dep in deps], ["Baz", "LinearAlgebra", "Skix"]) @test issetequal(keys(dep_section), deps) for (k, s) in pairs(dep_section) if k.package.name == "Skix" @test s == "weakdeps" elseif k.package.name == "Baz" @test s == "extras" - else + else # k.package.name == "LinearAlgebra" + @test s == "deps" + end + end + + deps, dep_section = CompatHelper.get_project_deps(project; include_jll=true, open_prs_for_extras = NoExtras()) + @test length(deps) == 4 + @test issetequal([dep.package.name for dep in deps], ["Bex_jll", "Foobar_jll", "LinearAlgebra", "Skix"]) + @test issetequal(keys(dep_section), deps) + for (k, s) in pairs(dep_section) + if k.package.name ∈ ["Bex_jll", "Skix"] + @test s == "weakdeps" + else # k.package.name ∈ ["Foobar_jll", "LinearAlgebra"] + @test s == "deps" + end + end + + deps, dep_section = CompatHelper.get_project_deps(project; include_jll=false, open_prs_for_extras = NoExtras()) + @test length(deps) == 2 + @test issetequal([dep.package.name for dep in deps], ["LinearAlgebra", "Skix"]) + @test issetequal(keys(dep_section), deps) + for (k, s) in pairs(dep_section) + if k.package.name == "Skix" + @test s == "weakdeps" + else # k.package.name == "LinearAlgebra" @test s == "deps" end end @@ -152,7 +206,11 @@ end @test isfile(project_file) for use_existing_registries in [true, false] options = CompatHelper.Options(; use_existing_registries) - deps, _ = CompatHelper.get_project_deps(project_file) + deps, _ = CompatHelper.get_project_deps( + project_file; + include_jll=false, + open_prs_for_extras=IfExistingCompatExtras(), + ) for dep in deps @test dep.latest_version === nothing end diff --git a/test/deps/Project.toml b/test/deps/Project.toml index 45911412..06263055 100644 --- a/test/deps/Project.toml +++ b/test/deps/Project.toml @@ -15,6 +15,7 @@ Ext = ["Bex_jll", "Skix"] [extras] Baz = "ea10d353-3f73-51f8-a26c-33c1cb351aa5" +Car = "0add4187-88db-462b-bf06-da4bec59fd54" [compat] Foobar_jll = "1" From 1e49c6fb8d123fdea9a672523f3864318f1ffa13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Thu, 4 Sep 2025 23:40:33 +0000 Subject: [PATCH 3/7] Add note that the setting is experimental --- src/main.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.jl b/src/main.jl index ecf0504b..461a7f1e 100644 --- a/src/main.jl +++ b/src/main.jl @@ -42,6 +42,9 @@ Main entry point for the package. Can be `IfExistingCompatExtras()` (only open a pull request for a dependency in `[extras]` if a compat entry for it exists), `AllExtras()` (open pull requests for all dependencies in `[extras]`), or `NoExtras()` (do not open pull requests for dependencies in `[extras]`). + +!!! note + The `open_prs_for_extras` keyword argument is considered experimental and may be changed in a non-breaking release. """ function main( env::AbstractDict=ENV, ci_cfg::CIService=auto_detect_ci_service(; env=env); kwargs... From 3ccfe316c3c641cd2ccf4bbd49a43d16df04eaa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Fri, 5 Sep 2025 01:44:26 +0200 Subject: [PATCH 4/7] Update src/main.jl Co-authored-by: Dilum Aluthge --- src/main.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.jl b/src/main.jl index 461a7f1e..1ba8af63 100644 --- a/src/main.jl +++ b/src/main.jl @@ -44,7 +44,7 @@ Main entry point for the package. or `NoExtras()` (do not open pull requests for dependencies in `[extras]`). !!! note - The `open_prs_for_extras` keyword argument is considered experimental and may be changed in a non-breaking release. + The `open_prs_for_extras` keyword argument is considered experimental (not public API) and may be changed or removed in a non-breaking release. """ function main( env::AbstractDict=ENV, ci_cfg::CIService=auto_detect_ci_service(; env=env); kwargs... From ea2c7c6d3ca348eb8f3a326df4142db61cea1eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Fri, 5 Sep 2025 02:23:57 +0200 Subject: [PATCH 5/7] Add additional imports from CompatHelper --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 793cf395..8b2dc4f9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,7 @@ using Aqua using Base64 using CompatHelper -using CompatHelper: DepInfo, EntryType +using CompatHelper: DepInfo, EntryType, AllExtras, IfExistingCompatExtras, NoExtras using Dates using GitForge using GitForge: GitForge, GitHub, GitLab From 115f5f162df725b292295213f86b9d8ecda26632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Fri, 5 Sep 2025 02:26:10 +0200 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Dilum Aluthge --- src/CompatHelper.jl | 1 - src/main.jl | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/CompatHelper.jl b/src/CompatHelper.jl index 30ccb422..a11fd063 100644 --- a/src/CompatHelper.jl +++ b/src/CompatHelper.jl @@ -12,7 +12,6 @@ using UUIDs: UUIDs, UUID using RegistryInstances: RegistryInstances export DropEntry, KeepEntry, NewEntry -export AllExtras, IfExistingCompatExtras, NoExtras export CIService, GitHubActions, GitLabCI @static if Base.VERSION >= v"1.7-" diff --git a/src/main.jl b/src/main.jl index 1ba8af63..05603679 100644 --- a/src/main.jl +++ b/src/main.jl @@ -44,7 +44,7 @@ Main entry point for the package. or `NoExtras()` (do not open pull requests for dependencies in `[extras]`). !!! note - The `open_prs_for_extras` keyword argument is considered experimental (not public API) and may be changed or removed in a non-breaking release. + The `open_prs_for_extras` keyword argument is considered experimental (not public API) and may be changed or removed in a non-breaking release. Same goes for `AllExtras`, `IfExistingCompatExtras`, `NoExtras`, and `ExtrasType`. """ function main( env::AbstractDict=ENV, ci_cfg::CIService=auto_detect_ci_service(; env=env); kwargs... From 98a26849857ad6fa762217284117e4b70af5740f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller-Widmann?= Date: Fri, 5 Sep 2025 07:56:25 +0000 Subject: [PATCH 7/7] Update docstrings since types are not exported anymore --- src/main.jl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.jl b/src/main.jl index 05603679..ae05b2d7 100644 --- a/src/main.jl +++ b/src/main.jl @@ -15,7 +15,7 @@ cc_user=false, bump_version=false, include_yanked=false, - open_prs_for_extras::ExtrasType=IfExistingCompatExtras(), + open_prs_for_extras::CompatHelper.ExtrasType=CompatHelper.IfExistingCompatExtras(), ) Main entry point for the package. @@ -38,13 +38,15 @@ Main entry point for the package. - `cc_user=false`: CC the user on the pull requests - `bump_version=false`: When set to true, the version in Project.toml will be bumped if a pull request is made. Minor bump if >= 1.0, or patch bump if < 1.0 - `include_yanked=false`: When set to true, yanked versions will be included when calculating what the latest version of a package is -- `open_prs_for_extras::ExtrasType=IfExistingCompatExtras()`: How to handle dependencies in `[extras]`. - Can be `IfExistingCompatExtras()` (only open a pull request for a dependency in `[extras]` if a compat entry for it exists), - `AllExtras()` (open pull requests for all dependencies in `[extras]`), - or `NoExtras()` (do not open pull requests for dependencies in `[extras]`). +- `open_prs_for_extras::CompatHelper.ExtrasType=CompatHelper.IfExistingCompatExtras()`: How to handle dependencies in `[extras]`. + Can be `CompatHelper.IfExistingCompatExtras()` (only open a pull request for a dependency in `[extras]` if a compat entry for it exists), + `CompatHelper.AllExtras()` (open pull requests for all dependencies in `[extras]`), + or `CompatHelper.NoExtras()` (do not open pull requests for dependencies in `[extras]`). !!! note - The `open_prs_for_extras` keyword argument is considered experimental (not public API) and may be changed or removed in a non-breaking release. Same goes for `AllExtras`, `IfExistingCompatExtras`, `NoExtras`, and `ExtrasType`. + The `open_prs_for_extras` keyword argument and + the `CompatHelper.AllExtras`, `CompatHelper.IfExistingCompatExtras`, `CompatHelper.NoExtras`, and `CompatHelper.ExtrasType` types + are considered experimental (not public API) and may be changed or removed in a non-breaking release. """ function main( env::AbstractDict=ENV, ci_cfg::CIService=auto_detect_ci_service(; env=env); kwargs...