perf(ci): transfer artifacts locally instead of through FRP
Gitea CI / Check code and tests (pull_request) Successful in 6m9s
Gitea CI / Build Android APK (pull_request) Successful in 3m35s
Gitea CI / Build Windows x64 app (pull_request) Successful in 7m45s
Gitea CI / Audit and package Windows x64 (pull_request) Failing after 1m41s
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Gitea CI passed (pull_request) Failing after 2s
Gitea CI / Check code and tests (pull_request) Successful in 6m9s
Gitea CI / Build Android APK (pull_request) Successful in 3m35s
Gitea CI / Build Windows x64 app (pull_request) Successful in 7m45s
Gitea CI / Audit and package Windows x64 (pull_request) Failing after 1m41s
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Gitea CI passed (pull_request) Failing after 2s
This commit is contained in:
1 parent
e06590dc82
commit
8e523f0e89
6 files changed
+83
-2
No files matched your search
@@ -15,6 +15,19 @@ SERVER = 'https://git.orangraph.com'
|
||||
RETRY_DELAYS = (5, 15)
|
||||
|
||||
|
||||
def transport_url(url):
|
||||
"""Route this host's Gitea traffic locally when the runner opts in."""
|
||||
internal = os.environ.get('CUTDEX_GITEA_INTERNAL_URL', '').rstrip('/')
|
||||
if not internal:
|
||||
return url
|
||||
if internal != 'http://127.0.0.1:3000':
|
||||
raise ValueError('Unexpected internal Gitea endpoint')
|
||||
parsed = urllib.parse.urlparse(url)
|
||||
if parsed.scheme != 'https' or parsed.netloc != 'git.orangraph.com':
|
||||
raise ValueError('Unexpected Gitea transport origin')
|
||||
return urllib.parse.urlunparse(parsed._replace(scheme='http', netloc='127.0.0.1:3000'))
|
||||
|
||||
|
||||
def transient(error):
|
||||
if isinstance(error, urllib.error.HTTPError):
|
||||
if error.code == 404 and error.headers.get('Content-Type', '').split(';')[0].lower() == 'text/html':
|
||||
@@ -45,7 +58,7 @@ def request(url, data=None, method=None, content_type='application/json'):
|
||||
headers['Content-Type'] = content_type
|
||||
if isinstance(data, dict):
|
||||
data = json.dumps(data).encode()
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
req = urllib.request.Request(transport_url(url), data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=300) as response:
|
||||
body = response.read()
|
||||
return json.loads(body) if body and 'application/json' in response.headers.get('Content-Type', '') else body
|
||||
@@ -61,7 +74,7 @@ def attachment_url(asset):
|
||||
def fingerprint(asset):
|
||||
"""Hash one remote attachment in chunks, keeping memory usage bounded."""
|
||||
sha256, sha1, size = hashlib.sha256(), hashlib.sha1(), 0
|
||||
req = urllib.request.Request(attachment_url(asset),
|
||||
req = urllib.request.Request(transport_url(attachment_url(asset)),
|
||||
headers={'Authorization': 'token ' + os.environ['GITEA_TOKEN']})
|
||||
with urllib.request.urlopen(req, timeout=300) as response:
|
||||
while chunk := response.read(1024 * 1024):
|
||||
|
||||
Reference in new issue
Block a user