From 307713ed60af5d327ef6df6dd4292e65336a25bd Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 6 Dec 2024 14:19:14 +0100 Subject: [PATCH 1/8] Fix Health --- .github/workflows/health_base.yaml | 4 --- pkgs/firehose/lib/src/health/health.dart | 42 ++++++++++++++++-------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 27df6fef..1f6a1e30 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -134,10 +134,6 @@ jobs: 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' }} diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 18dd388f..61ee4460 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -161,6 +161,16 @@ class Health { 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'], + 'dart_apitool', + ], + ); + runDashProcess( flutterPackages, package, @@ -248,18 +258,29 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} 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'], + 'dart_apitool', ], ); + 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; @@ -271,14 +292,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], - ], ); } } From e46d8d74e18eb05d58a1bbaef6fa5cad7dba945a Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 6 Dec 2024 14:26:50 +0100 Subject: [PATCH 2/8] Add firehose ref --- .github/workflows/health_base.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 1f6a1e30..ca8b29d4 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -127,7 +127,8 @@ 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/ --git-ref=healthFixes + # DO-NOT-SUBMIT if: ${{ !inputs.local_debug }} - name: Install local firehose From aadfaacc25a7e19153898371ad2f38e19fefe0cd Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 6 Dec 2024 14:33:12 +0100 Subject: [PATCH 3/8] Add log --- pkgs/firehose/lib/src/health/health.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 61ee4460..e351c786 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -151,9 +151,10 @@ class Health { Future breakingCheck() async { final filesInPR = await listFilesInPRorAll(ignoredPackages); final changeForPackage = {}; + 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'); @@ -252,6 +253,7 @@ ${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 = From 0564a7b971754824a72d98df80c559279423f9f0 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 6 Dec 2024 14:36:10 +0100 Subject: [PATCH 4/8] Test for flutter package by name --- pkgs/firehose/lib/src/health/health.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index e351c786..5ab93b54 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -221,7 +221,7 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} ProcessResult runDashProcess( List flutterPackages, Package package, List 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, From f544293b6660a92a616d5110272d577d39addec1 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 9 Dec 2024 14:28:52 +0100 Subject: [PATCH 5/8] Activate dart_apitool from SHA --- pkgs/firehose/lib/src/health/health.dart | 4 ++-- pkgs/firehose/test/health_test.dart | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 5ab93b54..e0498db7 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -228,8 +228,8 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} 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; } diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index d17e6db2..b3e472ed 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -49,7 +49,15 @@ Future 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', + '123049d3fa3c1459a5129b2b61d852a388a8511e', + ]); await Process.run('dart', ['pub', 'global', 'activate', 'coverage']); }); From b17b809582e7c1b3a83669791ee09a646f25d282 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 9 Dec 2024 14:44:23 +0100 Subject: [PATCH 6/8] use hashed version in prod --- pkgs/firehose/lib/src/health/health.dart | 16 ++++++++++++---- pkgs/firehose/test/health_test.dart | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index e0498db7..4b96b4f2 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -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'), @@ -167,8 +169,11 @@ class Health { flutterPackages, package, [ - ...['pub', 'global', 'activate'], - 'dart_apitool', + 'pub', + 'global', + 'activate', + ...['-sgit', 'https://github.com/bmw-tech/dart_apitool.git'], + ...['--git-ref', apiToolHash], ], ); @@ -265,8 +270,11 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} flutterPackages, package, [ - ...['pub', 'global', 'activate'], - 'dart_apitool', + 'pub', + 'global', + 'activate', + ...['-sgit', 'https://github.com/bmw-tech/dart_apitool.git'], + ...['--git-ref', apiToolHash], ], ); diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index b3e472ed..7b76fbd0 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -56,7 +56,7 @@ Future main() async { '-sgit', 'https://github.com/bmw-tech/dart_apitool.git', '--git-ref', - '123049d3fa3c1459a5129b2b61d852a388a8511e', + apiToolHash, ]); await Process.run('dart', ['pub', 'global', 'activate', 'coverage']); }); From e117767bf0aff5c34515a7e18705af2ef471903f Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 9 Dec 2024 15:36:40 +0100 Subject: [PATCH 7/8] Use main --- .github/workflows/health_base.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index ca8b29d4..5c7e8b1d 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -127,8 +127,7 @@ jobs: if: ${{ inputs.check == 'coverage' }} - name: Install firehose - run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/ --git-ref=healthFixes - # DO-NOT-SUBMIT + 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 From b7c7e71c18fee7a3e289f35361cb6255d918d730 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 9 Dec 2024 15:43:12 +0100 Subject: [PATCH 8/8] Rev version --- pkgs/firehose/CHANGELOG.md | 4 ++++ pkgs/firehose/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/firehose/CHANGELOG.md b/pkgs/firehose/CHANGELOG.md index bf8a747b..9db228f7 100644 --- a/pkgs/firehose/CHANGELOG.md +++ b/pkgs/firehose/CHANGELOG.md @@ -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 diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml index 92b25430..069929f6 100644 --- a/pkgs/firehose/pubspec.yaml +++ b/pkgs/firehose/pubspec.yaml @@ -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: