Skip to content

Commit

Permalink
support RegistryInstance in get_all_non_jll_package_names (#568)
Browse files Browse the repository at this point in the history
* support compressed registry in `get_all_non_jll_package_names`

* up

* switch approach, don't add dep

* fix projects

* update docstring

* up

* don't unpack on docs build

* try to fix docs

* use pkgserver
  • Loading branch information
ericphanson committed Jul 9, 2024
1 parent c93ebce commit 24eae8b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
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

2 comments on commit 24eae8b

@ericphanson
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/110752

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v10.6.0 -m "<description of version>" 24eae8b454767837f365e225f3a09312346f6582
git push origin v10.6.0

Please sign in to comment.