Skip to content

Commit

Permalink
Merge branch 'master' into eph/malformed-package-name
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson authored Jun 12, 2024
2 parents 30dceed + eae1bc9 commit e2f52d7
Show file tree
Hide file tree
Showing 38 changed files with 835 additions and 102 deletions.
6 changes: 4 additions & 2 deletions 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.0.1"
version = "10.1.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down Expand Up @@ -34,6 +34,7 @@ LicenseCheck = "0.2"
Pkg = "1"
Printf = "<0.0.1, 1"
Random = "<0.0.1, 1"
ReferenceTests = "0.9, 0.10"
RegistryTools = "2.2"
SHA = "<0.0.1, 0.7, 1"
SimpleMock = "1"
Expand All @@ -52,8 +53,9 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
SimpleMock = "a896ed2c-15a5-4479-b61d-a0e88e2a1d25"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"

[targets]
test = ["Dates", "GitHub", "JSON", "Pkg", "Printf", "SimpleMock", "Test", "TimeZones"]
test = ["Dates", "GitHub", "JSON", "Pkg", "Printf", "SimpleMock", "ReferenceTests", "Test", "TimeZones"]
6 changes: 3 additions & 3 deletions docs/src/private-registries.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ After you have the registry configured, you can setup CI using RegistryCI by fol
You will first need to copy the `.ci` folder in the root of the General registry to the root of your own registry. This folder contains some resources required for the RegistryCI package to work and update itself. If you do not need AutoMerge support, there is no need to copy the
`stopwatch.jl` file in the `.ci` folder.

Next, you will need to copy the `ci.yml` and `update_manifest.yml` workflow files.
Next, you will need to copy the `registry-consistency-ci.yml` and `update_manifest.yml` workflow files.

The `ci.yml` file should be modified as follows if you have packages in your registry that depend on packages in the General registry.
The `registry-consistency-ci.yml` file should be modified as follows if you have packages in your registry that depend on packages in the General registry.
If the packages in your registry depend on packages in other registries, they should also be added to `registry_deps`
```diff
- run: julia --project=.ci/ --color=yes -e 'import RegistryCI; RegistryCI.test()'
Expand Down Expand Up @@ -98,7 +98,7 @@ In that case you will also have to add the following
- run: chmod 400 .ci/Manifest.toml
+ - run: chmod +x .ci/instantiate.sh
```
in `ci.yml` and also `TagBotTriggers.yml` and `automerge.yml` (in which the above appears twice) files if those features are used.
in `registry-consistency-ci.yml` and also `TagBotTriggers.yml` and `automerge.yml` (in which the above appears twice) files if those features are used.

## Author approval workflow support

Expand Down
57 changes: 43 additions & 14 deletions src/AutoMerge/guidelines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function meets_name_ascii(pkg)
end

const guideline_julia_name_check = Guideline(;
info="Name does not include \"julia\" or start with \"Ju\".",
info="Name does not include \"julia\", start with \"Ju\", or end with \"jl\".",
check=data -> meets_julia_name_check(data.pkg),
)

Expand All @@ -254,6 +254,8 @@ function meets_julia_name_check(pkg)
"Lowercase package name $(lowercase(pkg)) contains the string \"julia\"."
elseif startswith(pkg, "Ju")
return false, "Package name starts with \"Ju\"."
elseif endswith(lowercase(pkg), "jl")
return false, "Lowercase package name $(lowercase(pkg)) ends with \"jl\"."
else
return true, ""
end
Expand All @@ -264,6 +266,35 @@ function sqrt_normalized_vd(name1, name2)
return VisualStringDistances.visual_distance(name1, name2; normalize=x -> 5 + sqrt(x))
end

# This check cannot be overridden, since it's important for registry integrity
const guideline_name_match_check = Guideline(;
info = "Name does not match the name of any existing package names (up-to-case)",
docs = "Packages must not match the name of existing package up-to-case, since on case-insensitive filesystems, this will break the registry.",
check=data -> meets_name_match_check(data.pkg, data.registry_master))

function meets_name_match_check(pkg_name::AbstractString, registry_master::AbstractString)
other_packages = get_all_non_jll_package_names(registry_master)
return meets_name_match_check(pkg_name, other_packages)
end

function meets_name_match_check(
pkg_name::AbstractString,
other_packages::Vector;
)
for other_pkg in other_packages
if pkg_name == other_pkg
# We short-circuit in this case; more information doesn't help.
return (false, "Package name already exists in the registry.")
elseif lowercase(pkg_name) == lowercase(other_pkg)
return (false, "Package name matches existing package name $(other_pkg) up-to-case.")
end
end
return (true, "")
end


# This check looks for similar (but not exactly matching) names. It can be
# overridden by a label.
const guideline_distance_check = Guideline(;
info="Name is not too similar to existing package names",
docs="""
Expand Down Expand Up @@ -302,18 +333,9 @@ function meets_distance_check(
)
problem_messages = Tuple{String,Tuple{Float64,Float64,Float64}}[]
for other_pkg in other_packages
if pkg_name == other_pkg
# We short-circuit in this case; more information doesn't help.
return (false, "Package name already exists in the registry.")
elseif lowercase(pkg_name) == lowercase(other_pkg)
# We'll sort this first
push!(
problem_messages,
(
"Package name matches existing package name $(other_pkg) up to case.",
(0, 0, 0),
),
)
if lowercase(pkg_name) == lowercase(other_pkg)
# We handle this case in `meets_name_match_check`
continue
else
msg = ""

Expand Down Expand Up @@ -492,7 +514,7 @@ function _valid_change(old_version::VersionNumber, new_version::VersionNumber)
end

const PACKAGE_AUTHOR_APPROVAL_INSTRUCTIONS = string(
"**If this was not a mistake and you wish to merge this PR anyway,",
"**If this was not a mistake and you wish to merge this PR anyway, ",
"write a comment that says `[merge approved]`.**")

const guideline_sequential_version_number = Guideline(;
Expand Down Expand Up @@ -987,6 +1009,11 @@ function _run_pkg_commands(
pushfirst!(cmd.exec, xvfb)
end
@info(before_message)
@info(string(
"IMPORTANT: If you see any messages of the form \"Error: Some registries failed to update\"",
"or \"registry dirty\", ",
"please disregard those messages. Those messages are normal and do not indicate an error.",
))
cmd_ran_successfully = success(pipeline(cmd; stdout=stdout, stderr=stderr))
cd(original_directory)

Expand Down Expand Up @@ -1042,6 +1069,8 @@ function get_automerge_guidelines(
(guideline_version_can_be_imported, true),
(:update_status, true),
(guideline_dependency_confusion, true),
# this is the non-optional part of name checking
(guideline_name_match_check, true),
# We always run the `guideline_distance_check`
# check last, because if the check fails, it
# prints the list of similar package names in
Expand Down
Loading

0 comments on commit e2f52d7

Please sign in to comment.