Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support RegistryInstance in get_all_non_jll_package_names #568

Merged
merged 9 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci_unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
env:
AUTOMERGE_RUN_INTEGRATION_TESTS: "false"
documentation:
env:
JULIA_PKG_UNPACK_REGISTRY: 'false'
name: Documentation
runs-on: ubuntu-latest
steps:
Expand All @@ -59,10 +61,11 @@ jobs:
- run: |
julia --project=docs -e '
using Pkg
# install compressed registry
Pkg.Registry.rm("General")
Pkg.Registry.add("General")
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
env:
JULIA_PKG_SERVER: ''
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RegistryCI"
uuid = "0c95cc5f-2f7e-43fe-82dd-79dbcba86b32"
authors = ["Dilum Aluthge <[email protected]>", "Fredrik Ekre <[email protected]>", "contributors"]
version = "10.5.0"
version = "10.6.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
RegistryCI = "0c95cc5f-2f7e-43fe-82dd-79dbcba86b32"
RegistryInstances = "2792f1a3-b283-48e8-9a74-f99dce5104f3"

[compat]
Documenter = "1"
RegistryInstances = "0.1"
16 changes: 9 additions & 7 deletions docs/src/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,19 @@ To test yourself that a tentative package name, say `MyPackage` meets these
checks, you can use the following code (after adding the RegistryCI package
to your Julia environment):

```julia
using RegistryCI
```@example
using RegistryCI, RegistryInstances
using RegistryCI.AutoMerge
all_pkg_names = AutoMerge.get_all_non_jll_package_names(path_to_registry)
AutoMerge.meets_distance_check("MyPackage", all_pkg_names)
path_to_registry = joinpath(DEPOT_PATH[1], "registries", "General.toml")
all_pkg_names = AutoMerge.get_all_non_jll_package_names(RegistryInstance(path_to_registry))
AutoMerge.meets_distance_check("MyPackage123", all_pkg_names)
```

where `path_to_registry` is a path to the folder containing the registry of
where `path_to_registry` is a path to the registry of
interest. For the General Julia registry, usually `path_to_registry =
joinpath(DEPOT_PATH[1], "registries", "General")` if you haven't changed
your `DEPOT_PATH` and have an extracted version of the Pkg server registry (see JuliaRegistries/RegistryCI.jl#442). This will return a boolean, indicating whether or not
joinpath(DEPOT_PATH[1], "registries", "General.toml")` if you haven't changed
your `DEPOT_PATH` (or `path_to_registry =
joinpath(DEPOT_PATH[1], "registries", "General")` if you have an uncompressed registry at the directory there). This will return a boolean, indicating whether or not
your tentative package name passed the check, as well as a string,
indicating what the problem is in the event the check did not pass.

Expand Down
29 changes: 22 additions & 7 deletions src/AutoMerge/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,32 @@ end

"""
get_all_non_jll_package_names(registry_dir::AbstractString) -> Vector{String}
get_all_non_jll_package_names(registry::RegistryInstance) -> Vector{String}

Given a path to the directory holding a registry, returns the names of all the non-JLL packages
defined in that registry, along with the names of Julia's standard libraries.
Given either:

- a path to a directory holding an uncompressed registry

or

- a `RegistryInstance` object (from [RegistryInstances.jl](https://github.com/GunnarFarneback/RegistryInstances.jl)) associated to a registry,

returns a sorted list of the names of Julia's standard libraries
and all the non-JLL packages defined in that registry.
"""
function get_all_non_jll_package_names(registry_dir::AbstractString)
packages = [
x["name"] for
x in values(TOML.parsefile(joinpath(registry_dir, "Registry.toml"))["packages"])
]
sort!(packages)
# Mimic the structure of a RegistryInstance
list = TOML.parsefile(joinpath(registry_dir, "Registry.toml"))["packages"]
registry = (; pkgs=Dict(k => (; name=v["name"]) for (k,v) in pairs(list)))
return get_all_non_jll_package_names(registry)
end

# Generic method intended for RegistryInstance (without taking on the dependency,
# which is only valid on Julia 1.7+)
function get_all_non_jll_package_names(registry)
packages = [entry.name for entry in values(registry.pkgs)]
append!(packages, (RegistryTools.get_stdlib_name(x) for x in values(RegistryTools.stdlibs())))
sort!(packages)
filter!(x -> !endswith(x, "_jll"), packages)
unique!(packages)
return packages
Expand Down
Loading