Skip to content

Commit 5a0a8b4

Browse files
authored
Improve the logic for determining the name of a local registry given the repository URL (#10)
1 parent 01aa92b commit 5a0a8b4

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

.github/workflows/CompatHelper.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@ on:
1010
type: string
1111
localregistry:
1212
description: 'URLs of registries besides General to use. Specified by providing the url (https/ssh) to the Github
13-
repositories as a newline (\n) seperated list. Should correspond to the registry names listed in
14-
`localregistry-names`.'
15-
default: ""
16-
required: false
17-
type: string
18-
localregistry-names:
19-
description: 'Names of registries besides General to use. Specified by providing the name of the registries
20-
as a newline (\n) seperated list. Should correspond to the registry URLs listed in `localregistry`.'
13+
repositories as a newline (\n) seperated list.'
2114
default: ""
2215
required: false
2316
type: string
@@ -53,23 +46,32 @@ jobs:
5346
- name: "Run CompatHelper"
5447
run: |
5548
import CompatHelper
49+
import LibGit2
5650
import Pkg
51+
import TOML
52+
function registry_info_from_url(url::AbstractString)
53+
return mktempdir() do tmp_path
54+
# Retry to help spurious connection issues, particularly on CI.
55+
# See https://github.com/JuliaLang/Pkg.jl/blob/v1.11.0/src/Registry/Registry.jl#L246-L248.
56+
repo = retry(LibGit2.clone; delays=fill(1.0, 5), check=(s, e) -> e isa LibGit2.GitError)(url, tmp_path)
57+
LibGit2.close(repo)
58+
return TOML.parsefile(joinpath(tmp_path, "Registry.toml"))
59+
end
60+
end
61+
registry_name_from_url(url::AbstractString) = registry_info_from_url(url)["name"]
5762
registries = [
5863
Pkg.RegistrySpec(;
59-
name = "General",
6064
url = "https://github.com/JuliaRegistries/General.git",
65+
name = "General",
6166
)
6267
]
6368
if !isempty("${{ inputs.localregistry }}")
6469
registry_urls = split("${{ inputs.localregistry }}", "\n") .|> string
65-
registry_names = if !isempty("${{ inputs.localregistry-names }}")
66-
split("${{ inputs.localregistry-names }}", "\n") .|> string
67-
else
68-
# Guess the registry name from the last part of the repository URL.
69-
map(registry_url -> string(first(split(last(split(registry_url, '/')), '.'))), registry_urls)
70-
end
71-
for (registry_url, registry_name) in zip(registry_urls, registry_names)
70+
for registry_url in registry_urls
7271
isempty(registry_url) && continue
72+
registry_name = registry_name_from_url(registry_url)
73+
# `CompatHelper.main` requires both the URL and the name.
74+
# TODO: Raise an issue about that in CompatHelper.jl.
7375
push!(registries, Pkg.RegistrySpec(; url=registry_url, name=registry_name))
7476
end
7577
end

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,7 @@ checks the Julia [General registry](https://github.com/JuliaRegistries/General)
183183
for breaking releases of dependencies, but you can add other registries
184184
by specifying the registry URLs with the `localregistry` option,
185185
which should be strings with registry URLs seperated by a newline character (`\n`).
186-
Registry names will be guess from the URLs, for example if a registry URL
187-
is "https://github.com/ITensor/ITensorRegistry.git" we will guess that the
188-
registry name is "ITensorRegistry". If that is not the case for one or more registry,
189-
you will need to specify all of the registry names as well using the `localregistry-names`
190-
in the same format. Here is an example workflow:
186+
Here is an example workflow:
191187

192188
```yaml
193189
name: "CompatHelper"
@@ -201,7 +197,7 @@ permissions:
201197
pull-requests: write
202198
203199
jobs:
204-
CompatHelper:
200+
compat-helper:
205201
name: "CompatHelper"
206202
uses: "ITensor/ITensorActions/.github/workflows/CompatHelper.yml@main"
207203
with:

0 commit comments

Comments
 (0)