generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put the General registry clone inside a bounded retry loop (#31)
Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
- Loading branch information
1 parent
78a53ba
commit 8ff46c6
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 add the General registry") | ||
catch ex | ||
msg = "I was unable to added the General registry. However, the build will continue." | ||
@error(msg, exception=(ex,catch_backtrace())) | ||
end | ||
|
||
return | ||
end | ||
|
||
main() |