refactor(build): 统一本地与 CI 构建入口及平台发布工具 (#9)
Gitea CI / Check code and tests (push) Successful in 7m38s
Gitea CI / Build Android APK (push) Successful in 6m20s
Gitea CI / Audit and package Windows x64 (push) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (push) Canceled after 0s
Gitea CI / Gitea CI passed (push) Canceled after 0s
Gitea CI / Build Windows x64 app (push) Canceled after 14m42s

This commit was merged in pull request #9.
This commit is contained in:
lingjhf committed 2026-10-06 16:14:42 +00:00
1 parent a13a54d5ec
commit 4a759d81a6
61 files changed
+1913 -388

No files matched your search

+16 -7
View File
@@ -1,4 +1,5 @@
import 'support/creation_names.dart';
import 'support/dart_executable.dart';
import 'package:cutdex/app/editor_theme.dart';
import 'package:cutdex/l10n/app_localizations.dart';
@@ -1790,12 +1791,14 @@ void main() {
);
addTearDown(bridge.close);
final process = await Process.start(
'dart',
['run', 'tool/mcp_stdio.dart'],
runInShell: Platform.isWindows,
flutterTestDartExecutable(),
['tool/mcp_stdio.dart'],
environment: {
'CUTDEX_MCP_PORT': '${bridge.port}',
'CUTDEX_MCP_TOKEN': token,
// This standard-library launcher must not need a Dart/Flutter wrapper
// on PATH, or compete with parallel generators for startup/pub locks.
'PATH': root.path,
},
);
addTearDown(process.kill);
@@ -1809,13 +1812,19 @@ void main() {
}),
),
);
final response = jsonDecode(
await process.stdout
final String responseLine;
try {
responseLine = await process.stdout
.transform(utf8.decoder)
.transform(const LineSplitter())
.first
.timeout(const Duration(seconds: 15)),
) as Map;
.timeout(const Duration(seconds: 15));
} on TimeoutException {
process.kill();
await process.exitCode.timeout(const Duration(seconds: 5));
fail('MCP launcher did not respond within 15 seconds.\n${await errors}');
}
final response = jsonDecode(responseLine) as Map;
expect((response['result'] as Map)['isError'], false, reason: '$response');
expect(transform().x, closeTo(320 / session.canvas.width, 1e-9));
await process.stdin.close();
+3 -4
View File
@@ -4,6 +4,8 @@ import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:crypto/crypto.dart';
import 'support/dart_executable.dart';
const _generatedFiles = [
':(glob)lib/**/*.g.dart',
':(glob)lib/**/*.freezed.dart',
@@ -15,10 +17,7 @@ void main() {
test('workspace generated code is up to date', () async {
await _expectNoUntrackedGeneratedFiles();
final before = await _generatedContents();
final flutterRoot = Platform.environment['FLUTTER_ROOT'];
final dart = flutterRoot == null
? (Platform.isWindows ? 'dart.exe' : 'dart')
: '$flutterRoot/bin/cache/dart-sdk/bin/${Platform.isWindows ? 'dart.exe' : 'dart'}';
final dart = flutterTestDartExecutable();
for (final directory in _generatorRoots()) {
final result = await Process.run(dart, [
'run',
+27
View File
@@ -0,0 +1,27 @@
import 'dart:io';
import 'package:path/path.dart' as p;
/// Uses the SDK running Flutter tests without invoking its shell launcher.
String flutterTestDartExecutable() {
final root = Platform.environment['FLUTTER_ROOT'];
if (root == null || root.isEmpty) {
throw StateError(
'Flutter tests require FLUTTER_ROOT to select their Dart SDK.',
);
}
final executable = p.join(
root,
'bin',
'cache',
'dart-sdk',
'bin',
Platform.isWindows ? 'dart.exe' : 'dart',
);
if (!File(executable).existsSync()) {
throw StateError(
'The Flutter test SDK is missing its native Dart executable.',
);
}
return executable;
}
+105
View File
@@ -0,0 +1,105 @@
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import '../../tool/src/local_environment.dart';
void main() {
late Directory root;
setUp(() => root = Directory.systemTemp.createTempSync('cutdex-env-test-'));
tearDown(() => root.deleteSync(recursive: true));
test('parses BOM, CRLF, quotes, comments and literal Windows paths', () {
expect(
parseLocalEnvironment(
'\uFEFF# local configuration\r\n'
'export CUTDEX_WINDOWS_PATH = "C:\\My SDK\\native" # source\r\n'
"CUTDEX_PROCESSING_ROOT='C:/workers #1'\r\n"
'CUTDEX_GITEA_TOKEN=literal#hash # comment\r\n'
'EMPTY=\r\n',
),
{
'CUTDEX_WINDOWS_PATH': r'C:\My SDK\native',
'CUTDEX_PROCESSING_ROOT': 'C:/workers #1',
'CUTDEX_GITEA_TOKEN': 'literal#hash',
'EMPTY': '',
},
);
});
test('values are not evaluated or expanded', () {
expect(
parseLocalEnvironment(r'VALUE=$(command) ${OTHER}\n')['VALUE'],
r'$(command) ${OTHER}\n',
);
});
test('invalid and duplicate assignments never expose their values', () {
for (final source in [
'this-is-a-secret',
'TOKEN="this-is-a-secret',
'TOKEN="this-is-a-secret" trailing',
'TOKEN=first\nTOKEN=this-is-a-secret',
]) {
try {
parseLocalEnvironment(source);
fail('Invalid configuration was accepted.');
} on FormatException catch (error) {
expect(error.message, isNot(contains('this-is-a-secret')));
}
}
});
test('explicit process values win, including empty values', () {
expect(
mergeLocalEnvironment(
{'TOKEN': 'explicit', 'EMPTY': ''},
{'TOKEN': 'file', 'EMPTY': 'file', 'LOCAL': 'file'},
windows: false,
),
{'TOKEN': 'explicit', 'EMPTY': '', 'LOCAL': 'file'},
);
});
test('Windows variable names are compared without case sensitivity', () {
expect(
mergeLocalEnvironment(
{'Path': 'explicit'},
{'PATH': 'file'},
windows: true,
),
{'Path': 'explicit'},
);
});
test('missing local file preserves the SDK defaults', () {
expect(loadLocalEnvironment(root, {'EXISTING': 'value'}, windows: false), {
'EXISTING': 'value',
});
});
test('loads the project root file without modifying parent variables', () {
File.fromUri(root.uri.resolve('.env.local'))
.writeAsStringSync('LOCAL=value');
final parent = <String, String>{'EXISTING': 'parent'};
expect(loadLocalEnvironment(root, parent, windows: false), {
'EXISTING': 'parent',
'LOCAL': 'value',
});
expect(parent, {'EXISTING': 'parent'});
});
test('CI never opens even an invalid local file', () {
File.fromUri(root.uri.resolve('.env.local'))
.writeAsStringSync('invalid file');
for (final key in ['CI', 'GITEA_ACTIONS', 'GITHUB_ACTIONS']) {
final parent = {key: 'true'};
expect(loadLocalEnvironment(root, parent, windows: false), parent);
}
});
test('a false CI flag still allows local development', () {
expect(isContinuousIntegration({'CI': 'false'}), isFalse);
expect(isContinuousIntegration({'CI': '1'}), isTrue);
});
}
+9 -2
View File
@@ -2392,9 +2392,16 @@ void main() {
targetLanguage: 'zh',
);
await backend.started.future;
final completed = Completer<void>();
void checkCompletion() {
if (job.terminal && !completed.isCompleted) completed.complete();
}
session.addListener(checkCompletion);
addTearDown(() => session.removeListener(checkCompletion));
await session.subtitleWorkflows.cancel(job);
await settle(session);
await Future<void>.delayed(const Duration(milliseconds: 10));
checkCompletion();
await completed.future.timeout(const Duration(seconds: 5));
expect(job.status, TranscriptionStatus.cancelled);
expect(job.terminal, true);
expect(session.subtitleWorkflows.runningCount, 0);