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

Health fixes #325

Merged
merged 8 commits into from
Dec 11, 2024
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
6 changes: 1 addition & 5 deletions .github/workflows/health_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,13 @@ jobs:
if: ${{ inputs.check == 'coverage' }}

- name: Install firehose
run: dart pub global activate firehose
run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/
if: ${{ !inputs.local_debug }}

- name: Install local firehose
run: dart pub global activate --source path current_repo/pkgs/firehose/
if: ${{ inputs.local_debug }}

- name: Install api_tool
run: dart pub global activate dart_apitool
if: ${{ inputs.check == 'breaking' || inputs.check == 'leaking' }}

- name: Check PR health
id: healthstep
if: ${{ github.event_name == 'pull_request' }}
Expand Down
4 changes: 4 additions & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.1

- Small fixes to the PR health checker.

## 0.10.0

- Remove the `version` pubspec checks (these largely duplicate the feedback
Expand Down
60 changes: 43 additions & 17 deletions pkgs/firehose/lib/src/health/health.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import 'changelog.dart';
import 'coverage.dart';
import 'license.dart';

const apiToolHash = '123049d3fa3c1459a5129b2b61d852a388a8511e';

enum Check {
license('License Headers', 'license'),
changelog('Changelog Entry', 'changelog'),
Expand Down Expand Up @@ -151,16 +153,30 @@ class Health {
Future<HealthCheckResult> breakingCheck() async {
final filesInPR = await listFilesInPRorAll(ignoredPackages);
final changeForPackage = <Package, BreakingChange>{};

final flutterPackages =
packagesContaining(filesInPR, only: flutterPackageGlobs);

log('This list of Flutter packages is $flutterPackages');
for (var package
in packagesContaining(filesInPR, ignore: ignoredPackages)) {
log('Look for changes in $package');
var relativePath =
path.relative(package.directory.path, from: directory.path);
var tempDirectory = Directory.systemTemp.createTempSync();
var reportPath = path.join(tempDirectory.path, 'report.json');

runDashProcess(
flutterPackages,
package,
[
'pub',
'global',
'activate',
...['-sgit', 'https://github.com/bmw-tech/dart_apitool.git'],
...['--git-ref', apiToolHash],
],
);

runDashProcess(
flutterPackages,
package,
Expand Down Expand Up @@ -210,15 +226,15 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}

ProcessResult runDashProcess(
List<Package> flutterPackages, Package package, List<String> arguments) {
var exec = executable(flutterPackages.contains(package));
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(runApiTool.stderr as String);
log(runApiTool.stdout as String);
log('StdOut:\n ${runApiTool.stdout as String}');
log('StdErr:\n ${runApiTool.stderr as String}');
return runApiTool;
}

Expand All @@ -242,24 +258,39 @@ ${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');
var relativePath =
path.relative(package.directory.path, from: directory.path);
var tempDirectory = Directory.systemTemp.createTempSync();
var reportPath = path.join(tempDirectory.path, 'leaks.json');
var runApiTool = runDashProcess(

runDashProcess(
flutterPackages,
package,
[
...['pub', 'global', 'run'],
'dart_apitool:main',
'extract',
...['--input', relativePath],
...['--output', reportPath],
'pub',
'global',
'activate',
...['-sgit', 'https://github.com/bmw-tech/dart_apitool.git'],
...['--git-ref', apiToolHash],
],
);

var arguments = [
...['pub', 'global', 'run'],
'dart_apitool:main',
'extract',
...['--input', relativePath],
...['--output', reportPath],
];
var runApiTool = runDashProcess(
flutterPackages,
package,
arguments,
);

if (runApiTool.exitCode == 0) {
var fullReportString = await File(reportPath).readAsString();
var decoded = jsonDecode(fullReportString) as Map<String, dynamic>;
Expand All @@ -271,14 +302,9 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}
}
} else {
throw ProcessException(
executable(flutterPackages.contains(package)),
arguments,
'Api tool finished with exit code ${runApiTool.exitCode}',
[
...['pub', 'global', 'run'],
'dart_apitool:main',
'extract',
...['--input', relativePath],
...['--output', reportPath],
],
);
}
}
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.0
version: 0.10.1
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

environment:
Expand Down
10 changes: 9 additions & 1 deletion pkgs/firehose/test/health_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ Future<void> main() async {
...additional
]);

await Process.run('dart', ['pub', 'global', 'activate', 'dart_apitool']);
await Process.run('dart', [
'pub',
'global',
'activate',
'-sgit',
'https://github.com/bmw-tech/dart_apitool.git',
'--git-ref',
apiToolHash,
]);
await Process.run('dart', ['pub', 'global', 'activate', 'coverage']);
});

Expand Down
Loading