Skip to content

Commit 640a2e2

Browse files
Merge pull request #762 from python-discord/raise-static-builds
Static Builds Small Improvements
2 parents 8ab501c + 3335cc6 commit 640a2e2

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

pydis_site/apps/api/github_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from pydis_site import settings
1111

12-
MAX_RUN_TIME = datetime.timedelta(minutes=3)
12+
MAX_RUN_TIME = datetime.timedelta(minutes=10)
1313
"""The maximum time allowed before an action is declared timed out."""
1414
ISO_FORMAT_STRING = "%Y-%m-%dT%H:%M:%SZ"
1515
"""The datetime string format GitHub uses."""

static-builds/netlify_build.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515

1616
import httpx
1717

18+
19+
def raise_response(response: httpx.Response) -> None:
20+
"""Raise an exception from a response if necessary."""
21+
if response.status_code // 100 != 2:
22+
try:
23+
print(response.json())
24+
except json.JSONDecodeError:
25+
pass
26+
27+
response.raise_for_status()
28+
29+
1830
if __name__ == "__main__":
1931
owner, repo = parse.urlparse(os.getenv("REPOSITORY_URL")).path.lstrip("/").split("/")[0:2]
2032

@@ -29,24 +41,18 @@
2941
])
3042
print(f"Fetching download URL from {download_url}")
3143
response = httpx.get(download_url, follow_redirects=True)
32-
33-
if response.status_code // 100 != 2:
34-
try:
35-
print(response.json())
36-
except json.JSONDecodeError:
37-
pass
38-
39-
response.raise_for_status()
44+
raise_response(response)
4045

4146
# The workflow is still pending, retry in a bit
4247
while response.status_code == 202:
4348
print(f"{response.json()['error']}. Retrying in 10 seconds.")
4449
time.sleep(10)
4550
response = httpx.get(download_url, follow_redirects=True)
4651

52+
raise_response(response)
4753
url = response.json()["url"]
4854
print(f"Downloading build from {url}")
49-
zipped_content = httpx.get(url, follow_redirects=True)
55+
zipped_content = httpx.get(url, follow_redirects=True, timeout=3 * 60)
5056
zipped_content.raise_for_status()
5157

5258
zip_file = Path("temp.zip")

0 commit comments

Comments
 (0)