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

print detailed info about the leaked APIs to stdout in the workflow #339

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## 0.10.2-wip
## 0.10.2

- Don't check licenses of generated files in PR health workflow.
- Add generalized ignore-per-checks to health workflow.
- Update dart_apitool version in health workflow.
- Print detailed info about the leaked APIs to stdout in the workflow.

## 0.10.1

Expand Down
2 changes: 0 additions & 2 deletions pkgs/firehose/lib/firehose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ class VerificationResults {
bool get hasError => results.any((r) => r.severity == Severity.error);

String describeAsMarkdown({bool withTag = true}) {
results.sort((a, b) => Enum.compareByIndex(a.severity, b.severity));

return results.map((r) {
var sev = r.severity == Severity.error ? '(error) ' : '';
var tagColumn = '';
Expand Down
38 changes: 33 additions & 5 deletions pkgs/firehose/lib/src/health/health.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class Health {
...['-sgit', 'https://github.com/bmw-tech/dart_apitool.git'],
...['--git-ref', apiToolHash],
],
logStdout: false,
);

runDashProcess(
Expand Down Expand Up @@ -223,16 +224,26 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}
String getCurrentVersionOfPackage(Package package) => 'pub://${package.name}';

ProcessResult runDashProcess(
List<Package> flutterPackages, Package package, List<String> arguments) {
List<Package> flutterPackages,
Package package,
List<String> arguments, {
bool logStdout = true,
}) {
var exec = executable(flutterPackages.any((p) => p.name == package.name));
log('Running `$exec ${arguments.join(' ')}` in ${directory.path}');
var runApiTool = Process.runSync(
exec,
arguments,
workingDirectory: directory.path,
);
log('StdOut:\n ${runApiTool.stdout as String}');
log('StdErr:\n ${runApiTool.stderr as String}');
final out = (runApiTool.stdout as String).trimRight();
if (logStdout && out.isNotEmpty) {
print(out);
}
final err = (runApiTool.stderr as String).trimRight();
if (err.isNotEmpty) {
print(err);
}
return runApiTool;
}

Expand All @@ -257,8 +268,11 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}
final flutterPackages =
packagesContaining(filesInPR, only: flutterPackageGlobs);
log('This list of Flutter packages is $flutterPackages');

for (var package in packagesContaining(filesInPR)) {
log('Look for leaks in $package');
log('');
log('--- ${package.name} ---');
log('Look for leaks in ${package.name}');
var relativePath =
path.relative(package.directory.path, from: directory.path);
var tempDirectory = Directory.systemTemp.createTempSync();
Expand All @@ -274,6 +288,7 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}
...['-sgit', 'https://github.com/bmw-tech/dart_apitool.git'],
...['--git-ref', apiToolHash],
],
logStdout: false,
);

var arguments = [
Expand All @@ -289,15 +304,28 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}
arguments,
);

log('');

if (runApiTool.exitCode == 0) {
var fullReportString = await File(reportPath).readAsString();
var decoded = jsonDecode(fullReportString) as Map<String, dynamic>;
var leaks = decoded['missingEntryPoints'] as List<dynamic>;

log('Leaking symbols in API:\n$leaks');
if (leaks.isNotEmpty) {
leaksForPackage[package] = leaks.cast();

final desc = leaks.map((item) => '$item').join(', ');
log('Leaked symbols found: $desc.');

log('');

final report = const JsonEncoder.withIndent(' ').convert(decoded);
log(report);
} else {
log('No leaks found.');
}

log('');
} else {
throw ProcessException(
executable(flutterPackages.contains(package)),
Expand Down
2 changes: 1 addition & 1 deletion pkgs/firehose/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firehose
description: A tool to automate publishing of Pub packages from GitHub actions.
version: 0.10.2-wip
version: 0.10.2
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

environment:
Expand Down
Loading