retry download on unpack error
Sometimes, the downloaded tar file gets corrupted and fails to unpack. Add a couple retries to avoid spurious CI failures in dependent projs. ``` [2022-12-09T23:17:22.588Z] + ./scripts/setup_scenarios.sh [2022-12-09T23:17:22.588Z] Downloading consensus spec test vectors [2022-12-09T23:17:22.588Z] ~/workspace/atforms_macos_aarch64_dev_etan_y/vendor/nim-eth2-scenarios ~/workspace/atforms_macos_aarch64_dev_etan_y [2022-12-09T23:17:22.588Z] Downloading: v1.2.0/general.tar.gz [2022-12-09T23:17:24.296Z] Downloading: v1.2.0/minimal.tar.gz [2022-12-09T23:17:29.150Z] Downloading: v1.2.0/mainnet.tar.gz [2022-12-09T23:17:30.331Z] Unpacking: v1.2.0/general.tar.gz [2022-12-09T23:17:30.671Z] Unpacking: v1.2.0/minimal.tar.gz [2022-12-09T23:17:36.665Z] Unpacking: v1.2.0/mainnet.tar.gz [2022-12-09T23:17:36.665Z] tar: Error opening archive: Unrecognized archive format [2022-12-09T23:17:36.665Z] Tar failed. Aborting. script returned exit code 1 ```
This commit is contained in:
parent
5163f18ae2
commit
9e23fbeba9
|
@ -47,12 +47,15 @@ unpack_version() {
|
|||
[[ -z "$1" ]] && { echo "usage: unpack_version() vX.Y.Z"; exit 1; }
|
||||
version="$1"
|
||||
|
||||
local retries=0 ok=0
|
||||
while (( !ok && ++retries <= 5 )); do # downloaded tar.gz may be corrupted
|
||||
dl_version "$version"
|
||||
|
||||
# suppress warnings when unpacking with GNU tar an archive created with BSD tar (probably on macOS)
|
||||
EXTRA_TAR_PARAMS=""
|
||||
tar --version | grep -qi 'gnu' && EXTRA_TAR_PARAMS="--warning=no-unknown-keyword --ignore-zeros"
|
||||
|
||||
ok=1
|
||||
if [[ ! -d "tests-${version}" ]]; then
|
||||
for flavour in "${FLAVOURS[@]}"; do
|
||||
echo "Unpacking: ${version}/${flavour}.tar.gz"
|
||||
|
@ -60,12 +63,16 @@ unpack_version() {
|
|||
tar -C "tests-${version}" --strip-components 1 ${EXTRA_TAR_PARAMS} --exclude=phase1 -xzf \
|
||||
"tarballs/${version}/${flavour}.tar.gz" \
|
||||
|| {
|
||||
echo "Tar failed. Aborting."
|
||||
rm -rf "tests-${version}"
|
||||
exit 1
|
||||
rm -rf "tests-${version}" "tarballs/${version}/${flavour}.tar.gz"
|
||||
ok=0
|
||||
}
|
||||
done
|
||||
fi
|
||||
done
|
||||
if (( !ok )); then
|
||||
echo "Unpacking test vectors failed too often. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# download and unpack
|
||||
|
|
Loading…
Reference in New Issue