优化 Gitea 并行构建、重试与 Windows 更新发布 #5
No files matched your search
@@ -28,6 +28,9 @@ the runner user's `%LOCALAPPDATA%/Cutdex/ci-tools/`. Later builds reuse them aft
|
|||||||
version checks. Python interpreter identity and tool versions isolate the cache,
|
version checks. Python interpreter identity and tool versions isolate the cache,
|
||||||
and a mutex protects installation across concurrent workflows. .NET setup remains
|
and a mutex protects installation across concurrent workflows. .NET setup remains
|
||||||
in the Windows packaging job to provide SDK 10 and the runtime required by `vpk`.
|
in the Windows packaging job to provide SDK 10 and the runtime required by `vpk`.
|
||||||
|
The .NET installation uses the runner user's `Cutdex/ci-tools/dotnet` directory
|
||||||
|
through `DOTNET_INSTALL_DIR` and `DOTNET_ROOT`, so setup needs no administrator
|
||||||
|
access and later jobs reuse the installed SDK and runtime.
|
||||||
The Windows build verifies that the resolved deskup native SDK matches the pinned
|
The Windows build verifies that the resolved deskup native SDK matches the pinned
|
||||||
Velopack version before saving the app. Packaging imports no Flutter package
|
Velopack version before saving the app. Packaging imports no Flutter package
|
||||||
configuration and independently verifies the installed vpk version.
|
configuration and independently verifies the installed vpk version.
|
||||||
|
|||||||
@@ -148,6 +148,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: cutdex-windows-app
|
name: cutdex-windows-app
|
||||||
path: build/windows/x64/production/runner/Release/
|
path: build/windows/x64/production/runner/Release/
|
||||||
|
- name: Configure user .NET installation
|
||||||
|
run: |
|
||||||
|
$directory = Join-Path $env:LOCALAPPDATA 'Cutdex/ci-tools/dotnet'
|
||||||
|
[IO.Directory]::CreateDirectory($directory) | Out-Null
|
||||||
|
"DOTNET_INSTALL_DIR=$directory" | Out-File -LiteralPath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
"DOTNET_ROOT=$directory" | Out-File -LiteralPath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
- name: Set up .NET SDK
|
- name: Set up .NET SDK
|
||||||
uses: https://github.com/actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1
|
uses: https://github.com/actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -53,12 +53,16 @@ def retry_read(operation):
|
|||||||
|
|
||||||
|
|
||||||
def request(url, data=None, method=None, content_type='application/json'):
|
def request(url, data=None, method=None, content_type='application/json'):
|
||||||
|
endpoint = transport_url(url)
|
||||||
headers = {'Authorization': 'token ' + os.environ['GITEA_TOKEN']}
|
headers = {'Authorization': 'token ' + os.environ['GITEA_TOKEN']}
|
||||||
|
if endpoint != url:
|
||||||
|
# Gitea constructs response links from Host, even when reached locally.
|
||||||
|
headers['Host'] = 'git.orangraph.com'
|
||||||
if data is not None:
|
if data is not None:
|
||||||
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(transport_url(url), data=data, headers=headers, method=method)
|
req = urllib.request.Request(endpoint, 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
|
||||||
@@ -74,8 +78,12 @@ 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(transport_url(attachment_url(asset)),
|
url = attachment_url(asset)
|
||||||
headers={'Authorization': 'token ' + os.environ['GITEA_TOKEN']})
|
endpoint = transport_url(url)
|
||||||
|
headers = {'Authorization': 'token ' + os.environ['GITEA_TOKEN']}
|
||||||
|
if endpoint != url:
|
||||||
|
headers['Host'] = 'git.orangraph.com'
|
||||||
|
req = urllib.request.Request(endpoint, headers=headers)
|
||||||
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):
|
||||||
sha256.update(chunk)
|
sha256.update(chunk)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class TransferToolsTests(unittest.TestCase):
|
|||||||
self.assertEqual(request.full_url, 'http://127.0.0.1:3000/api/v1/releases?name=a%20b')
|
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_method(), 'POST')
|
||||||
self.assertEqual(request.get_header('Authorization'), 'token test-token')
|
self.assertEqual(request.get_header('Authorization'), 'token test-token')
|
||||||
|
self.assertEqual(request.get_header('Host'), 'git.orangraph.com')
|
||||||
self.assertEqual(request.data, b'package')
|
self.assertEqual(request.data, b'package')
|
||||||
self.assertEqual(transfers.SERVER, 'https://git.orangraph.com')
|
self.assertEqual(transfers.SERVER, 'https://git.orangraph.com')
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ class TransferToolsTests(unittest.TestCase):
|
|||||||
patch.object(transfers.urllib.request, 'urlopen', return_value=io.BytesIO(b'app')) as open_url:
|
patch.object(transfers.urllib.request, 'urlopen', return_value=io.BytesIO(b'app')) as open_url:
|
||||||
result = transfers.fingerprint(asset)
|
result = transfers.fingerprint(asset)
|
||||||
self.assertEqual(open_url.call_args.args[0].full_url, 'http://127.0.0.1:3000/attachments/example')
|
self.assertEqual(open_url.call_args.args[0].full_url, 'http://127.0.0.1:3000/attachments/example')
|
||||||
|
self.assertEqual(open_url.call_args.args[0].get_header('Host'), 'git.orangraph.com')
|
||||||
self.assertEqual(result['sha256'], hashlib.sha256(b'app').hexdigest())
|
self.assertEqual(result['sha256'], hashlib.sha256(b'app').hexdigest())
|
||||||
self.assertEqual(asset['browser_download_url'], 'https://git.orangraph.com/attachments/example')
|
self.assertEqual(asset['browser_download_url'], 'https://git.orangraph.com/attachments/example')
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user