Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is:wasm-ready tag #1336

Merged
merged 13 commits into from
Feb 9, 2024
8 changes: 4 additions & 4 deletions lib/src/report/multi_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Future<ReportSection> multiPlatform(String packageDir, Pubspec pubspec) async {

Subsection scorePlatforms(
List<String> tags, List<Explanation> explanations) {
// Scoring and the report only takes these platforms into account.
final tagNames = const {
PanaTags.platformIos: 'iOS',
PanaTags.platformAndroid: 'Android',
Expand All @@ -45,12 +46,13 @@ Future<ReportSection> multiPlatform(String packageDir, Pubspec pubspec) async {
PanaTags.platformMacos: 'macOS',
PanaTags.platformLinux: 'Linux',
};
final officialTags = tags.where(tagNames.containsKey).toList();
final sdkExplanations =
explanations.where((e) => e.tag != null && e.tag!.startsWith('sdk:'));
final platformExplanations = explanations
.where((e) => e.tag == null || !e.tag!.startsWith('sdk:'));
final officialExplanations = platformExplanations.where((e) =>
!tags.contains(e.tag) &&
!officialTags.contains(e.tag) &&
(e.tag == null || tagNames.containsKey(e.tag)));
final trustExplanations = explanations.where((e) => tags.contains(e.tag));
final paragraphs = <Paragraph>[
Expand All @@ -59,7 +61,7 @@ Future<ReportSection> multiPlatform(String packageDir, Pubspec pubspec) async {
if (sdkExplanations.isNotEmpty)
// This empty line is required for `package:markdown` to render the following list correctly.
RawParagraph(''),
for (final tag in tags.where((e) => e.startsWith('platform')))
for (final tag in officialTags.where((e) => e.startsWith('platform')))
RawParagraph('* ✓ ${tagNames[tag]}'),
if (officialExplanations.isNotEmpty)
RawParagraph('\nThese platforms are not supported:\n'),
Expand All @@ -70,8 +72,6 @@ Future<ReportSection> multiPlatform(String packageDir, Pubspec pubspec) async {
...trustExplanations.map(explanationToIssue),
];

final officialTags = tags.where(tagNames.containsKey).toList();

final status =
officialTags.where((tag) => tag.startsWith('platform:')).isEmpty
? ReportStatus.failed
Expand Down
7 changes: 7 additions & 0 deletions lib/src/tag/_specs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Runtime {
nativeAot,
nativeJit,
web,
wasm,
];

static final nativeAot = Runtime(
Expand All @@ -90,6 +91,12 @@ class Runtime {
tag: PanaTags.runtimeWeb,
);

static final wasm = Runtime(
'wasm',
{..._onAllPlatforms, 'ui', 'ui_web', 'js_interop', 'js_interop_unsafe'},
tag: PanaTags.isWasmReady,
);

static final flutterNative = Runtime(
'flutter-native',
{
Expand Down
1 change: 1 addition & 0 deletions lib/src/tag/pana_tags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ abstract class PanaTags {
static const runtimeFlutterNative = 'runtime:flutter-native';
static const runtimeFlutterWeb = 'runtime:flutter-web';
static const runtimeWeb = 'runtime:web';
static const isWasmReady = 'is:wasm-ready';

// platform tags
static const platformAndroid = 'platform:android';
Expand Down
1 change: 1 addition & 0 deletions test/goldens/end2end/async-2.11.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"runtime:native-aot",
"runtime:native-jit",
"runtime:web",
"is:wasm-ready",
"is:null-safe",
"is:dart3-compatible",
"license:bsd-3-clause",
Expand Down
1 change: 1 addition & 0 deletions test/goldens/end2end/http-0.13.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"runtime:native-aot",
"runtime:native-jit",
"runtime:web",
"is:wasm-ready",
"is:null-safe",
"is:dart3-compatible",
"license:bsd-3-clause",
Expand Down
1 change: 1 addition & 0 deletions test/goldens/end2end/lints-1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"runtime:native-aot",
"runtime:native-jit",
"runtime:web",
"is:wasm-ready",
"is:null-safe",
"is:dart3-compatible",
"license:bsd-3-clause",
Expand Down
26 changes: 22 additions & 4 deletions test/tag/tag_end2end_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void main() {
'runtime:native-jit',
'runtime:native-aot',
'runtime:web',
'is:wasm-ready',
},
explanations: isEmpty);
_expectTagging(tagger.flutterPluginTags, tags: isEmpty);
Expand Down Expand Up @@ -310,8 +311,12 @@ int fourtyTwo() => 42;
_expectTagging(tagger.sdkTags, tags: {'sdk:flutter', 'sdk:dart'});
_expectTagging(tagger.platformTags,
tags: {'platform:windows', 'platform:android'});
_expectTagging(tagger.runtimeTags,
tags: ['runtime:native-aot', 'runtime:native-jit', 'runtime:web']);
_expectTagging(tagger.runtimeTags, tags: [
'runtime:native-aot',
'runtime:native-jit',
'runtime:web',
'is:wasm-ready'
]);
_expectTagging(tagger.flutterPluginTags, tags: isEmpty);
});

Expand Down Expand Up @@ -406,7 +411,13 @@ Because:
finding: 'Package not compatible with runtime js', explanation: '''
Because:
* `package:my_package/my_package.dart` that imports:
* `dart:io`''')
* `dart:io`'''),
_explanation(
finding: 'Package not compatible with runtime wasm',
explanation: '''
Because:
* `package:my_package/my_package.dart` that imports:
* `dart:io`'''),
});
_expectTagging(tagger.flutterPluginTags, tags: isEmpty);
});
Expand Down Expand Up @@ -449,7 +460,12 @@ int fourtyThree() => 43;
},
explanations: isEmpty);
_expectTagging(tagger.runtimeTags,
tags: {'runtime:native-aot', 'runtime:native-jit', 'runtime:web'},
tags: {
'runtime:native-aot',
'runtime:native-jit',
'runtime:web',
'is:wasm-ready',
},
explanations: isEmpty);
_expectTagging(tagger.flutterPluginTags, tags: isEmpty);
});
Expand Down Expand Up @@ -507,6 +523,7 @@ name: my_package
'runtime:native-jit',
'runtime:native-aot',
'runtime:web',
'is:wasm-ready',
},
explanations: isEmpty);
_expectTagging(tagger.flutterPluginTags, tags: isEmpty);
Expand Down Expand Up @@ -536,6 +553,7 @@ name: my_package
'runtime:native-jit',
'runtime:native-aot',
'runtime:web',
'is:wasm-ready',
},
explanations: isEmpty);
_expectTagging(tagger.flutterPluginTags, tags: isEmpty);
Expand Down
Loading