Skip to content

Commit

Permalink
Health fixes (#325)
Browse files Browse the repository at this point in the history
Some more minor fixes for the Health workflow

---

- [x] I’ve reviewed the contributor guide and applied the relevant
portions to this PR.

<details>
  <summary>Contribution guidelines:</summary><br>

- See our [contributor
guide](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md)
for general expectations for PRs.
- Larger or significant changes should be discussed in an issue before
creating a PR.
- Contributions to our repos should follow the [Dart style
guide](https://dart.dev/guides/language/effective-dart) and use `dart
format`.
- Most changes should add an entry to the changelog and may need to [rev
the pubspec package
version](https://github.com/dart-lang/sdk/blob/main/docs/External-Package-Maintenance.md#making-a-change).
- Changes to packages require [corresponding
tests](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md#Testing).

Note that many Dart repos have a weekly cadence for reviewing PRs -
please allow for some latency before initial review feedback.
</details>
  • Loading branch information
mosuem authored Dec 11, 2024
1 parent b25118a commit 3339020
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 24 deletions.
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

0 comments on commit 3339020

Please sign in to comment.