add retry when updating mediawiki releases

This commit is contained in:
Jörg Thalheim 2024-04-25 10:56:57 +02:00
parent ce500d4ed0
commit e5c9a38a14

View File

@ -5,6 +5,7 @@ import os
import shlex import shlex
import subprocess import subprocess
import sys import sys
import time
import urllib.parse import urllib.parse
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
@ -67,8 +68,17 @@ def mirror_extension(extension_name: str, mediawiki_version: str) -> Extension:
with TemporaryDirectory() as tmpdir: with TemporaryDirectory() as tmpdir:
download_file(download_url.geturl(), f"{tmpdir}/{base_name}") download_file(download_url.geturl(), f"{tmpdir}/{base_name}")
run(["gh", "release", "upload", base_name, f"{tmpdir}/{base_name}"]) run(["gh", "release", "upload", base_name, f"{tmpdir}/{base_name}"])
for i in range(3):
try:
hash = run(["nix-prefetch-url", "--unpack", mirror_url], stdout=subprocess.PIPE).stdout.strip() hash = run(["nix-prefetch-url", "--unpack", mirror_url], stdout=subprocess.PIPE).stdout.strip()
except subprocess.CalledProcessError:
# sometimes github takes a while to make releases available
print("nix-prefetch-url failed, retrying")
time.sleep(i * 5)
continue
else:
return Extension(name=extension_name, hash=hash, url=mirror_url) return Extension(name=extension_name, hash=hash, url=mirror_url)
raise Exception("Failed to fetch extension, see above")
def write_nix_file(file: IO[str], mirrored_extensions: list[Extension]) -> None: def write_nix_file(file: IO[str], mirrored_extensions: list[Extension]) -> None: