Compare commits
11
Commits
No files matched your search
@@ -77,11 +77,7 @@ 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. 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
|
||||
metadata. Missing, expired or duplicate required artifacts 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
|
||||
@@ -98,11 +94,6 @@ 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,
|
||||
|
||||
@@ -24,7 +24,6 @@ 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:
|
||||
@@ -41,23 +40,16 @@ jobs:
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
steps:
|
||||
- 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
|
||||
- name: Check out release tag
|
||||
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 -C .release-source rev-parse HEAD
|
||||
$env:GITEA_SHA = git 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.' }
|
||||
@@ -73,17 +65,10 @@ jobs:
|
||||
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
|
||||
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.android-artifact-id }}
|
||||
steps:
|
||||
- name: Check out pinned release tools
|
||||
- name: Check out release commit
|
||||
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
|
||||
ref: ${{ needs.prepare.outputs.sha }}
|
||||
persist-credentials: false
|
||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||
- name: Download Android CI artifact
|
||||
@@ -106,17 +91,10 @@ jobs:
|
||||
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
|
||||
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.windows-artifact-id }}
|
||||
steps:
|
||||
- name: Check out pinned release tools
|
||||
- name: Check out release commit
|
||||
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
|
||||
ref: ${{ needs.prepare.outputs.sha }}
|
||||
persist-credentials: false
|
||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||
- name: Download Windows CI artifact
|
||||
@@ -139,17 +117,10 @@ jobs:
|
||||
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
|
||||
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.artifact-id }}
|
||||
steps:
|
||||
- name: Check out pinned release tools
|
||||
- name: Check out release commit
|
||||
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
|
||||
ref: ${{ needs.prepare.outputs.sha }}
|
||||
persist-credentials: false
|
||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||
- name: Download release verification metadata
|
||||
|
||||
@@ -108,4 +108,3 @@ pubspec_overrides.yaml
|
||||
|
||||
# Core and native source checkouts prepared by CI or local development.
|
||||
.dependencies/
|
||||
.release-source/
|
||||
@@ -332,13 +332,10 @@ void main() {
|
||||
String workspace = 'application',
|
||||
String? operation,
|
||||
}) async {
|
||||
final id = ++requestId;
|
||||
final elapsed = Stopwatch()..start();
|
||||
stdout.writeln('MCP request $id: $name started');
|
||||
socket.writeln(
|
||||
jsonEncode({
|
||||
'jsonrpc': '2.0',
|
||||
'id': id,
|
||||
'id': ++requestId,
|
||||
'method': 'tools/call',
|
||||
'params': {
|
||||
'_meta': {
|
||||
@@ -354,19 +351,8 @@ void main() {
|
||||
},
|
||||
}),
|
||||
);
|
||||
await socket.flush();
|
||||
// Project tools persist real files. Await their response rather than
|
||||
// imposing an unrelated transport SLA; the test's timeout bounds hangs.
|
||||
expect(
|
||||
await lines.moveNext(),
|
||||
true,
|
||||
reason: 'MCP stream closed for $name request $id',
|
||||
);
|
||||
stdout.writeln(
|
||||
'MCP request $id: $name replied after ${elapsed.elapsedMilliseconds}ms',
|
||||
);
|
||||
expect(await lines.moveNext().timeout(const Duration(seconds: 5)), true);
|
||||
final response = jsonDecode(lines.current) as Map;
|
||||
expect(response['id'], id, reason: '$response');
|
||||
expect(response['error'], isNull, reason: '$response');
|
||||
return (response['result'] as Map)['structuredContent'] as Map;
|
||||
}
|
||||
|
||||
+36
-124
@@ -22,12 +22,6 @@ 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(
|
||||
@@ -37,9 +31,6 @@ 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;
|
||||
}
|
||||
@@ -91,46 +82,12 @@ class _DelayedRestoreConversation extends AgentConversationService {
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
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));
|
||||
}
|
||||
fail('Expected state was not reached');
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -138,7 +95,6 @@ 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-');
|
||||
@@ -175,11 +131,8 @@ 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);
|
||||
});
|
||||
@@ -438,12 +391,7 @@ void main() {
|
||||
);
|
||||
await tester.runAsync(() async {
|
||||
await tester.tap(find.byTooltip('发送消息'));
|
||||
await _waitForRequests(
|
||||
container,
|
||||
chatControllerProvider('lib'),
|
||||
model,
|
||||
1,
|
||||
);
|
||||
await _until(() => model.requests.isNotEmpty);
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(model.requests.single.messages.single.text, '测试发送');
|
||||
@@ -513,10 +461,11 @@ void main() {
|
||||
);
|
||||
await tester.runAsync(() async {
|
||||
model.streams.single.add(const TextDelta('正在生成的内容'));
|
||||
await _waitForState(
|
||||
container,
|
||||
chatControllerProvider('lib'),
|
||||
(state) => state.partialResponse.isNotEmpty,
|
||||
await _until(
|
||||
() => container
|
||||
.read(chatControllerProvider('lib'))
|
||||
.partialResponse
|
||||
.isNotEmpty,
|
||||
);
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
@@ -524,11 +473,7 @@ void main() {
|
||||
await tester.runAsync(() async {
|
||||
await tester.tap(find.byTooltip('停止回复'));
|
||||
await container.read(chatControllerProvider('lib').notifier).stop();
|
||||
await _waitForState(
|
||||
container,
|
||||
chatControllerProvider('lib'),
|
||||
(state) => !state.busy,
|
||||
);
|
||||
await _until(() => !container.read(chatControllerProvider('lib')).busy);
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('回复已中断'), findsOneWidget);
|
||||
@@ -569,11 +514,7 @@ void main() {
|
||||
addTearDown(subscription.close);
|
||||
await tester.pump();
|
||||
await tester.runAsync(
|
||||
() => _waitForState(
|
||||
isolated,
|
||||
provider,
|
||||
(state) => state.messages.length == 2,
|
||||
),
|
||||
() => _until(() => isolated.read(provider).messages.length == 2),
|
||||
);
|
||||
final controller = isolated.read(provider.notifier);
|
||||
expect(isolated.read(provider).messages.last.elapsedMs, 23000);
|
||||
@@ -680,12 +621,7 @@ void main() {
|
||||
await tester.pump();
|
||||
await tester.runAsync(() async {
|
||||
await tester.tap(find.byTooltip('发送消息'));
|
||||
await _waitForRequests(
|
||||
container,
|
||||
chatControllerProvider('project'),
|
||||
model,
|
||||
1,
|
||||
);
|
||||
await _until(() => model.streams.isNotEmpty);
|
||||
});
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('test-project-selector')), findsNothing);
|
||||
@@ -693,10 +629,8 @@ void main() {
|
||||
await tester.runAsync(() async {
|
||||
model.streams.single.add(ModelResponse(text: '已经开始'));
|
||||
await model.streams.single.close();
|
||||
await _waitForState(
|
||||
container,
|
||||
chatControllerProvider('project'),
|
||||
(state) => !state.busy,
|
||||
await _until(
|
||||
() => !container.read(chatControllerProvider('project')).busy,
|
||||
);
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
@@ -763,12 +697,7 @@ void main() {
|
||||
);
|
||||
await tester.runAsync(() async {
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
|
||||
await _waitForRequests(
|
||||
container,
|
||||
chatControllerProvider('lib'),
|
||||
model,
|
||||
1,
|
||||
);
|
||||
await _until(() => model.requests.isNotEmpty);
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
@@ -780,11 +709,7 @@ void main() {
|
||||
await tester.runAsync(() async {
|
||||
model.streams.single.add(ModelResponse(text: 'ok'));
|
||||
await model.streams.single.close();
|
||||
await _waitForState(
|
||||
container,
|
||||
chatControllerProvider('lib'),
|
||||
(state) => !state.busy,
|
||||
);
|
||||
await _until(() => !container.read(chatControllerProvider('lib')).busy);
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -800,15 +725,11 @@ void main() {
|
||||
addTearDown(subscription.close);
|
||||
final controller = container.read(provider.notifier);
|
||||
final sending = controller.send('你好', timelineId: 'first');
|
||||
await _waitForRequests(container, provider, model, 1);
|
||||
await _until(() => model.streams.isNotEmpty);
|
||||
await controller.send('重复', timelineId: 'first');
|
||||
expect(model.requests, hasLength(1));
|
||||
model.streams[0].add(const TextDelta('你好呀'));
|
||||
await _waitForState(
|
||||
container,
|
||||
provider,
|
||||
(state) => state.partialResponse == '你好呀',
|
||||
);
|
||||
await _until(() => container.read(provider).partialResponse == '你好呀');
|
||||
expect(container.read(provider).busy, isTrue);
|
||||
model.streams[0].add(ModelResponse(text: '你好呀!'));
|
||||
await model.streams[0].close();
|
||||
@@ -817,7 +738,7 @@ void main() {
|
||||
expect(container.read(provider).partialResponse, isEmpty);
|
||||
|
||||
final second = controller.send('接着说', timelineId: 'second');
|
||||
await _waitForRequests(container, provider, model, 2);
|
||||
await _until(() => model.requests.length == 2);
|
||||
expect(model.requests[1].messages.map((m) => m.text), [
|
||||
'你好',
|
||||
'你好呀!',
|
||||
@@ -837,7 +758,7 @@ void main() {
|
||||
final other = container
|
||||
.read(otherProvider.notifier)
|
||||
.send('新会话', timelineId: 'timeline');
|
||||
await _waitForRequests(container, otherProvider, model, 3);
|
||||
await _until(() => model.requests.length == 3);
|
||||
expect(model.requests.last.messages.map((m) => m.text), ['新会话']);
|
||||
model.streams[2].add(ModelResponse(text: '新回答'));
|
||||
await model.streams[2].close();
|
||||
@@ -852,20 +773,16 @@ void main() {
|
||||
addTearDown(subscription.close);
|
||||
final controller = container.read(provider.notifier);
|
||||
final sending = controller.send('开始', timelineId: 'timeline');
|
||||
await _waitForRequests(container, provider, model, 1);
|
||||
await _until(() => model.streams.isNotEmpty);
|
||||
model.streams[0].add(const TextDelta('部分回复'));
|
||||
await _waitForState(
|
||||
container,
|
||||
provider,
|
||||
(state) => state.partialResponse.isNotEmpty,
|
||||
);
|
||||
await _until(() => container.read(provider).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 _waitForRequests(container, provider, model, 2);
|
||||
await _until(() => model.streams.length == 2);
|
||||
model.streams[1].add(ModelResponse(text: '完成'));
|
||||
await model.streams[1].close();
|
||||
await next;
|
||||
@@ -888,14 +805,14 @@ void main() {
|
||||
final first = container
|
||||
.read(firstProvider.notifier)
|
||||
.send('第一条', timelineId: 'timeline');
|
||||
await _waitForRequests(container, firstProvider, model, 1);
|
||||
await _until(() => model.streams.length == 1);
|
||||
model.streams[0].add(ModelResponse(text: '第一答'));
|
||||
await model.streams[0].close();
|
||||
await first;
|
||||
final second = container
|
||||
.read(secondProvider.notifier)
|
||||
.send('第二条', timelineId: 'timeline');
|
||||
await _waitForRequests(container, secondProvider, model, 2);
|
||||
await _until(() => model.streams.length == 2);
|
||||
expect(model.requests[1].messages.map((message) => message.text), ['第二条']);
|
||||
model.streams[1].add(ModelResponse(text: '第二答'));
|
||||
await model.streams[1].close();
|
||||
@@ -918,7 +835,7 @@ void main() {
|
||||
final first = container
|
||||
.read(provider.notifier)
|
||||
.send('保留这段对话', timelineId: 'timeline');
|
||||
await _waitForRequests(container, provider, model, 1);
|
||||
await _until(() => model.streams.isNotEmpty);
|
||||
model.streams.single.add(ModelResponse(text: '已经保存'));
|
||||
await model.streams.single.close();
|
||||
await first;
|
||||
@@ -960,18 +877,13 @@ void main() {
|
||||
),
|
||||
],
|
||||
);
|
||||
registry = container.read(agentConversationRegistryProvider);
|
||||
final restoredProvider = chatControllerProvider(
|
||||
'project',
|
||||
conversationId: conversationId,
|
||||
);
|
||||
subscription = container.listen(restoredProvider, (_, _) {});
|
||||
addTearDown(subscription.close);
|
||||
await _waitForState(
|
||||
container,
|
||||
restoredProvider,
|
||||
(state) => state.messages.length == 2,
|
||||
);
|
||||
await _until(() => container.read(restoredProvider).messages.length == 2);
|
||||
expect(
|
||||
container
|
||||
.read(restoredProvider)
|
||||
@@ -983,7 +895,7 @@ void main() {
|
||||
final continued = container
|
||||
.read(restoredProvider.notifier)
|
||||
.send('继续', timelineId: 'timeline');
|
||||
await _waitForRequests(container, restoredProvider, model, 2);
|
||||
await _until(() => model.requests.length == 2);
|
||||
expect(model.requests.last.messages.map((message) => message.text), [
|
||||
'保留这段对话',
|
||||
'已经保存',
|
||||
@@ -1037,7 +949,7 @@ void main() {
|
||||
final first = switchingContainer
|
||||
.read(provider.notifier)
|
||||
.send('旧会话', timelineId: 'timeline');
|
||||
await _waitForRequests(switchingContainer, provider, firstModel, 1);
|
||||
await _until(() => firstModel.streams.isNotEmpty);
|
||||
firstModel.streams.single.add(ModelResponse(text: '旧回答'));
|
||||
await firstModel.streams.single.close();
|
||||
await first;
|
||||
@@ -1052,7 +964,7 @@ void main() {
|
||||
final second = switchingContainer
|
||||
.read(provider.notifier)
|
||||
.send('继续会话', timelineId: 'timeline');
|
||||
await _waitForRequests(switchingContainer, provider, firstModel, 2);
|
||||
await _until(() => firstModel.streams.length == 2);
|
||||
expect(firstModel.requests.last.messages.map((message) => message.text), [
|
||||
'旧会话',
|
||||
'旧回答',
|
||||
@@ -1092,7 +1004,7 @@ void main() {
|
||||
final sending = container
|
||||
.read(provider.notifier)
|
||||
.send('hello', timelineId: 'timeline');
|
||||
await _waitForRequests(container, provider, model, 1);
|
||||
await _until(() => model.streams.isNotEmpty);
|
||||
model.streams.single.addError(entry.key);
|
||||
await model.streams.single.close();
|
||||
await sending;
|
||||
@@ -1106,7 +1018,7 @@ void main() {
|
||||
addTearDown(subscription.close);
|
||||
final controller = container.read(provider.notifier);
|
||||
final sending = controller.send('开始', timelineId: 'timeline');
|
||||
await _waitForRequests(container, provider, model, 1);
|
||||
await _until(() => model.streams.isNotEmpty);
|
||||
model.streams[0].addError(StateError('sensitive remote payload'));
|
||||
await model.streams[0].close();
|
||||
await sending;
|
||||
@@ -1120,7 +1032,7 @@ void main() {
|
||||
['开始'],
|
||||
);
|
||||
final next = controller.send('重试', timelineId: 'timeline');
|
||||
await _waitForRequests(container, provider, model, 2);
|
||||
await _until(() => model.streams.length == 2);
|
||||
model.streams[1].add(ModelResponse(text: '成功'));
|
||||
await model.streams[1].close();
|
||||
await next;
|
||||
@@ -1136,7 +1048,7 @@ void main() {
|
||||
await early;
|
||||
expect(container.read(provider).busy, isFalse);
|
||||
final later = controller.send('再次开始', timelineId: 'timeline');
|
||||
await _waitForRequests(container, provider, model, 1);
|
||||
await _until(() => model.streams.isNotEmpty);
|
||||
subscription.close();
|
||||
container.dispose();
|
||||
await later;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
@@ -15,20 +14,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()) {
|
||||
await _generate(
|
||||
dart,
|
||||
directory,
|
||||
const Duration(minutes: 5) -
|
||||
const Duration(seconds: 10) -
|
||||
elapsed.elapsed,
|
||||
final result = await Process.run(dart, [
|
||||
'run',
|
||||
'build_runner',
|
||||
'build',
|
||||
], workingDirectory: directory);
|
||||
expect(
|
||||
result.exitCode,
|
||||
0,
|
||||
reason: '$directory\n${result.stdout}\n${result.stderr}',
|
||||
);
|
||||
}
|
||||
expect(
|
||||
@@ -37,61 +36,7 @@ void main() {
|
||||
reason: 'Generated files changed. Run dart run build_runner build and review the output.',
|
||||
);
|
||||
await _expectNoUntrackedGeneratedFiles();
|
||||
},
|
||||
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',
|
||||
);
|
||||
}
|
||||
}, timeout: const Timeout(Duration(minutes: 5)));
|
||||
}
|
||||
|
||||
Future<void> _expectNoUntrackedGeneratedFiles() async {
|
||||
|
||||
+1
-6
@@ -45,12 +45,7 @@ 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', '--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']))
|
||||
run(tool_command('flutter', ['test', '--reporter', 'expanded', 'test', *package_tests]))
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -13,7 +13,7 @@ import tempfile
|
||||
import zipfile
|
||||
|
||||
from read_dependencies import ROOT, validate_pins
|
||||
from release_transport import SERVER, attachment_url, request
|
||||
from release_transport import SERVER, request
|
||||
|
||||
|
||||
def verify_archive(data, pins):
|
||||
@@ -94,7 +94,10 @@ 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.')
|
||||
return request(attachment_url(assets[0]))
|
||||
url = assets[0]['browser_download_url']
|
||||
if not url.startswith(SERVER + '/'):
|
||||
raise ValueError('Unexpected Core release download origin.')
|
||||
return request(url)
|
||||
|
||||
|
||||
def prepare(pins, root=ROOT):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""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
|
||||
@@ -23,7 +22,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(os.environ.get('RELEASE_PUBSPEC', 'pubspec.yaml'))
|
||||
version, windows_version = app_versions('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="")}')
|
||||
@@ -66,25 +65,8 @@ def ci_artifacts(base, run_id):
|
||||
if not item.get('expired', False)]
|
||||
|
||||
|
||||
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]
|
||||
def artifact_named(artifacts, name):
|
||||
matches = [item for item in artifacts if item['name'] == name]
|
||||
if len(matches) != 1:
|
||||
raise ValueError('Expected one unexpired CI artifact: ' + name)
|
||||
return matches[0]
|
||||
@@ -109,9 +91,8 @@ 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'])
|
||||
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)
|
||||
verification = artifact_named(artifacts, 'cutdex-release-metadata')
|
||||
selected = {platform: artifact_named(artifacts, f'cutdex-{platform}-build')
|
||||
for platform in ('android', 'windows')}
|
||||
release = prepare(base, sha, tag, version, windows_version, ci_run=run['id'])
|
||||
if os.environ.get('GITHUB_OUTPUT'):
|
||||
|
||||
@@ -8,22 +8,10 @@ from unittest.mock import patch
|
||||
import unittest
|
||||
import zipfile
|
||||
|
||||
from prepare_dependencies import extract_archive, prepare, release_archive, verify_archive
|
||||
from prepare_dependencies import extract_archive, prepare, 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',
|
||||
|
||||
@@ -41,14 +41,6 @@ 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()
|
||||
@@ -82,8 +74,6 @@ 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'):
|
||||
@@ -272,29 +262,6 @@ 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'):
|
||||
|
||||
@@ -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_native_flutter_plugin.dll',
|
||||
'cutdex.exe', 'flutter_windows.dll', 'cutdex_runtime_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,12 +37,6 @@ 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 [])
|
||||
|
||||
Reference in new issue
Block a user