12 changed files with 323 additions and 69 deletions

No files matched your search

+10 -1
View File
@@ -77,7 +77,11 @@ Android and Windows independently download their platform artifacts from the
selected CI run and immediately upload them to the draft. These jobs run in
parallel. The final job accepts only the compact metadata artifact from that same
CI run. Complete binary archives cannot substitute for platform packages or
metadata. Missing, expired or duplicate required artifacts block preparation
metadata. Gitea can retain old artifact API rows after a job rerun despite overwrite.
Selection requires the exact CI run and source commit, and exactly one artifact
created within its current successful producer job's execution interval. Jobs
preserved during a partial rerun retain their original intervals and artifacts.
Missing, expired or ambiguous artifacts in that interval block preparation
before any draft is created. Platform uploads check attachment presence without
reading back their bytes. Before publication, every attachment is read back once
and verified against trusted SHA256 checksums; the full update package also
@@ -94,6 +98,11 @@ operator attention. Published Releases are never overwritten. The built-in
GITEA_TOKEN handles release writes and Actions artifact reads; no separate
release-write PAT is required. Do not commit credentials or keystores.
Release tools are checked out at the workflow's exact commit; tagged application
source is checked out separately in `.release-source`. A manual dispatch on main
can therefore apply a reviewed release-tool fix to an existing tag without moving
that tag or substituting another application's version or CI artifacts.
Full-pipeline CI produces Actions artifacts without creating Releases. If a tag is pushed
before main CI succeeds, release preparation fails without creating a draft; retry
the Release workflow once CI has finished. This design overlaps platform uploads,
+37 -8
View File
@@ -24,6 +24,7 @@ env:
GIT_CONFIG_VALUE_0: 'false'
GIT_CONFIG_KEY_1: core.eol
GIT_CONFIG_VALUE_1: lf
RELEASE_PUBSPEC: .release-source/pubspec.yaml
RELEASE_TAG: ${{ gitea.event.inputs.tag || gitea.ref_name }}
GITEA_REPOSITORY: ${{ gitea.repository }}
jobs:
@@ -40,16 +41,23 @@ jobs:
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
steps:
- name: Check out release tag
- name: Check out pinned release tools
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ gitea.sha }}
persist-credentials: false
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
- name: Check out release source separately
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ gitea.event.inputs.tag || gitea.ref_name }}
path: .release-source
persist-credentials: false
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
- name: Select successful CI and prepare draft
id: draft
run: |
$env:GITEA_SHA = git rev-parse HEAD
$env:GITEA_SHA = git -C .release-source rev-parse HEAD
if ($LASTEXITCODE -ne 0) { throw 'Release source resolution failed.' }
python tool/gitea/stage-release.py prepare-ci
if ($LASTEXITCODE -ne 0) { throw 'CI selection or draft preparation failed.' }
@@ -65,10 +73,17 @@ jobs:
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.android-artifact-id }}
steps:
- name: Check out release commit
- name: Check out pinned release tools
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ needs.prepare.outputs.sha }}
ref: ${{ gitea.sha }}
persist-credentials: false
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
- name: Check out release source separately
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ gitea.event.inputs.tag || gitea.ref_name }}
path: .release-source
persist-credentials: false
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
- name: Download Android CI artifact
@@ -91,10 +106,17 @@ jobs:
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.windows-artifact-id }}
steps:
- name: Check out release commit
- name: Check out pinned release tools
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ needs.prepare.outputs.sha }}
ref: ${{ gitea.sha }}
persist-credentials: false
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
- name: Check out release source separately
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ gitea.event.inputs.tag || gitea.ref_name }}
path: .release-source
persist-credentials: false
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
- name: Download Windows CI artifact
@@ -117,10 +139,17 @@ jobs:
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.artifact-id }}
steps:
- name: Check out release commit
- name: Check out pinned release tools
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ needs.prepare.outputs.sha }}
ref: ${{ gitea.sha }}
persist-credentials: false
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
- name: Check out release source separately
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: ${{ gitea.event.inputs.tag || gitea.ref_name }}
path: .release-source
persist-credentials: false
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
- name: Download release verification metadata
+1
View File
@@ -108,3 +108,4 @@ pubspec_overrides.yaml
# Core and native source checkouts prepared by CI or local development.
.dependencies/
.release-source/
+124 -36
View File
@@ -22,6 +22,12 @@ import 'package:flutter_test/flutter_test.dart';
class _Model implements ModelAdapter {
final requests = <ModelRequest>[];
final streams = <StreamController<ModelEvent>>[];
final _requestWaiters = <int, Completer<void>>{};
Future<void> waitForRequests(int count) {
if (requests.length >= count) return Future<void>.value();
return _requestWaiters.putIfAbsent(count, Completer<void>.new).future;
}
@override
Stream<ModelEvent> stream(
@@ -31,6 +37,9 @@ class _Model implements ModelAdapter {
requests.add(request);
final stream = StreamController<ModelEvent>();
streams.add(stream);
for (final count in _requestWaiters.keys.toList()) {
if (requests.length >= count) _requestWaiters.remove(count)!.complete();
}
unawaited(cancellation.whenCancelled.then((_) => stream.close()));
return stream.stream;
}
@@ -82,12 +91,46 @@ class _DelayedRestoreConversation extends AgentConversationService {
}
}
Future<void> _until(bool Function() check) async {
for (var attempt = 0; attempt < 1000; attempt++) {
if (check()) return;
await Future<void>.delayed(const Duration(milliseconds: 1));
Future<void> _waitForRequests(
ProviderContainer container,
ChatControllerProvider provider,
_Model model,
int count,
) async {
if (model.requests.length >= count) return;
final settled = Completer<void>();
void onState(ChatState state) {
if (!state.busy && model.requests.length < count && !settled.isCompleted) {
settled.completeError(
TestFailure('Send settled before model request $count: ${state.error}'),
);
}
}
final subscription = container.listen(provider, (_, state) => onState(state));
onState(container.read(provider));
try {
await Future.any([model.waitForRequests(count), settled.future]);
} finally {
subscription.close();
}
}
Future<void> _waitForState(
ProviderContainer container,
ChatControllerProvider provider,
bool Function(ChatState) check,
) async {
if (check(container.read(provider))) return;
final ready = Completer<void>();
final subscription = container.listen(provider, (_, state) {
if (check(state) && !ready.isCompleted) ready.complete();
});
try {
await ready.future;
} finally {
subscription.close();
}
fail('Expected state was not reached');
}
void main() {
@@ -95,6 +138,7 @@ void main() {
late Directory conversationsRoot;
late ConversationRepository conversationRepository;
late ProviderContainer container;
late AgentConversationRegistry registry;
setUp(() async {
model = _Model();
conversationsRoot = await Directory.systemTemp.createTemp('chat-test-');
@@ -131,8 +175,11 @@ void main() {
),
],
);
registry = container.read(agentConversationRegistryProvider);
});
tearDown(() async {
// Disposal initiates cancellation, but files remain open until the run settles.
await registry.cancelAll();
container.dispose();
await conversationsRoot.delete(recursive: true);
});
@@ -391,7 +438,12 @@ void main() {
);
await tester.runAsync(() async {
await tester.tap(find.byTooltip('发送消息'));
await _until(() => model.requests.isNotEmpty);
await _waitForRequests(
container,
chatControllerProvider('lib'),
model,
1,
);
});
await tester.pumpAndSettle();
expect(model.requests.single.messages.single.text, '测试发送');
@@ -461,11 +513,10 @@ void main() {
);
await tester.runAsync(() async {
model.streams.single.add(const TextDelta('正在生成的内容'));
await _until(
() => container
.read(chatControllerProvider('lib'))
.partialResponse
.isNotEmpty,
await _waitForState(
container,
chatControllerProvider('lib'),
(state) => state.partialResponse.isNotEmpty,
);
});
await tester.pumpAndSettle();
@@ -473,7 +524,11 @@ void main() {
await tester.runAsync(() async {
await tester.tap(find.byTooltip('停止回复'));
await container.read(chatControllerProvider('lib').notifier).stop();
await _until(() => !container.read(chatControllerProvider('lib')).busy);
await _waitForState(
container,
chatControllerProvider('lib'),
(state) => !state.busy,
);
});
await tester.pumpAndSettle();
expect(find.text('回复已中断'), findsOneWidget);
@@ -514,7 +569,11 @@ void main() {
addTearDown(subscription.close);
await tester.pump();
await tester.runAsync(
() => _until(() => isolated.read(provider).messages.length == 2),
() => _waitForState(
isolated,
provider,
(state) => state.messages.length == 2,
),
);
final controller = isolated.read(provider.notifier);
expect(isolated.read(provider).messages.last.elapsedMs, 23000);
@@ -621,7 +680,12 @@ void main() {
await tester.pump();
await tester.runAsync(() async {
await tester.tap(find.byTooltip('发送消息'));
await _until(() => model.streams.isNotEmpty);
await _waitForRequests(
container,
chatControllerProvider('project'),
model,
1,
);
});
await tester.pump();
expect(find.byKey(const Key('test-project-selector')), findsNothing);
@@ -629,8 +693,10 @@ void main() {
await tester.runAsync(() async {
model.streams.single.add(ModelResponse(text: '已经开始'));
await model.streams.single.close();
await _until(
() => !container.read(chatControllerProvider('project')).busy,
await _waitForState(
container,
chatControllerProvider('project'),
(state) => !state.busy,
);
});
await tester.pumpAndSettle();
@@ -697,7 +763,12 @@ void main() {
);
await tester.runAsync(() async {
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await _until(() => model.requests.isNotEmpty);
await _waitForRequests(
container,
chatControllerProvider('lib'),
model,
1,
);
});
await tester.pumpAndSettle();
expect(
@@ -709,7 +780,11 @@ void main() {
await tester.runAsync(() async {
model.streams.single.add(ModelResponse(text: 'ok'));
await model.streams.single.close();
await _until(() => !container.read(chatControllerProvider('lib')).busy);
await _waitForState(
container,
chatControllerProvider('lib'),
(state) => !state.busy,
);
});
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
@@ -725,11 +800,15 @@ void main() {
addTearDown(subscription.close);
final controller = container.read(provider.notifier);
final sending = controller.send('你好', timelineId: 'first');
await _until(() => model.streams.isNotEmpty);
await _waitForRequests(container, provider, model, 1);
await controller.send('重复', timelineId: 'first');
expect(model.requests, hasLength(1));
model.streams[0].add(const TextDelta('你好呀'));
await _until(() => container.read(provider).partialResponse == '你好呀');
await _waitForState(
container,
provider,
(state) => state.partialResponse == '你好呀',
);
expect(container.read(provider).busy, isTrue);
model.streams[0].add(ModelResponse(text: '你好呀!'));
await model.streams[0].close();
@@ -738,7 +817,7 @@ void main() {
expect(container.read(provider).partialResponse, isEmpty);
final second = controller.send('接着说', timelineId: 'second');
await _until(() => model.requests.length == 2);
await _waitForRequests(container, provider, model, 2);
expect(model.requests[1].messages.map((m) => m.text), [
'你好',
'你好呀!',
@@ -758,7 +837,7 @@ void main() {
final other = container
.read(otherProvider.notifier)
.send('新会话', timelineId: 'timeline');
await _until(() => model.requests.length == 3);
await _waitForRequests(container, otherProvider, model, 3);
expect(model.requests.last.messages.map((m) => m.text), ['新会话']);
model.streams[2].add(ModelResponse(text: '新回答'));
await model.streams[2].close();
@@ -773,16 +852,20 @@ void main() {
addTearDown(subscription.close);
final controller = container.read(provider.notifier);
final sending = controller.send('开始', timelineId: 'timeline');
await _until(() => model.streams.isNotEmpty);
await _waitForRequests(container, provider, model, 1);
model.streams[0].add(const TextDelta('部分回复'));
await _until(() => container.read(provider).partialResponse.isNotEmpty);
await _waitForState(
container,
provider,
(state) => state.partialResponse.isNotEmpty,
);
controller.stop();
await sending;
expect(container.read(provider).busy, isFalse);
expect(container.read(provider).messages.last.text, '部分回复');
expect(container.read(provider).messages.last.interrupted, isTrue);
final next = controller.send('再来', timelineId: 'timeline');
await _until(() => model.streams.length == 2);
await _waitForRequests(container, provider, model, 2);
model.streams[1].add(ModelResponse(text: '完成'));
await model.streams[1].close();
await next;
@@ -805,14 +888,14 @@ void main() {
final first = container
.read(firstProvider.notifier)
.send('第一条', timelineId: 'timeline');
await _until(() => model.streams.length == 1);
await _waitForRequests(container, firstProvider, model, 1);
model.streams[0].add(ModelResponse(text: '第一答'));
await model.streams[0].close();
await first;
final second = container
.read(secondProvider.notifier)
.send('第二条', timelineId: 'timeline');
await _until(() => model.streams.length == 2);
await _waitForRequests(container, secondProvider, model, 2);
expect(model.requests[1].messages.map((message) => message.text), ['第二条']);
model.streams[1].add(ModelResponse(text: '第二答'));
await model.streams[1].close();
@@ -835,7 +918,7 @@ void main() {
final first = container
.read(provider.notifier)
.send('保留这段对话', timelineId: 'timeline');
await _until(() => model.streams.isNotEmpty);
await _waitForRequests(container, provider, model, 1);
model.streams.single.add(ModelResponse(text: '已经保存'));
await model.streams.single.close();
await first;
@@ -877,13 +960,18 @@ void main() {
),
],
);
registry = container.read(agentConversationRegistryProvider);
final restoredProvider = chatControllerProvider(
'project',
conversationId: conversationId,
);
subscription = container.listen(restoredProvider, (_, _) {});
addTearDown(subscription.close);
await _until(() => container.read(restoredProvider).messages.length == 2);
await _waitForState(
container,
restoredProvider,
(state) => state.messages.length == 2,
);
expect(
container
.read(restoredProvider)
@@ -895,7 +983,7 @@ void main() {
final continued = container
.read(restoredProvider.notifier)
.send('继续', timelineId: 'timeline');
await _until(() => model.requests.length == 2);
await _waitForRequests(container, restoredProvider, model, 2);
expect(model.requests.last.messages.map((message) => message.text), [
'保留这段对话',
'已经保存',
@@ -949,7 +1037,7 @@ void main() {
final first = switchingContainer
.read(provider.notifier)
.send('旧会话', timelineId: 'timeline');
await _until(() => firstModel.streams.isNotEmpty);
await _waitForRequests(switchingContainer, provider, firstModel, 1);
firstModel.streams.single.add(ModelResponse(text: '旧回答'));
await firstModel.streams.single.close();
await first;
@@ -964,7 +1052,7 @@ void main() {
final second = switchingContainer
.read(provider.notifier)
.send('继续会话', timelineId: 'timeline');
await _until(() => firstModel.streams.length == 2);
await _waitForRequests(switchingContainer, provider, firstModel, 2);
expect(firstModel.requests.last.messages.map((message) => message.text), [
'旧会话',
'旧回答',
@@ -1004,7 +1092,7 @@ void main() {
final sending = container
.read(provider.notifier)
.send('hello', timelineId: 'timeline');
await _until(() => model.streams.isNotEmpty);
await _waitForRequests(container, provider, model, 1);
model.streams.single.addError(entry.key);
await model.streams.single.close();
await sending;
@@ -1018,7 +1106,7 @@ void main() {
addTearDown(subscription.close);
final controller = container.read(provider.notifier);
final sending = controller.send('开始', timelineId: 'timeline');
await _until(() => model.streams.isNotEmpty);
await _waitForRequests(container, provider, model, 1);
model.streams[0].addError(StateError('sensitive remote payload'));
await model.streams[0].close();
await sending;
@@ -1032,7 +1120,7 @@ void main() {
['开始'],
);
final next = controller.send('重试', timelineId: 'timeline');
await _until(() => model.streams.length == 2);
await _waitForRequests(container, provider, model, 2);
model.streams[1].add(ModelResponse(text: '成功'));
await model.streams[1].close();
await next;
@@ -1048,7 +1136,7 @@ void main() {
await early;
expect(container.read(provider).busy, isFalse);
final later = controller.send('再次开始', timelineId: 'timeline');
await _until(() => model.streams.isNotEmpty);
await _waitForRequests(container, provider, model, 1);
subscription.close();
container.dispose();
await later;
+66 -11
View File
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
@@ -14,20 +15,20 @@ const _generatedFiles = [
];
void main() {
test('workspace generated code is up to date', () async {
test(
'workspace generated code is up to date',
() async {
await _expectNoUntrackedGeneratedFiles();
final before = await _generatedContents();
final dart = flutterTestDartExecutable();
final elapsed = Stopwatch()..start();
for (final directory in _generatorRoots()) {
final result = await Process.run(dart, [
'run',
'build_runner',
'build',
], workingDirectory: directory);
expect(
result.exitCode,
0,
reason: '$directory\n${result.stdout}\n${result.stderr}',
await _generate(
dart,
directory,
const Duration(minutes: 5) -
const Duration(seconds: 10) -
elapsed.elapsed,
);
}
expect(
@@ -36,7 +37,61 @@ void main() {
reason: 'Generated files changed. Run dart run build_runner build and review the output.',
);
await _expectNoUntrackedGeneratedFiles();
}, timeout: const Timeout(Duration(minutes: 5)));
},
timeout: const Timeout(Duration(minutes: 5)),
tags: ['codegen'],
);
}
Future<void> _generate(
String dart,
String directory,
Duration remaining,
) async {
if (remaining <= Duration.zero) {
throw TimeoutException('Generated-code verification budget exhausted');
}
final elapsed = Stopwatch()..start();
stdout.writeln(
'Generating $directory; remaining budget: ${remaining.inSeconds}s',
);
final process = await Process.start(dart, [
'run',
'build_runner',
'build',
], workingDirectory: directory);
final output = StringBuffer();
Future<void> read(Stream<List<int>> stream) async {
await for (final line
in stream.transform(utf8.decoder).transform(const LineSplitter())) {
output.writeln(line);
stdout.writeln('[$directory] $line');
}
}
final streams = Future.wait([read(process.stdout), read(process.stderr)]);
var exited = false;
try {
final exitCode = await process.exitCode.timeout(remaining);
exited = true;
await streams;
expect(exitCode, 0, reason: '$directory\n$output');
} finally {
if (!exited) {
// Flutter's outer test timeout cannot terminate Process.run children.
// End the generator before leaving the test, including on Windows.
if (Platform.isWindows) {
await Process.run('taskkill', ['/PID', '${process.pid}', '/T', '/F']);
} else {
process.kill(ProcessSignal.sigkill);
}
await process.exitCode;
await streams;
}
stdout.writeln(
'Generation $directory ended after ${elapsed.elapsed.inMilliseconds}ms',
);
}
}
Future<void> _expectNoUntrackedGeneratedFiles() async {
+6 -1
View File
@@ -45,7 +45,12 @@ def check_analyze():
def check_flutter():
package_tests = sorted(str(path.relative_to(ROOT)) for pattern in ('*/test', '*/example/test')
for path in (ROOT / 'packages').glob(pattern))
run(tool_command('flutter', ['test', '--reporter', 'expanded', 'test', *package_tests]))
run(tool_command('flutter', ['test', '--reporter', 'expanded', '--exclude-tags', 'codegen',
'test', *package_tests]))
# build_runner compiles generators and performs repository-wide file I/O.
# Keep this gate serial with widget tests to avoid competing with their isolates.
run(tool_command('flutter', ['test', '--reporter', 'expanded', '--tags', 'codegen',
'test/generated_code_test.dart']))
def main():
+2 -5
View File
@@ -13,7 +13,7 @@ import tempfile
import zipfile
from read_dependencies import ROOT, validate_pins
from release_transport import SERVER, request
from release_transport import SERVER, attachment_url, request
def verify_archive(data, pins):
@@ -94,10 +94,7 @@ def release_archive(pins):
assets = [asset for asset in release['assets'] if asset['name'] == core['artifact']['file']]
if len(assets) != 1:
raise ValueError('Expected exactly one Core release source archive.')
url = assets[0]['browser_download_url']
if not url.startswith(SERVER + '/'):
raise ValueError('Unexpected Core release download origin.')
return request(url)
return request(attachment_url(assets[0]))
def prepare(pins, root=ROOT):
+24 -5
View File
@@ -1,6 +1,7 @@
"""Upload platform builds to a commit-bound draft, then verify and publish it."""
import argparse
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
import hashlib
import importlib.util
import io
@@ -22,7 +23,7 @@ fingerprint = transport.fingerprint
def context():
base = f"{transport.SERVER}/api/v1/repos/{os.environ['GITEA_REPOSITORY']}"
sha, tag = os.environ['GITEA_SHA'], os.environ['RELEASE_TAG']
version, windows_version = app_versions('pubspec.yaml')
version, windows_version = app_versions(os.environ.get('RELEASE_PUBSPEC', 'pubspec.yaml'))
if tag != f'v{version}':
raise ValueError('Release tag must match pubspec version')
remote_tag = request(f'{base}/tags/{urllib.parse.quote(tag, safe="")}')
@@ -65,8 +66,25 @@ def ci_artifacts(base, run_id):
if not item.get('expired', False)]
def artifact_named(artifacts, name):
matches = [item for item in artifacts if item['name'] == name]
def artifact_named(artifacts, name, run, jobs):
producer = {'cutdex-android-build': 'Build Android APK',
'cutdex-windows-build': 'Audit and package Windows x64',
'cutdex-release-metadata': 'Assemble and validate CI artifacts'}[name]
producers = [job for job in jobs if job['name'] == producer
and job.get('conclusion') == 'success' and job.get('head_sha') == run['head_sha']]
if len(producers) != 1:
raise ValueError('Expected one successful artifact producer: ' + producer)
job = producers[0]
def timestamp(value):
return datetime.fromisoformat(value.replace('Z', '+00:00'))
started, completed = timestamp(job['started_at']), timestamp(job['completed_at'])
# Gitea retains old API rows after overwrite/rerun. Accept only the artifact
# uploaded within the current successful producer's interval; cloned jobs
# retain their original interval and therefore reuse their original bytes.
matches = [item for item in artifacts if item['name'] == name
and item.get('workflow_run', {}).get('id') == run['id']
and item['workflow_run'].get('head_sha') == run['head_sha']
and started <= timestamp(item['created_at']) <= completed]
if len(matches) != 1:
raise ValueError('Expected one unexpired CI artifact: ' + name)
return matches[0]
@@ -91,8 +109,9 @@ def prepare_ci(base, sha, tag, version, windows_version):
run_id = int(matches[0])
run = successful_ci(base, sha, run_id)
artifacts = ci_artifacts(base, run['id'])
verification = artifact_named(artifacts, 'cutdex-release-metadata')
selected = {platform: artifact_named(artifacts, f'cutdex-{platform}-build')
jobs = request(f"{base}/actions/runs/{run['id']}/jobs")['jobs']
verification = artifact_named(artifacts, 'cutdex-release-metadata', run, jobs)
selected = {platform: artifact_named(artifacts, f'cutdex-{platform}-build', run, jobs)
for platform in ('android', 'windows')}
release = prepare(base, sha, tag, version, windows_version, ci_run=run['id'])
if os.environ.get('GITHUB_OUTPUT'):
+13 -1
View File
@@ -8,10 +8,22 @@ from unittest.mock import patch
import unittest
import zipfile
from prepare_dependencies import extract_archive, prepare, verify_archive
from prepare_dependencies import extract_archive, prepare, release_archive, verify_archive
class CoreSourceDependencyTests(unittest.TestCase):
def test_local_gitea_response_links_use_verified_public_origin(self):
_, pins = self.bundle()
asset = {'name': pins['core']['artifact']['file'],
'browser_download_url': 'http://git.orangraph.com/lingjhf/cutdex_core/releases/download/v0.0.1/cutdex-core-0.0.1.zip'}
release = {'tag_name': 'v0.0.1', 'draft': False, 'prerelease': False, 'assets': [asset]}
with patch('prepare_dependencies.request', side_effect=[release, b'archive']) as send:
self.assertEqual(release_archive(pins), b'archive')
self.assertEqual(send.call_args.args[0], asset['browser_download_url'].replace('http:', 'https:'))
asset['browser_download_url'] = 'https://untrusted.example/archive.zip'
with patch('prepare_dependencies.request', return_value=release), self.assertRaises(ValueError):
release_archive(pins)
def bundle(self, extra=None):
prefix = 'cutdex-core-0.0.1/'
native = {'version': '0.0.1', 'source_commit': 'b' * 40, 'path': 'native_flutter',
+33
View File
@@ -41,6 +41,14 @@ class StagedReleaseTests(unittest.TestCase):
{'id': 11, 'name': 'cutdex-android-build'},
{'id': 12, 'name': 'cutdex-windows-build'},
{'id': 13, 'name': 'cutdex-release-metadata'}]}
for artifact in self.run_artifacts[1]:
artifact.update(created_at='2026-10-11T10:01:00Z',
workflow_run={'id': 1, 'head_sha': self.sha})
self.ci_jobs = {1: [{'name': name, 'head_sha': self.sha, 'conclusion': 'success',
'started_at': '2026-10-11T10:00:00Z',
'completed_at': '2026-10-11T10:02:00Z'} for name in
['Build Android APK', 'Audit and package Windows x64',
'Assemble and validate CI artifacts']]}
self.artifact_contents = {10: self.contents,
11: {'app-production-release.apk': self.contents['cutdex-0.1.0-android.apk']},
12: {name: body for name, body in self.contents.items()
@@ -74,6 +82,8 @@ class StagedReleaseTests(unittest.TestCase):
self.calls.append((method, url))
if url.endswith('/actions/runs?limit=100'):
return {'workflow_runs': self.ci_runs}
if '/actions/runs/' in url and url.endswith('/jobs'):
return {'jobs': self.ci_jobs[int(url.split('/actions/runs/')[1].split('/')[0])]}
if '/actions/runs/' in url and url.endswith('/artifacts'):
return {'artifacts': self.run_artifacts[int(url.split('/actions/runs/')[1].split('/')[0])]}
if '/actions/artifacts/' in url and url.endswith('/zip'):
@@ -262,6 +272,29 @@ class StagedReleaseTests(unittest.TestCase):
self.assertIn(stage.ci_marker(1), self.release['body'])
self.assert_draft()
def test_independent_packaging_retry_uses_current_producers_and_original_android(self):
for job in self.ci_jobs[1][1:]:
job.update(started_at='2026-10-11T11:00:00Z', completed_at='2026-10-11T11:02:00Z')
for old_id, new_id in [(12, 22), (13, 23)]:
old = next(item for item in self.run_artifacts[1] if item['id'] == old_id)
self.run_artifacts[1].append(dict(old, id=new_id, created_at='2026-10-11T11:01:00Z'))
self.run_cli('prepare-ci')
output = (self.root / 'outputs').read_text()
for value in ['artifact-id=23', 'windows-artifact-id=22', 'android-artifact-id=11']:
self.assertIn(value, output)
def test_same_producer_duplicate_or_wrong_source_artifact_is_rejected(self):
current = self.run_artifacts[1][3]
self.run_artifacts[1].append(dict(current, id=99))
with self.assertRaisesRegex(ValueError, 'one unexpired CI artifact'):
self.run_cli('prepare-ci')
self.run_artifacts[1].pop()
for identity in [{'id': 2, 'head_sha': self.sha}, {'id': 1, 'head_sha': 'b' * 40}]:
current['workflow_run'] = identity
with self.assertRaisesRegex(ValueError, 'one unexpired CI artifact'):
self.run_cli('prepare-ci')
self.assertIsNone(self.release)
def test_ci_failure_or_expired_metadata_never_creates_draft(self):
self.ci_runs[0]['conclusion'] = 'failure'
with self.assertRaisesRegex(ValueError, 'No successful main CI'):
+1 -1
View File
@@ -19,7 +19,7 @@ ws2_32 ucrtbase version
'''.split())
SYSTEM_DLLS = {name + '.dll' for name in SYSTEM_DLLS}
REQUIRED = (
'cutdex.exe', 'flutter_windows.dll', 'cutdex_runtime_plugin.dll',
'cutdex.exe', 'flutter_windows.dll', 'cutdex_native_flutter_plugin.dll',
'deskup_plugin.dll', 'velopack_libc.dll',
'cutdex_windows_ffi.dll', 'sqlite3.dll', 'data/app.so', 'data/icudtl.dat',
'processing/bin/cutdex-processing-worker.exe',
@@ -37,6 +37,12 @@ class DependencyGateTest(unittest.TestCase):
with self.assertRaisesRegex(ValueError, 'data/app.so'):
audit(self.root, lambda p: [])
def test_native_flutter_plugin_is_required_after_migration(self):
(self.root / 'cutdex_native_flutter_plugin.dll').unlink()
(self.root / 'cutdex_runtime_plugin.dll').touch()
with self.assertRaisesRegex(ValueError, 'cutdex_native_flutter_plugin.dll'):
audit(self.root, lambda p: [], require_processing=False)
def test_jvm_is_not_assumed_to_be_a_system_dependency(self):
with self.assertRaisesRegex(ValueError, 'jvm.dll'):
audit(self.root, lambda p: ['jvm.dll'] if p.name == 'cutdex.exe' else [])