mirror of
https://github.com/julia-actions/julia-buildpkg.git
synced 2026-02-12 01:16:54 +08:00
Put the General registry clone inside a bounded retry loop (#13)
Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
This commit is contained in:
@@ -17,7 +17,7 @@ runs:
|
|||||||
# * https://github.com/JuliaLang/Pkg.jl/issues/2011
|
# * https://github.com/JuliaLang/Pkg.jl/issues/2011
|
||||||
# * https://github.com/JuliaRegistries/General/issues/16777
|
# * https://github.com/JuliaRegistries/General/issues/16777
|
||||||
# * https://github.com/JuliaPackaging/PkgServer.jl/issues/60
|
# * https://github.com/JuliaPackaging/PkgServer.jl/issues/60
|
||||||
- run: julia --color=yes -e 'using Pkg; VERSION >= v"1.5-" && !isdir(joinpath(DEPOT_PATH[1], "registries", "General")) && Pkg.Registry.add("General")'
|
- run: julia --color=yes "$GITHUB_ACTION_PATH"/add_general_registry.jl
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
# We set `JULIA_PKG_SERVER` only for this step to enforce
|
# We set `JULIA_PKG_SERVER` only for this step to enforce
|
||||||
@@ -25,5 +25,6 @@ runs:
|
|||||||
# the request metadata to pkg.julialang.org when installing
|
# the request metadata to pkg.julialang.org when installing
|
||||||
# packages via `Pkg.test`.
|
# packages via `Pkg.test`.
|
||||||
JULIA_PKG_SERVER: ""
|
JULIA_PKG_SERVER: ""
|
||||||
|
|
||||||
- run: julia --color=yes --project -e 'using Pkg; if VERSION >= v"1.1.0-rc1"; Pkg.build(verbose=true); else Pkg.build(); end'
|
- run: julia --color=yes --project -e 'using Pkg; if VERSION >= v"1.1.0-rc1"; Pkg.build(verbose=true); else Pkg.build(); end'
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
49
add_general_registry.jl
Normal file
49
add_general_registry.jl
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using Pkg
|
||||||
|
|
||||||
|
function general_registry_location()
|
||||||
|
general_registry_dir = joinpath(DEPOT_PATH[1], "registries", "General")
|
||||||
|
registry_toml_file = joinpath(general_registry_dir, "Registry.toml")
|
||||||
|
return general_registry_dir, registry_toml_file
|
||||||
|
end
|
||||||
|
|
||||||
|
function general_registry_exists()
|
||||||
|
general_registry_dir, registry_toml_file = general_registry_location()
|
||||||
|
if !isdir(general_registry_dir)
|
||||||
|
return false
|
||||||
|
elseif !isfile(registry_toml_file)
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function add_general_registry()
|
||||||
|
@info("Attempting to clone the General registry")
|
||||||
|
general_registry_dir, registry_toml_file = general_registry_location()
|
||||||
|
rm(general_registry_dir; force = true, recursive = true)
|
||||||
|
Pkg.Registry.add("General")
|
||||||
|
isfile(registry_toml_file) || throw(ErrorException("the Registry.toml file does not exist"))
|
||||||
|
return nothing
|
||||||
|
end
|
||||||
|
|
||||||
|
function main(; n = 10, max_delay = 120)
|
||||||
|
VERSION >= v"1.5-" || return
|
||||||
|
|
||||||
|
if general_registry_exists()
|
||||||
|
@info("The General registry already exists locally")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
delays = ExponentialBackOff(; n = n, max_delay = max_delay)
|
||||||
|
try
|
||||||
|
retry(add_general_registry; delays = delays)()
|
||||||
|
@info("Successfully added the General registry")
|
||||||
|
catch ex
|
||||||
|
msg = "I was unable to add the General registry. However, the build will continue."
|
||||||
|
@error(msg, exception=(ex,catch_backtrace()))
|
||||||
|
end
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user