Skip to content

Commit 452b566

Browse files
committed
Squashed commit of the following:
commit da1dd5d Author: Devon Carew <devoncarew@google.com> Date: Thu Jul 24 10:24:40 2025 -0700 switch CI to using workflow files (dart-lang#428) * switch CI to using workflow files * update the sdk matrix * review feedback * remove format sdk version check commit 8ffaf5e Author: Nikechukwu <150845642+nikeokoronkwo@users.noreply.github.com> Date: Wed Jul 23 12:17:55 2025 -0400 [interop] Implement Diagnostics and Handling Errors (dart-lang#426) * implemented diagnostics * added extra invalid semantic
1 parent b8d7132 commit 452b566

13 files changed

Lines changed: 276 additions & 681 deletions

File tree

.github/workflows/dart.yml

Lines changed: 0 additions & 503 deletions
This file was deleted.

.github/workflows/web.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: package:web
2+
permissions: read-all
3+
4+
on:
5+
# Run CI on pushes to the main branch and on PRs.
6+
push:
7+
branches: [ main ]
8+
paths:
9+
- '.github/workflows/web.yaml'
10+
- 'web/**'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/web.yaml'
14+
- 'web/**'
15+
schedule:
16+
- cron: "0 0 * * 0"
17+
18+
defaults:
19+
run:
20+
working-directory: web/
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
sdk: [3.4, beta, dev]
29+
test_config: ['-p chrome', '-p chrome -c dart2wasm']
30+
31+
steps:
32+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
33+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
34+
with:
35+
sdk: ${{ matrix.sdk }}
36+
37+
- run: dart pub get
38+
- run: dart format --output=none --set-exit-if-changed .
39+
if: ${{ matrix.sdk == 'dev' }}
40+
- run: dart analyze --fatal-infos
41+
- run: dart test ${{ matrix.test_config }}
42+
43+
# Validate the 'dart fix' metadata.
44+
- run: dart fix --compare-to-golden test_fixes
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: package:web_generator
2+
permissions: read-all
3+
4+
on:
5+
# Run CI on pushes to the main branch and on PRs.
6+
push:
7+
branches: [ main ]
8+
paths:
9+
- '.github/workflows/web_generator.yaml'
10+
- 'web_generator/**'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/web_generator.yaml'
14+
- 'web_generator/**'
15+
schedule:
16+
- cron: "0 0 * * 0"
17+
18+
defaults:
19+
run:
20+
working-directory: web_generator/
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
sdk: [dev]
29+
test_config: ['', '-p chrome', '-p chrome -c dart2wasm']
30+
31+
steps:
32+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
33+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
34+
with:
35+
sdk: ${{ matrix.sdk }}
36+
37+
- run: dart pub get
38+
- run: dart format --output=none --set-exit-if-changed .
39+
- run: dart analyze --fatal-infos
40+
- run: dart test ${{ matrix.test_config }}
41+
42+
# test bin/update_idl_bindings.dart
43+
test_generate:
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
48+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
49+
50+
- run: dart pub get
51+
- run: dart pub -C ../web get
52+
- run: dart bin/update_idl_bindings.dart
53+
- run: dart analyze --fatal-infos ../web
54+
55+
# test bin/update_idl_bindings.dart --generate-all
56+
test_generate_all:
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
61+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
62+
63+
- run: dart pub get
64+
- run: dart pub -C ../web get
65+
- run: dart bin/update_idl_bindings.dart --generate-all
66+
- run: dart analyze --fatal-infos ../web

mono_repo.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

tool/ci.sh

Lines changed: 0 additions & 131 deletions
This file was deleted.

web/mono_pkg.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

web_generator/lib/src/cli.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ Future<void> compileDartMain({String? langVersion, String? dir}) async {
3131
);
3232
}
3333

34+
Future<Process> runProcWithResult(String executable, List<String> arguments,
35+
{required String workingDirectory}) async {
36+
print(ansi.styleBold.wrap(['*', executable, ...arguments].join(' ')));
37+
return Process.start(
38+
executable,
39+
arguments,
40+
runInShell: Platform.isWindows,
41+
workingDirectory: workingDirectory,
42+
);
43+
}
44+
3445
Future<void> runProc(String executable, List<String> arguments,
3546
{required String workingDirectory, bool detached = false}) async {
3647
print(ansi.styleBold.wrap(['*', executable, ...arguments].join(' ')));

web_generator/lib/src/interop_gen/parser.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'dart:js_interop';
66

7+
import '../js/node.dart';
78
import '../js/typescript.dart' as ts;
89

910
class ParserResult {
@@ -13,9 +14,35 @@ class ParserResult {
1314
ParserResult({required this.program, required this.files});
1415
}
1516

17+
/// Parses the given TypeScript declaration [files], provides any diagnostics,
18+
/// if any, and generates a [ts.TSProgram] for transformation
1619
ParserResult parseDeclarationFiles(Iterable<String> files) {
1720
final program = ts.createProgram(files.jsify() as JSArray<JSString>,
1821
ts.TSCompilerOptions(declaration: true));
1922

23+
// get diagnostics
24+
final diagnostics = [
25+
...program.getSemanticDiagnostics().toDart,
26+
...program.getSyntacticDiagnostics().toDart,
27+
...program.getDeclarationDiagnostics().toDart,
28+
];
29+
30+
// handle diagnostics
31+
for (final diagnostic in diagnostics) {
32+
if (diagnostic.file case final diagnosticFile?) {
33+
final ts.TSLineAndCharacter(line: line, character: char) =
34+
ts.getLineAndCharacterOfPosition(diagnosticFile, diagnostic.start!);
35+
final message =
36+
ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
37+
printErr('${diagnosticFile.fileName} '
38+
'(${line.toDartInt + 1},${char.toDartInt + 1}): $message');
39+
}
40+
}
41+
42+
if (diagnostics.isNotEmpty) {
43+
// exit
44+
exit(1);
45+
}
46+
2047
return ParserResult(program: program, files: files);
2148
}

web_generator/lib/src/js/node.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ import 'dart:js_interop';
66

77
@JS()
88
external String get url;
9+
10+
@JS('process.exit')
11+
external void exit(int code);
12+
13+
@JS('console.error')
14+
external void printErr(String message);

0 commit comments

Comments
 (0)