Skip to content

Commit 18bd2a4

Browse files
authored
Open PRs for compat entries to weak dependencies (#458)
* Track deps also in weakdeps * Add dependency section to PR title * Fix keyword bug * Add section to other method * Update new_versions tests * Update method call * Update patch * Run formatter * Add integration tests for weak dependencies * Place square brackets around section name in title * Add unit test for `get_project_deps` * Don't change the PR title when package is in deps section * Increase count for pr length check * Add missing compat entries for extras * Increment minor version for feature release * Update call to `get_project_deps`
1 parent 532fae9 commit 18bd2a4

File tree

15 files changed

+308
-38
lines changed

15 files changed

+308
-38
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CompatHelper"
22
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
33
authors = ["Dilum Aluthge", "Brown Center for Biomedical Informatics", "contributors"]
4-
version = "3.10.0"
4+
version = "3.11.0"
55

66
[deps]
77
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

src/dependencies.jl

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,39 @@ end
1818

1919
function get_project_deps(project_file::AbstractString; include_jll::Bool=false)
2020
project_deps = Set{DepInfo}()
21+
dep_section = Dict{DepInfo,String}()
2122
project = TOML.parsefile(project_file)
2223

23-
if haskey(project, "deps")
24-
deps = project["deps"]
25-
add_compat_section!(project)
26-
compat = project["compat"]
27-
28-
for dep in deps
29-
name = dep[1]
30-
uuid = UUIDs.UUID(dep[2])
31-
32-
# Ignore JLL packages if flag set
33-
# Do NOT ignore stdlib packages.
34-
if !endswith(lowercase(strip(name)), "_jll") || include_jll
35-
package = Package(name, uuid)
36-
compat_entry = DepInfo(package)
37-
dep_entry = convert(String, strip(get(compat, name, "")))
38-
39-
if !isempty(dep_entry)
40-
compat_entry.version_spec = semver_spec(dep_entry)
41-
compat_entry.version_verbatim = dep_entry
24+
for section in ["deps", "weakdeps"]
25+
if haskey(project, section)
26+
deps = project[section]
27+
add_compat_section!(project)
28+
compat = project["compat"]
29+
30+
for dep in deps
31+
name = dep[1]
32+
uuid = UUIDs.UUID(dep[2])
33+
34+
# Ignore JLL packages if flag set
35+
# Do NOT ignore stdlib packages.
36+
if !endswith(lowercase(strip(name)), "_jll") || include_jll
37+
package = Package(name, uuid)
38+
compat_entry = DepInfo(package)
39+
dep_entry = convert(String, strip(get(compat, name, "")))
40+
41+
if !isempty(dep_entry)
42+
compat_entry.version_spec = semver_spec(dep_entry)
43+
compat_entry.version_verbatim = dep_entry
44+
end
45+
46+
push!(project_deps, compat_entry)
47+
get!(dep_section, compat_entry, section)
4248
end
43-
44-
push!(project_deps, compat_entry)
4549
end
4650
end
4751
end
4852

49-
return project_deps
53+
return project_deps, dep_section
5054
end
5155

5256
function clone_all_registries(f::Function, registry_list::Vector{Pkg.RegistrySpec})

src/main.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ function main(
5151

5252
for subdir in options.subdirs
5353
project_file = @mock joinpath(local_clone_path, subdir, "Project.toml")
54-
deps = get_project_deps(project_file; include_jll=options.include_jll)
54+
deps, dep_sections = get_project_deps(project_file; include_jll=options.include_jll)
5555

5656
populate_dep_versions_from_reg!(deps; options)
5757

5858
for dep in deps
59+
dep_section = dep_sections[dep]
5960
pr = @mock make_pr_for_new_version(
6061
api,
6162
repo,
@@ -65,6 +66,7 @@ function main(
6566
options,
6667
subdir,
6768
local_clone_path,
69+
dep_section,
6870
)
6971

7072
if !isnothing(pr)

src/utilities/new_versions.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,14 @@ function subdir_string(subdir::AbstractString)
4343
end
4444
end
4545

46+
function section_string(section::AbstractString)
47+
return section == "deps" ? "" : " in [$(section)]"
48+
end
49+
4650
function pr_info(
4751
compat_entry_verbatim::Nothing,
4852
name::AbstractString,
53+
section_str::AbstractString,
4954
compat_entry_for_latest_version::AbstractString,
5055
compat_entry::AbstractString,
5156
subdir_string::AbstractString,
@@ -54,7 +59,7 @@ function pr_info(
5459
pr_title_prefix::String,
5560
)
5661
new_pr_title = m"""
57-
$(pr_title_prefix)CompatHelper: add new compat entry for $(name) at version
62+
$(pr_title_prefix)CompatHelper: add new compat entry for $(name)$(section_str) at version
5863
$(compat_entry_for_latest_version)$(subdir_string)$(pr_title_parenthetical)
5964
"""
6065

@@ -73,6 +78,7 @@ end
7378
function pr_info(
7479
compat_entry_verbatim::AbstractString,
7580
name::AbstractString,
81+
section_str::AbstractString,
7682
compat_entry_for_latest_version::AbstractString,
7783
compat_entry::AbstractString,
7884
subdir_string::AbstractString,
@@ -81,7 +87,7 @@ function pr_info(
8187
pr_title_prefix::String,
8288
)
8389
new_pr_title = m"""
84-
$(pr_title_prefix)CompatHelper: bump compat for $(name) to
90+
$(pr_title_prefix)CompatHelper: bump compat for $(name)$(section_str) to
8591
$(compat_entry_for_latest_version)$(subdir_string)$(pr_title_parenthetical)
8692
"""
8793

@@ -209,6 +215,7 @@ function make_pr_for_new_version(
209215
options::Options,
210216
subdir::String,
211217
local_clone_path::AbstractString,
218+
dep_section::String,
212219
)
213220
if !continue_with_pr(dep, options.bump_compat_containing_equality_specifier)
214221
return nothing
@@ -222,6 +229,7 @@ function make_pr_for_new_version(
222229
new_pr_title, new_pr_body = pr_info(
223230
dep.version_verbatim,
224231
dep.package.name,
232+
section_string(dep_section),
225233
compat_entry_for_latest_version,
226234
brand_new_compat,
227235
subdir_string(subdir),

test/dependencies.jl

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,27 @@ end
1414
@testset "get_project_deps" begin
1515
project = joinpath(@__DIR__, "deps", "Project.toml")
1616

17-
deps = CompatHelper.get_project_deps(project; include_jll=true)
17+
deps, dep_section = CompatHelper.get_project_deps(project; include_jll=true)
18+
@test length(deps) == 5
19+
@test issetequal(keys(dep_section), deps)
20+
for (k, s) in pairs(dep_section)
21+
if k.package.name ["Bex_jll", "Skix"]
22+
@test s == "weakdeps"
23+
else
24+
@test s == "deps"
25+
end
26+
end
27+
28+
deps, dep_section = CompatHelper.get_project_deps(project; include_jll=false)
1829
@test length(deps) == 3
19-
deps = CompatHelper.get_project_deps(project; include_jll=false)
20-
@test length(deps) == 2
30+
@test issetequal(keys(dep_section), deps)
31+
for (k, s) in pairs(dep_section)
32+
if k.package.name == "Skix"
33+
@test s == "weakdeps"
34+
else
35+
@test s == "deps"
36+
end
37+
end
2138
end
2239

2340
@testset "clone_all_registries" begin
@@ -131,7 +148,7 @@ end
131148
@test isfile(project_file)
132149
for use_existing_registries in [true, false]
133150
options = CompatHelper.Options(; use_existing_registries)
134-
deps = CompatHelper.get_project_deps(project_file)
151+
deps, _ = CompatHelper.get_project_deps(project_file)
135152
for dep in deps
136153
@test dep.latest_version === nothing
137154
end

test/deps/Project.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ Foobar_jll = "6ca821de-e512-569d-89d9-0b16ce691416"
77
Baz = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"
88
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
99

10+
[weakdeps]
11+
Bex_jll = "3db6da90-6ed3-11ee-0779-f549c8e3e90d"
12+
Skix = "3db6da90-6ed3-11ee-0779-f549c8e3e90d"
13+
14+
[extensions]
15+
Ext = ["Bex_jll", "Skix"]
16+
1017
[compat]
1118
Foobar_jll = "1"
1219
Baz = "1"
20+
Bex_jll = "1"
21+
Skix = "1"
1322
julia = "1.6"

test/integration_tests.jl

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,106 @@ function run_integration_tests(
171171
end
172172
end
173173

174+
sleep(1) # Prevent hitting the GH Secondary Rate Limits
175+
176+
@testset "master_9" begin
177+
with_master_branch(templates("master_9"), url, "master") do master_9
178+
withenv(env...) do
179+
CompatHelper.main(
180+
ENV,
181+
ci_cfg;
182+
pr_title_prefix="$(GLOBAL_PR_TITLE_PREFIX) [test-9c] ",
183+
master_branch=master_9,
184+
entry_type=KeepEntry(),
185+
)
186+
end
187+
end
188+
end
189+
190+
sleep(1) # Prevent hitting the GH Secondary Rate Limits
191+
192+
@testset "master_10" begin
193+
with_master_branch(templates("master_10"), url, "master") do master_10
194+
withenv(env...) do
195+
CompatHelper.main(
196+
ENV,
197+
ci_cfg;
198+
pr_title_prefix="$(GLOBAL_PR_TITLE_PREFIX) [test-10a] ",
199+
master_branch=master_10,
200+
entry_type=DropEntry(),
201+
)
202+
203+
sleep(1) # Prevent hitting the GH Secondary Rate Limits
204+
205+
CompatHelper.main(
206+
ENV,
207+
ci_cfg;
208+
pr_title_prefix="$(GLOBAL_PR_TITLE_PREFIX) [test-10b] ",
209+
master_branch=master_10,
210+
entry_type=KeepEntry(),
211+
)
212+
213+
sleep(1) # Prevent hitting the GH Secondary Rate Limits
214+
215+
CompatHelper.main(
216+
ENV,
217+
ci_cfg;
218+
pr_title_prefix="$(GLOBAL_PR_TITLE_PREFIX) [test-10c] ",
219+
master_branch=master_10,
220+
entry_type=KeepEntry(),
221+
)
222+
end
223+
end
224+
end
225+
226+
sleep(1) # Prevent hitting the GH Secondary Rate Limits
227+
228+
@testset "master_11" begin
229+
with_master_branch(templates("master_11"), url, "master") do master_11
230+
withenv(env...) do
231+
CompatHelper.main(
232+
ENV,
233+
ci_cfg;
234+
pr_title_prefix="$(GLOBAL_PR_TITLE_PREFIX) [test-11c] ",
235+
master_branch=master_11,
236+
entry_type=KeepEntry(),
237+
)
238+
end
239+
end
240+
end
241+
242+
sleep(1) # Prevent hitting the GH Secondary Rate Limits
243+
244+
@testset "master_12" begin
245+
with_master_branch(templates("master_12"), url, "master") do master_12
246+
withenv(env...) do
247+
CompatHelper.main(
248+
ENV,
249+
ci_cfg;
250+
pr_title_prefix="$(GLOBAL_PR_TITLE_PREFIX) [test-12a] ",
251+
master_branch=master_12,
252+
entry_type=DropEntry(),
253+
)
254+
end
255+
end
256+
end
257+
258+
sleep(1) # Prevent hitting the GH Secondary Rate Limits
259+
260+
@testset "master_13" begin
261+
with_master_branch(templates("master_13"), url, "master") do master_13
262+
withenv(env...) do
263+
CompatHelper.main(
264+
ENV,
265+
ci_cfg;
266+
pr_title_prefix="$(GLOBAL_PR_TITLE_PREFIX) [test-13a] ",
267+
master_branch=master_13,
268+
entry_type=DropEntry(),
269+
)
270+
end
271+
end
272+
end
273+
174274
return _cleanup_old_branches(url)
175275
end
176276

test/main.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@
6262
"GITHUB_REPOSITORY" => "CompatHelper.jl", "GITHUB_TOKEN" => "token"
6363
) do
6464
prs = CompatHelper.main()
65-
@test length(prs) == 2
65+
@test length(prs) == 3
6666
@test prs[1] isa GitHub.PullRequest
67+
@test prs[2] isa GitHub.PullRequest
6768
end
6869
end
6970
end
@@ -96,8 +97,9 @@
9697
) do
9798
delete!(ENV, "GITHUB_REPOSITORY")
9899
prs = CompatHelper.main()
99-
@test length(prs) == 2
100+
@test length(prs) == 3
100101
@test prs[1] isa GitLab.MergeRequest
102+
@test prs[2] isa GitLab.MergeRequest
101103
end
102104
end
103105
end

test/templates/master_10/Project.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name = "compathelper_integration_test_repo"
2+
uuid = "0e97b93d-f6aa-40c8-b749-d2f6bf239ed7"
3+
authors = ["Brown Center for Biomedical Informatics"]
4+
description = "Test Project.toml with both dependencies and weak dependencies, compat entries; major ver, ~"
5+
version = "0.1.0"
6+
7+
[weakdeps]
8+
BioSequences = "7e6ae17a-c86d-528c-b3b9-7f778a29fe59"
9+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
10+
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
11+
IterableTables = "1c8ee90f-4401-5389-894e-7a04a3dc0f4d"
12+
Nettle_jll = "4c82536e-c426-54e4-b420-14f461c4ed8b"
13+
PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925"
14+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
15+
16+
[extensions]
17+
Ext = ["BioSequences", "DataFrames", "Flux", "IterableTables", "Nettle_jll", "PGFPlotsX"]
18+
19+
[compat]
20+
IterableTables = "1"
21+
PGFPlotsX = "~1.0.0"
22+
julia = "1.2"
23+
24+
[extras]
25+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
26+
27+
[targets]
28+
test = ["Test"]

test/templates/master_11/Project.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name = "compathelper_integration_test_repo"
2+
uuid = "0e97b93d-f6aa-40c8-b749-d2f6bf239ed7"
3+
authors = ["Brown Center for Biomedical Informatics"]
4+
description = "Test Project.toml with weak dependency where package does not exist"
5+
version = "0.1.0"
6+
7+
[weakdeps]
8+
ThisPackageDoesNotExist = "2c58d03c-75de-479c-aa0b-96bf0b358d76"
9+
10+
[extensions]
11+
Ext = "ThisPackageDoesNotExist"
12+
13+
[compat]
14+
julia = "1.2"
15+
16+
[extras]
17+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
18+
19+
[targets]
20+
test = ["Test"]

0 commit comments

Comments
 (0)