Skip to content

Commit

Permalink
Merge #452
Browse files Browse the repository at this point in the history
452: Add the ability for registry maintainers to pass additional environment variables to the sub-processes that run `Pkg.add("Foo")` and `import Foo` r=DilumAluthge a=DilumAluthge



Co-authored-by: Dilum Aluthge <[email protected]>
  • Loading branch information
bors[bot] and DilumAluthge authored Aug 2, 2022
2 parents 583e2bd + acb80a8 commit 05d18ea
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
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 = "7.3.1"
version = "7.4.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
42 changes: 37 additions & 5 deletions src/AutoMerge/guidelines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,11 @@ const guideline_version_can_be_pkg_added = Guideline(;
info="Version can be `Pkg.add`ed",
docs="Package installation: The package should be installable (`Pkg.add(\"PackageName\")`).",
check=data -> meets_version_can_be_pkg_added(
data.registry_head, data.pkg, data.version; registry_deps=data.registry_deps
data.registry_head,
data.pkg,
data.version;
registry_deps=data.registry_deps,
environment_variables_to_pass=data.environment_variables_to_pass,
),
)

Expand All @@ -609,6 +613,7 @@ function meets_version_can_be_pkg_added(
pkg::String,
version::VersionNumber;
registry_deps::Vector{<:AbstractString}=String[],
environment_variables_to_pass::Vector{String},
)
pkg_add_command = _generate_pkg_add_command(pkg, version)
_registry_deps = convert(Vector{String}, registry_deps)
Expand Down Expand Up @@ -637,6 +642,7 @@ function meets_version_can_be_pkg_added(
version;
code=code,
before_message="Attempting to `Pkg.add` the package",
environment_variables_to_pass=environment_variables_to_pass,
)
if cmd_ran_successfully
@info "Successfully `Pkg.add`ed the package"
Expand Down Expand Up @@ -725,7 +731,11 @@ const guideline_version_can_be_imported = Guideline(;
info="Version can be `import`ed",
docs="Package loading: The package should be loadable (`import PackageName`).",
check=data -> meets_version_can_be_imported(
data.registry_head, data.pkg, data.version; registry_deps=data.registry_deps
data.registry_head,
data.pkg,
data.version;
registry_deps=data.registry_deps,
environment_variables_to_pass=data.environment_variables_to_pass,
),
)

Expand All @@ -734,6 +744,7 @@ function meets_version_can_be_imported(
pkg::String,
version::VersionNumber;
registry_deps::Vector{<:AbstractString}=String[],
environment_variables_to_pass::Vector{String},
)
pkg_add_command = _generate_pkg_add_command(pkg, version)
_registry_deps = convert(Vector{String}, registry_deps)
Expand Down Expand Up @@ -766,6 +777,7 @@ function meets_version_can_be_imported(
version;
code=code,
before_message="Attempting to `import` the package",
environment_variables_to_pass=environment_variables_to_pass,
)

if cmd_ran_successfully
Expand All @@ -783,7 +795,12 @@ function meets_version_can_be_imported(
end

function _run_pkg_commands(
working_directory::String, pkg::String, version::VersionNumber; code, before_message
working_directory::String,
pkg::String,
version::VersionNumber;
code,
before_message,
environment_variables_to_pass::Vector{String},
)
original_directory = pwd()
tmp_dir_1 = mktempdir()
Expand All @@ -808,15 +825,30 @@ function _run_pkg_commands(
# Python.
# 8. R_HOME. We set R_HOME to "*".
# 9. HOME. Lots of things need HOME.
#
# If registry maintainers need additional environment variables to be passed
# to the child process, they can do so by providing the `environment_variables_to_pass`
# kwarg to the `AutoMerge.run` function.

env = Dict(
"JULIA_DEPOT_PATH" => mktempdir(),
"JULIA_PKG_PRECOMPILE_AUTO" => "0",
"JULIA_REGISTRYCI_AUTOMERGE" => "true",
"PYTHON" => "",
"R_HOME" => "*",
"JULIA_PKG_PRECOMPILE_AUTO" => "0",
)
for k in ("HOME", "PATH", "HTTP_PROXY", "HTTPS_PROXY", "JULIA_PKG_SERVER")
default_environment_variables_to_pass = [
"HOME",
"JULIA_PKG_SERVER",
"PATH",
"HTTP_PROXY",
"HTTPS_PROXY",
]
all_environment_variables_to_pass = vcat(
default_environment_variables_to_pass,
environment_variables_to_pass,
)
for k in all_environment_variables_to_pass
if haskey(ENV, k)
env[k] = ENV[k]
end
Expand Down
2 changes: 2 additions & 0 deletions src/AutoMerge/public.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function run(;
# the `dependency_confusion.jl` file for details.
public_registries::Vector{<:AbstractString}=String[],
read_only::Bool=false,
environment_variables_to_pass::Vector{<:AbstractString}=String[],
)::Nothing
all_statuses = deepcopy(additional_statuses)
all_check_runs = deepcopy(additional_check_runs)
Expand Down Expand Up @@ -155,6 +156,7 @@ function run(;
check_license=check_license,
public_registries=public_registries,
read_only=read_only,
environment_variables_to_pass=environment_variables_to_pass,
)
else
always_assert(run_merge_build)
Expand Down
2 changes: 2 additions & 0 deletions src/AutoMerge/pull_requests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function pull_request_build(
check_license::Bool,
public_registries::Vector{<:AbstractString}=String[],
read_only::Bool,
environment_variables_to_pass::Vector{<:AbstractString}=String[],
)::Nothing
pr = my_retry(() -> GitHub.pull_request(api, registry, pr_number; auth=auth))
_github_api_pr_head_commit_sha = pull_request_head_sha(pr)
Expand Down Expand Up @@ -158,6 +159,7 @@ function pull_request_build(
registry_deps=registry_deps,
public_registries=public_registries,
read_only=read_only,
environment_variables_to_pass=environment_variables_to_pass,
)
pull_request_build(data; check_license=check_license)
rm(registry_master; force=true, recursive=true)
Expand Down
3 changes: 3 additions & 0 deletions src/AutoMerge/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ struct GitHubAutoMergeData

# whether only read-only actions should be taken
read_only::Bool

# Environment variables to pass to the subprocess that does `Pkg.add("Foo")` and `import Foo`
environment_variables_to_pass::Vector{String}
end

# Constructor that requires all fields (except `pkg_code_path`) as named arguments.
Expand Down

2 comments on commit 05d18ea

@DilumAluthge
Copy link
Member

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/65471

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 v7.4.0 -m "<description of version>" 05d18eace0b944591e2cac5090cbda1b49cb1efd
git push origin v7.4.0

Please sign in to comment.