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
@@ -38,6 +38,15 @@ preserves nested and hidden runtime assets, and excludes the same debug files an
|
|||||||
optional workers omitted by packaging. The saved app, platform packages, compact
|
optional workers omitted by packaging. The saved app, platform packages, compact
|
||||||
metadata and validated release artifact all retain 30 days.
|
metadata and validated release artifact all retain 30 days.
|
||||||
|
|
||||||
|
This host runs both Gitea and the runner. The workflows set
|
||||||
|
`CUTDEX_GITEA_INTERNAL_URL=http://127.0.0.1:3000` and override `ACTIONS_RESULTS_URL`
|
||||||
|
on artifact upload/download steps, so those transfers stay on the host instead of
|
||||||
|
looping through the public FRP tunnel. Release API uploads and byte verification
|
||||||
|
also use this loopback endpoint; tooling rewrites only the validated public Gitea
|
||||||
|
origin. The server's public URL remains `https://git.orangraph.com`, and the runner
|
||||||
|
registration is unchanged. These workflow labels require this shared-host layout;
|
||||||
|
configure a reachable private endpoint before using runners on other hosts.
|
||||||
|
|
||||||
Compare warm CI runs after the first cache fill. Measure checks, Android compile,
|
Compare warm CI runs after the first cache fill. Measure checks, Android compile,
|
||||||
Windows compile, packaging and artifact transfer separately. Total duration follows
|
Windows compile, packaging and artifact transfer separately. Total duration follows
|
||||||
the slower platform branch, plus checks and final assembly; no fixed speedup is
|
the slower platform branch, plus checks and final assembly; no fixed speedup is
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ runs:
|
|||||||
id: first
|
id: first
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: https://github.com/actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
uses: https://github.com/actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
||||||
|
env:
|
||||||
|
ACTIONS_RESULTS_URL: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.name }}
|
name: ${{ inputs.name }}
|
||||||
path: ${{ inputs.path }}
|
path: ${{ inputs.path }}
|
||||||
@@ -37,6 +39,8 @@ runs:
|
|||||||
if: ${{ !cancelled() && steps.first.outcome == 'failure' }}
|
if: ${{ !cancelled() && steps.first.outcome == 'failure' }}
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: https://github.com/actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
uses: https://github.com/actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
||||||
|
env:
|
||||||
|
ACTIONS_RESULTS_URL: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.name }}
|
name: ${{ inputs.name }}
|
||||||
path: ${{ inputs.path }}
|
path: ${{ inputs.path }}
|
||||||
@@ -53,6 +57,8 @@ runs:
|
|||||||
id: third
|
id: third
|
||||||
if: ${{ !cancelled() && steps.first.outcome == 'failure' && steps.second.outcome == 'failure' }}
|
if: ${{ !cancelled() && steps.first.outcome == 'failure' && steps.second.outcome == 'failure' }}
|
||||||
uses: https://github.com/actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
uses: https://github.com/actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
||||||
|
env:
|
||||||
|
ACTIONS_RESULTS_URL: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.name }}
|
name: ${{ inputs.name }}
|
||||||
path: ${{ inputs.path }}
|
path: ${{ inputs.path }}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
env:
|
env:
|
||||||
PYTHONUTF8: '1'
|
PYTHONUTF8: '1'
|
||||||
|
CUTDEX_GITEA_INTERNAL_URL: http://127.0.0.1:3000
|
||||||
GIT_CONFIG_COUNT: '2'
|
GIT_CONFIG_COUNT: '2'
|
||||||
GIT_CONFIG_KEY_0: core.autocrlf
|
GIT_CONFIG_KEY_0: core.autocrlf
|
||||||
GIT_CONFIG_VALUE_0: 'false'
|
GIT_CONFIG_VALUE_0: 'false'
|
||||||
@@ -142,6 +143,8 @@ jobs:
|
|||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Download saved Windows app
|
- name: Download saved Windows app
|
||||||
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
||||||
|
env:
|
||||||
|
ACTIONS_RESULTS_URL: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
with:
|
with:
|
||||||
name: cutdex-windows-app
|
name: cutdex-windows-app
|
||||||
path: build/windows/x64/production/runner/Release/
|
path: build/windows/x64/production/runner/Release/
|
||||||
@@ -177,11 +180,15 @@ jobs:
|
|||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Download Android CI artifact
|
- name: Download Android CI artifact
|
||||||
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
||||||
|
env:
|
||||||
|
ACTIONS_RESULTS_URL: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
with:
|
with:
|
||||||
name: cutdex-android-build
|
name: cutdex-android-build
|
||||||
path: build/app/outputs/flutter-apk/
|
path: build/app/outputs/flutter-apk/
|
||||||
- name: Download Windows CI artifact
|
- name: Download Windows CI artifact
|
||||||
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
uses: https://github.com/actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
|
||||||
|
env:
|
||||||
|
ACTIONS_RESULTS_URL: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
with:
|
with:
|
||||||
name: cutdex-windows-build
|
name: cutdex-windows-build
|
||||||
path: .build/windows-packages/
|
path: .build/windows-packages/
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ defaults:
|
|||||||
shell: pwsh
|
shell: pwsh
|
||||||
env:
|
env:
|
||||||
PYTHONUTF8: '1'
|
PYTHONUTF8: '1'
|
||||||
|
CUTDEX_GITEA_INTERNAL_URL: http://127.0.0.1:3000
|
||||||
GIT_CONFIG_COUNT: '2'
|
GIT_CONFIG_COUNT: '2'
|
||||||
GIT_CONFIG_KEY_0: core.autocrlf
|
GIT_CONFIG_KEY_0: core.autocrlf
|
||||||
GIT_CONFIG_VALUE_0: 'false'
|
GIT_CONFIG_VALUE_0: 'false'
|
||||||
|
|||||||
@@ -15,6 +15,19 @@ SERVER = 'https://git.orangraph.com'
|
|||||||
RETRY_DELAYS = (5, 15)
|
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):
|
def transient(error):
|
||||||
if isinstance(error, urllib.error.HTTPError):
|
if isinstance(error, urllib.error.HTTPError):
|
||||||
if error.code == 404 and error.headers.get('Content-Type', '').split(';')[0].lower() == 'text/html':
|
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
|
headers['Content-Type'] = content_type
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
data = json.dumps(data).encode()
|
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:
|
with urllib.request.urlopen(req, timeout=300) as response:
|
||||||
body = response.read()
|
body = response.read()
|
||||||
return json.loads(body) if body and 'application/json' in response.headers.get('Content-Type', '') else body
|
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):
|
def fingerprint(asset):
|
||||||
"""Hash one remote attachment in chunks, keeping memory usage bounded."""
|
"""Hash one remote attachment in chunks, keeping memory usage bounded."""
|
||||||
sha256, sha1, size = hashlib.sha256(), hashlib.sha1(), 0
|
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']})
|
headers={'Authorization': 'token ' + os.environ['GITEA_TOKEN']})
|
||||||
with urllib.request.urlopen(req, timeout=300) as response:
|
with urllib.request.urlopen(req, timeout=300) as response:
|
||||||
while chunk := response.read(1024 * 1024):
|
while chunk := response.read(1024 * 1024):
|
||||||
|
|||||||
@@ -9,6 +9,51 @@ import release_transport as transfers
|
|||||||
|
|
||||||
|
|
||||||
class TransferToolsTests(unittest.TestCase):
|
class TransferToolsTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
environment = patch.dict('os.environ', {'CUTDEX_GITEA_INTERNAL_URL': ''})
|
||||||
|
environment.start()
|
||||||
|
self.addCleanup(environment.stop)
|
||||||
|
|
||||||
|
def test_local_api_transport_preserves_authenticated_request_and_public_identity(self):
|
||||||
|
class Response(io.BytesIO):
|
||||||
|
headers = {'Content-Type': 'application/json'}
|
||||||
|
|
||||||
|
with patch.dict('os.environ', {'CUTDEX_GITEA_INTERNAL_URL': 'http://127.0.0.1:3000/',
|
||||||
|
'GITEA_TOKEN': 'test-token'}), \
|
||||||
|
patch.object(transfers.urllib.request, 'urlopen', return_value=Response(b'{"id":3}')) as open_url:
|
||||||
|
result = transfers.request(transfers.SERVER + '/api/v1/releases?name=a%20b',
|
||||||
|
data=b'package', method='POST', content_type='application/octet-stream')
|
||||||
|
request = open_url.call_args.args[0]
|
||||||
|
self.assertEqual(result, {'id': 3})
|
||||||
|
self.assertEqual(request.full_url, 'http://127.0.0.1:3000/api/v1/releases?name=a%20b')
|
||||||
|
self.assertEqual(request.get_method(), 'POST')
|
||||||
|
self.assertEqual(request.get_header('Authorization'), 'token test-token')
|
||||||
|
self.assertEqual(request.data, b'package')
|
||||||
|
self.assertEqual(transfers.SERVER, 'https://git.orangraph.com')
|
||||||
|
|
||||||
|
def test_local_verification_routes_validated_attachment_without_changing_its_public_url(self):
|
||||||
|
asset = {'browser_download_url': 'https://git.orangraph.com/attachments/example'}
|
||||||
|
with patch.dict('os.environ', {'CUTDEX_GITEA_INTERNAL_URL': 'http://127.0.0.1:3000',
|
||||||
|
'GITEA_TOKEN': 'test-token'}), \
|
||||||
|
patch.object(transfers.urllib.request, 'urlopen', return_value=io.BytesIO(b'app')) as open_url:
|
||||||
|
result = transfers.fingerprint(asset)
|
||||||
|
self.assertEqual(open_url.call_args.args[0].full_url, 'http://127.0.0.1:3000/attachments/example')
|
||||||
|
self.assertEqual(result['sha256'], hashlib.sha256(b'app').hexdigest())
|
||||||
|
self.assertEqual(asset['browser_download_url'], 'https://git.orangraph.com/attachments/example')
|
||||||
|
|
||||||
|
def test_local_transport_rejects_unexpected_endpoint_or_origin_before_sending_credentials(self):
|
||||||
|
for internal, url, message in [
|
||||||
|
('http://example.com:3000', transfers.SERVER + '/api/v1/releases', 'internal Gitea endpoint'),
|
||||||
|
('http://127.0.0.1:3000', 'https://example.com/file', 'transport origin'),
|
||||||
|
('http://127.0.0.1:3000', 'http://git.orangraph.com/file', 'transport origin'),
|
||||||
|
]:
|
||||||
|
with self.subTest(internal=internal, url=url), \
|
||||||
|
patch.dict('os.environ', {'CUTDEX_GITEA_INTERNAL_URL': internal, 'GITEA_TOKEN': 'test-token'}), \
|
||||||
|
patch.object(transfers.urllib.request, 'urlopen') as open_url:
|
||||||
|
with self.assertRaisesRegex(ValueError, message):
|
||||||
|
transfers.request(url)
|
||||||
|
open_url.assert_not_called()
|
||||||
|
|
||||||
def test_frp_tunnel_not_found_page_is_retried_as_a_temporary_failure(self):
|
def test_frp_tunnel_not_found_page_is_retried_as_a_temporary_failure(self):
|
||||||
calls = 0
|
calls = 0
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user