diff options
author | 2022-08-12 23:49:32 +0200 | |
---|---|---|
committer | 2022-08-12 23:49:32 +0200 | |
commit | 640a2e29b315854e5063dcea96c804a6081f652d (patch) | |
tree | fb84484d575671bb55654ffe57d4923b5ec0ed15 | |
parent | Merge pull request #742 from python-discord/github-artifacts (diff) | |
parent | Increase Timeout For Artifact Download (diff) |
Merge pull request #762 from python-discord/raise-static-builds
Static Builds Small Improvements
-rw-r--r-- | pydis_site/apps/api/github_utils.py | 2 | ||||
-rw-r--r-- | static-builds/netlify_build.py | 24 |
2 files changed, 16 insertions, 10 deletions
diff --git a/pydis_site/apps/api/github_utils.py b/pydis_site/apps/api/github_utils.py index ad24165d..5d7bcdc3 100644 --- a/pydis_site/apps/api/github_utils.py +++ b/pydis_site/apps/api/github_utils.py @@ -9,7 +9,7 @@ import jwt from pydis_site import settings -MAX_RUN_TIME = datetime.timedelta(minutes=3) +MAX_RUN_TIME = datetime.timedelta(minutes=10) """The maximum time allowed before an action is declared timed out.""" ISO_FORMAT_STRING = "%Y-%m-%dT%H:%M:%SZ" """The datetime string format GitHub uses.""" diff --git a/static-builds/netlify_build.py b/static-builds/netlify_build.py index a473bd91..f3a53f72 100644 --- a/static-builds/netlify_build.py +++ b/static-builds/netlify_build.py @@ -15,6 +15,18 @@ from urllib import parse import httpx + +def raise_response(response: httpx.Response) -> None: + """Raise an exception from a response if necessary.""" + if response.status_code // 100 != 2: + try: + print(response.json()) + except json.JSONDecodeError: + pass + + response.raise_for_status() + + if __name__ == "__main__": owner, repo = parse.urlparse(os.getenv("REPOSITORY_URL")).path.lstrip("/").split("/")[0:2] @@ -29,14 +41,7 @@ if __name__ == "__main__": ]) print(f"Fetching download URL from {download_url}") response = httpx.get(download_url, follow_redirects=True) - - if response.status_code // 100 != 2: - try: - print(response.json()) - except json.JSONDecodeError: - pass - - response.raise_for_status() + raise_response(response) # The workflow is still pending, retry in a bit while response.status_code == 202: @@ -44,9 +49,10 @@ if __name__ == "__main__": time.sleep(10) response = httpx.get(download_url, follow_redirects=True) + raise_response(response) url = response.json()["url"] print(f"Downloading build from {url}") - zipped_content = httpx.get(url, follow_redirects=True) + zipped_content = httpx.get(url, follow_redirects=True, timeout=3 * 60) zipped_content.raise_for_status() zip_file = Path("temp.zip") |