diff --git a/Project.toml b/Project.toml index 57e533c8..90bca45b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "RegistryCI" uuid = "0c95cc5f-2f7e-43fe-82dd-79dbcba86b32" authors = ["Dilum Aluthge ", "Fredrik Ekre ", "contributors"] -version = "7.3.1" +version = "7.4.0" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/src/AutoMerge/guidelines.jl b/src/AutoMerge/guidelines.jl index cd9490d1..d19c8b71 100644 --- a/src/AutoMerge/guidelines.jl +++ b/src/AutoMerge/guidelines.jl @@ -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, ), ) @@ -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) @@ -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" @@ -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, ), ) @@ -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) @@ -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 @@ -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() @@ -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 diff --git a/src/AutoMerge/public.jl b/src/AutoMerge/public.jl index 3508753b..c1024733 100644 --- a/src/AutoMerge/public.jl +++ b/src/AutoMerge/public.jl @@ -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) @@ -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) diff --git a/src/AutoMerge/pull_requests.jl b/src/AutoMerge/pull_requests.jl index 0212024c..6d4bcf8f 100644 --- a/src/AutoMerge/pull_requests.jl +++ b/src/AutoMerge/pull_requests.jl @@ -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) @@ -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) diff --git a/src/AutoMerge/types.jl b/src/AutoMerge/types.jl index 34c37a15..7c95d41e 100644 --- a/src/AutoMerge/types.jl +++ b/src/AutoMerge/types.jl @@ -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.