From b2d4ff7451c72bce71b9c3ce1cbb402bf2a3261d Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 29 Aug 2023 19:23:06 +0200 Subject: [PATCH 01/40] Add api tool call for testing --- .github/workflows/health.yaml | 4 ++-- pkgs/firehose/bin/health.dart | 2 +- pkgs/firehose/lib/src/health/health.dart | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index b7bfdcd2..d650d294 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -43,8 +43,8 @@ on: required: false type: string checks: - description: What to check for in the PR health check - any subset of "version,changelog,license,coverage" - default: "version,changelog,license,coverage" + description: What to check for in the PR health check - any subset of "version,changelog,license,coverage,breaking" + default: "version,changelog,license,coverage,breaking" type: string required: false local_debug: diff --git a/pkgs/firehose/bin/health.dart b/pkgs/firehose/bin/health.dart index 25b80524..e87270b1 100644 --- a/pkgs/firehose/bin/health.dart +++ b/pkgs/firehose/bin/health.dart @@ -11,7 +11,7 @@ void main(List arguments) async { var argParser = ArgParser() ..addMultiOption( 'checks', - allowed: ['version', 'license', 'changelog', 'coverage'], + allowed: ['version', 'license', 'changelog', 'coverage', 'breaking'], help: 'Check PR health.', ) ..addFlag( diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index e507a1bb..4d6261f4 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -63,6 +63,9 @@ class Health { if (args.contains('coverage') && !github.prLabels.contains('skip-coverage-check')) (Github github) => coverageCheck(github, coverageweb), + if (args.contains('breaking') && + !github.prLabels.contains('skip-breaking-check')) + breakingCheck, ]; var checked = @@ -91,6 +94,26 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati ); } + Future breakingCheck(Github github) async { + var getApiTool = await Process.run( + 'dart', ['pub', 'global', 'activate', 'dart_apitool']); + if (getApiTool.exitCode != 0) { + throw ProcessException('dart pub global', ['activate dart_apitool'], + 'Failed to install api tool'); + } + var runApiTool = await Process.run( + 'dart-apitool', ['diff', '--old', '../base_repo', '--new', '.']); + + return HealthCheckResult( + 'breaking', + _publishBotTag2, + runApiTool.exitCode == 0 ? Severity.success : Severity.error, + ''' +${runApiTool.stdout} +''', + ); + } + Future licenseCheck(Github github) async { var files = await Github().listFilesForPR(); var allFilePaths = await getFilesWithoutLicenses(Directory.current); From 29cc8b671718ab69eedc9fb05916285ff842a486 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 29 Aug 2023 19:32:58 +0200 Subject: [PATCH 02/40] Change tag --- 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 4d6261f4..5a9c7637 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -28,6 +28,8 @@ const String _changelogBotTag = '### Changelog Entry'; const String _coverageBotTag = '### Coverage'; +const String _breakingBotTag = '### Breaking changes'; + const String _prHealthTag = '## PR Health'; class Health { @@ -106,7 +108,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati return HealthCheckResult( 'breaking', - _publishBotTag2, + _breakingBotTag, runApiTool.exitCode == 0 ? Severity.success : Severity.error, ''' ${runApiTool.stdout} From 22fbb6c34b8f406c4f5c202c9d4b39c389b4ab10 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 29 Aug 2023 19:34:25 +0200 Subject: [PATCH 03/40] Add debugging log --- pkgs/firehose/lib/src/health/health.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 5a9c7637..02234bde 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -99,13 +99,14 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati Future breakingCheck(Github github) async { var getApiTool = await Process.run( 'dart', ['pub', 'global', 'activate', 'dart_apitool']); + print('getApiTool: err:${getApiTool.stderr}, out:${getApiTool.stdout}'); if (getApiTool.exitCode != 0) { throw ProcessException('dart pub global', ['activate dart_apitool'], 'Failed to install api tool'); } var runApiTool = await Process.run( 'dart-apitool', ['diff', '--old', '../base_repo', '--new', '.']); - + print('runApiTool: err:${runApiTool.stderr}, out:${runApiTool.stdout}'); return HealthCheckResult( 'breaking', _breakingBotTag, From d14f30ea2a958364f68d163436d986e5ea4ed2d8 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 29 Aug 2023 19:40:09 +0200 Subject: [PATCH 04/40] look in each package --- pkgs/firehose/lib/src/health/health.dart | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 02234bde..723a62d2 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -11,6 +11,7 @@ import 'package:collection/collection.dart'; import 'package:firehose/firehose.dart'; import '../github.dart'; +import '../repo.dart'; import '../utils.dart'; import 'changelog.dart'; import 'coverage.dart'; @@ -97,22 +98,29 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati } Future breakingCheck(Github github) async { - var getApiTool = await Process.run( - 'dart', ['pub', 'global', 'activate', 'dart_apitool']); - print('getApiTool: err:${getApiTool.stderr}, out:${getApiTool.stdout}'); - if (getApiTool.exitCode != 0) { - throw ProcessException('dart pub global', ['activate dart_apitool'], - 'Failed to install api tool'); + final repo = Repository(); + final packages = repo.locatePackages(); + var totalOut = ''; + for (var package in packages) { + print('Look for changes in ${package}'); + var getApiTool = await Process.run( + 'dart', ['pub', 'global', 'activate', 'dart_apitool']); + print('getApiTool: err:${getApiTool.stderr}, out:${getApiTool.stdout}'); + if (getApiTool.exitCode != 0) { + throw ProcessException('dart pub global', ['activate dart_apitool'], + 'Failed to install api tool'); + } + var runApiTool = await Process.run('dart-apitool', + ['diff', '--old', '../base_repo', '--new', package.directory.path]); + print('runApiTool: err:${runApiTool.stderr}, out:${runApiTool.stdout}'); + totalOut += runApiTool.stdout.toString(); } - var runApiTool = await Process.run( - 'dart-apitool', ['diff', '--old', '../base_repo', '--new', '.']); - print('runApiTool: err:${runApiTool.stderr}, out:${runApiTool.stdout}'); return HealthCheckResult( 'breaking', _breakingBotTag, - runApiTool.exitCode == 0 ? Severity.success : Severity.error, + Severity.info, ''' -${runApiTool.stdout} +$totalOut ''', ); } From c893a6fc66d09ba00e7ad60a39d492ad1bb9ff23 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 29 Aug 2023 19:47:58 +0200 Subject: [PATCH 05/40] debug --- pkgs/firehose/lib/src/health/health.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 723a62d2..1e19ed6f 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -101,17 +101,23 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati final repo = Repository(); final packages = repo.locatePackages(); var totalOut = ''; + var baseDirectory = Directory('../base_repo'); for (var package in packages) { - print('Look for changes in ${package}'); - var getApiTool = await Process.run( + print('Look for changes in $package with base ${baseDirectory.path}'); + var getApiTool = Process.runSync( 'dart', ['pub', 'global', 'activate', 'dart_apitool']); print('getApiTool: err:${getApiTool.stderr}, out:${getApiTool.stdout}'); if (getApiTool.exitCode != 0) { throw ProcessException('dart pub global', ['activate dart_apitool'], 'Failed to install api tool'); } - var runApiTool = await Process.run('dart-apitool', - ['diff', '--old', '../base_repo', '--new', package.directory.path]); + var runApiTool = Process.runSync('dart-apitool', [ + 'diff', + '--old', + baseDirectory.path, + '--new', + package.directory.path, + ]); print('runApiTool: err:${runApiTool.stderr}, out:${runApiTool.stdout}'); totalOut += runApiTool.stdout.toString(); } From 54b00b7f5934e51df9ccb3ea43f6d3fecde64442 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 29 Aug 2023 20:01:37 +0200 Subject: [PATCH 06/40] take subpackage --- pkgs/firehose/lib/src/health/health.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 1e19ed6f..f8cb4aa3 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -16,6 +16,7 @@ import '../utils.dart'; import 'changelog.dart'; import 'coverage.dart'; import 'license.dart'; +import 'package:path/path.dart' as path; const String _botSuffix = '[bot]'; @@ -103,7 +104,10 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati var totalOut = ''; var baseDirectory = Directory('../base_repo'); for (var package in packages) { - print('Look for changes in $package with base ${baseDirectory.path}'); + var basePackage = path.join(baseDirectory.path, + path.relative(package.directory.path, from: Directory.current.path)); + print( + 'Look for changes in ${package.directory.path} with base $basePackage'); var getApiTool = Process.runSync( 'dart', ['pub', 'global', 'activate', 'dart_apitool']); print('getApiTool: err:${getApiTool.stderr}, out:${getApiTool.stdout}'); @@ -114,7 +118,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati var runApiTool = Process.runSync('dart-apitool', [ 'diff', '--old', - baseDirectory.path, + basePackage, '--new', package.directory.path, ]); From ed7c17cefcc57537cae0f028b0dc3b94ebfeca3a Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 29 Aug 2023 20:07:08 +0200 Subject: [PATCH 07/40] Run in current --- pkgs/firehose/lib/src/health/health.dart | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index f8cb4aa3..1b7ac6ae 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -104,10 +104,10 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati var totalOut = ''; var baseDirectory = Directory('../base_repo'); for (var package in packages) { - var basePackage = path.join(baseDirectory.path, - path.relative(package.directory.path, from: Directory.current.path)); - print( - 'Look for changes in ${package.directory.path} with base $basePackage'); + var currentPath = + path.relative(package.directory.path, from: Directory.current.path); + var basePackage = path.join(baseDirectory.path, currentPath); + print('Look for changes in $currentPath with base $basePackage'); var getApiTool = Process.runSync( 'dart', ['pub', 'global', 'activate', 'dart_apitool']); print('getApiTool: err:${getApiTool.stderr}, out:${getApiTool.stdout}'); @@ -115,13 +115,17 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati throw ProcessException('dart pub global', ['activate dart_apitool'], 'Failed to install api tool'); } - var runApiTool = Process.runSync('dart-apitool', [ - 'diff', - '--old', - basePackage, - '--new', - package.directory.path, - ]); + var runApiTool = Process.runSync( + 'dart-apitool', + [ + 'diff', + '--old', + basePackage, + '--new', + '.', + ], + workingDirectory: currentPath, + ); print('runApiTool: err:${runApiTool.stderr}, out:${runApiTool.stdout}'); totalOut += runApiTool.stdout.toString(); } From 597f95dd33ba43069076c196dd06949cdffff5ce Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 29 Aug 2023 20:11:31 +0200 Subject: [PATCH 08/40] add debug --- pkgs/firehose/lib/src/health/health.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 1b7ac6ae..0af50ce6 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -110,11 +110,8 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati print('Look for changes in $currentPath with base $basePackage'); var getApiTool = Process.runSync( 'dart', ['pub', 'global', 'activate', 'dart_apitool']); - print('getApiTool: err:${getApiTool.stderr}, out:${getApiTool.stdout}'); - if (getApiTool.exitCode != 0) { - throw ProcessException('dart pub global', ['activate dart_apitool'], - 'Failed to install api tool'); - } + print( + 'getApiTool: err:!!!${getApiTool.stderr}!!!\nout: ???${getApiTool.stdout}???'); var runApiTool = Process.runSync( 'dart-apitool', [ From 16020499831eaa7cc594eeae31229553b7c23509 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 29 Aug 2023 20:15:10 +0200 Subject: [PATCH 09/40] debug --- .github/workflows/health_internal.yaml | 2 ++ pkgs/firehose/lib/src/health/health.dart | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml index 036e67a0..0577bd9f 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -11,3 +11,5 @@ jobs: with: local_debug: true coverage_web: false + upload_coverage: false + checks: breaking diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 0af50ce6..46e05be5 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -106,7 +106,10 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati for (var package in packages) { var currentPath = path.relative(package.directory.path, from: Directory.current.path); - var basePackage = path.join(baseDirectory.path, currentPath); + var basePackage = path.relative( + path.join(baseDirectory.absolute.path, currentPath), + from: currentPath, + ); print('Look for changes in $currentPath with base $basePackage'); var getApiTool = Process.runSync( 'dart', ['pub', 'global', 'activate', 'dart_apitool']); From d04f966cdc868b12ed0172461c5149496a7c2aa7 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 29 Aug 2023 20:17:08 +0200 Subject: [PATCH 10/40] Add argument for testing --- pkgs/firehose/bin/firehose.dart | 2 +- pkgs/firehose/lib/firehose.dart | 2 +- pkgs/firehose/lib/src/health/health.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/firehose/bin/firehose.dart b/pkgs/firehose/bin/firehose.dart index e561bd98..f4fb7d41 100644 --- a/pkgs/firehose/bin/firehose.dart +++ b/pkgs/firehose/bin/firehose.dart @@ -35,7 +35,7 @@ void main(List arguments) async { exit(1); } - var firehose = Firehose(Directory.current); + var firehose = Firehose(Directory.current, true); if (validate) { await firehose.validate(); diff --git a/pkgs/firehose/lib/firehose.dart b/pkgs/firehose/lib/firehose.dart index 55041cad..b959eb75 100644 --- a/pkgs/firehose/lib/firehose.dart +++ b/pkgs/firehose/lib/firehose.dart @@ -24,7 +24,7 @@ const String _ignoreWarningsLabel = 'publish-ignore-warnings'; class Firehose { final Directory directory; - Firehose(this.directory); + Firehose(this.directory, bool requiredBoolean); /// Validate the packages in the repository. /// diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 46e05be5..25c00c0c 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -80,7 +80,7 @@ class Health { } Future validateCheck(Github github) async { - var results = await Firehose(directory).verify(github); + var results = await Firehose(directory, true).verify(github); var markdownTable = ''' | Package | Version | Status | From e6d2c5de68b096b800b31c08a58e307835ed3ce5 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 30 Aug 2023 13:58:24 +0200 Subject: [PATCH 11/40] Switch to local copy --- .github/workflows/health.yaml | 6 ++++++ pkgs/firehose/lib/src/health/health.dart | 25 ++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index d650d294..aa532570 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -80,6 +80,12 @@ jobs: with: ref: ${{ github.event.pull_request.base.ref }} path: base_repo/ + + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + with: + repository: mosuem/dart_apitool + ref: pubspecOverridesSupport + path: apitool/ - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 25c00c0c..0b4e0f72 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -111,20 +111,33 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati from: currentPath, ); print('Look for changes in $currentPath with base $basePackage'); - var getApiTool = Process.runSync( - 'dart', ['pub', 'global', 'activate', 'dart_apitool']); - print( - 'getApiTool: err:!!!${getApiTool.stderr}!!!\nout: ???${getApiTool.stdout}???'); + // var getApiTool = Process.runSync( + // 'dart', ['pub', 'global', 'activate', 'dart_apitool']); + // print( + // 'getApiTool: err:!!!${getApiTool.stderr}!!!\nout: ???${getApiTool.stdout}???'); + // var runApiTool = Process.runSync( + // 'dart-apitool', + // [ + // 'diff', + // '--old', + // basePackage, + // '--new', + // '.', + // ], + // workingDirectory: currentPath, + // ); var runApiTool = Process.runSync( - 'dart-apitool', + 'dart', [ + 'run', + 'bin/main.dart', 'diff', '--old', basePackage, '--new', '.', ], - workingDirectory: currentPath, + workingDirectory: '../apitool/', ); print('runApiTool: err:${runApiTool.stderr}, out:${runApiTool.stdout}'); totalOut += runApiTool.stdout.toString(); From 11c1093218ffc199c835a65331c2a52454ac3af1 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 30 Aug 2023 14:01:51 +0200 Subject: [PATCH 12/40] Add pub get to apitool clone --- .github/workflows/health.yaml | 3 +++ pkgs/base_repo | 1 + 2 files changed, 4 insertions(+) create mode 160000 pkgs/base_repo diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index aa532570..8d07ebfb 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -86,6 +86,9 @@ jobs: repository: mosuem/dart_apitool ref: pubspecOverridesSupport path: apitool/ + + - name: Init apitool + run: (cd apitool/; dart pub get) - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: diff --git a/pkgs/base_repo b/pkgs/base_repo new file mode 160000 index 00000000..65817bf1 --- /dev/null +++ b/pkgs/base_repo @@ -0,0 +1 @@ +Subproject commit 65817bf10a4e5c45a99299aa4ae92a0993bf9847 From e694a6f6cf7ea6ab3a7163c2d50c62cca737a632 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 30 Aug 2023 14:02:49 +0200 Subject: [PATCH 13/40] move dart install --- .github/workflows/health.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index 8d07ebfb..d0b3de6b 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -72,6 +72,10 @@ jobs: runs-on: ubuntu-latest steps: + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + with: + sdk: ${{ inputs.sdk }} + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 with: path: current_repo/ @@ -89,11 +93,7 @@ jobs: - name: Init apitool run: (cd apitool/; dart pub get) - - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f - with: - sdk: ${{ inputs.sdk }} - + - name: Install coverage run: dart pub global activate coverage From 42f750dbf687544aa19cc142d483ebcdc940573b Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 30 Aug 2023 14:04:49 +0200 Subject: [PATCH 14/40] Revert changes --- .github/workflows/health.yaml | 17 ++++------------ pkgs/firehose/lib/src/health/health.dart | 25 ++++++------------------ 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index d0b3de6b..d650d294 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -72,10 +72,6 @@ jobs: runs-on: ubuntu-latest steps: - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f - with: - sdk: ${{ inputs.sdk }} - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 with: path: current_repo/ @@ -84,16 +80,11 @@ jobs: with: ref: ${{ github.event.pull_request.base.ref }} path: base_repo/ - - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: - repository: mosuem/dart_apitool - ref: pubspecOverridesSupport - path: apitool/ - - - name: Init apitool - run: (cd apitool/; dart pub get) - + sdk: ${{ inputs.sdk }} + - name: Install coverage run: dart pub global activate coverage diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 0b4e0f72..25c00c0c 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -111,33 +111,20 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati from: currentPath, ); print('Look for changes in $currentPath with base $basePackage'); - // var getApiTool = Process.runSync( - // 'dart', ['pub', 'global', 'activate', 'dart_apitool']); - // print( - // 'getApiTool: err:!!!${getApiTool.stderr}!!!\nout: ???${getApiTool.stdout}???'); - // var runApiTool = Process.runSync( - // 'dart-apitool', - // [ - // 'diff', - // '--old', - // basePackage, - // '--new', - // '.', - // ], - // workingDirectory: currentPath, - // ); + var getApiTool = Process.runSync( + 'dart', ['pub', 'global', 'activate', 'dart_apitool']); + print( + 'getApiTool: err:!!!${getApiTool.stderr}!!!\nout: ???${getApiTool.stdout}???'); var runApiTool = Process.runSync( - 'dart', + 'dart-apitool', [ - 'run', - 'bin/main.dart', 'diff', '--old', basePackage, '--new', '.', ], - workingDirectory: '../apitool/', + workingDirectory: currentPath, ); print('runApiTool: err:${runApiTool.stderr}, out:${runApiTool.stdout}'); totalOut += runApiTool.stdout.toString(); From 5a306078b5df97edeb6203d813b24c82f490c315 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 11 Sep 2023 09:49:09 +0200 Subject: [PATCH 15/40] Fix ref --- .github/workflows/health.yaml | 5 ++++- pkgs/firehose/lib/src/health/health.dart | 4 ---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index d650d294..e3834fb4 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -29,7 +29,7 @@ name: Health # uses: dart-lang/ecosystem/.github/workflows/health.yaml@main # with: # sdk: beta -# checks: "version,changelog,license,coverage" +# checks: "version,changelog,license,coverage,breaking" on: workflow_call: @@ -92,6 +92,9 @@ jobs: run: dart pub global activate firehose if: ${{ !inputs.local_debug }} + - name: Install api_tool + run: dart pub global activate --source git https://github.com/devmil/dart_apitool_fork --git-ref=fd64e2fec167d0b2c06085340f95392824946877 + - name: Install local firehose run: dart pub global activate --source path current_repo/pkgs/firehose/ if: ${{ inputs.local_debug }} diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 25c00c0c..6d0187b3 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -111,10 +111,6 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati from: currentPath, ); print('Look for changes in $currentPath with base $basePackage'); - var getApiTool = Process.runSync( - 'dart', ['pub', 'global', 'activate', 'dart_apitool']); - print( - 'getApiTool: err:!!!${getApiTool.stderr}!!!\nout: ???${getApiTool.stdout}???'); var runApiTool = Process.runSync( 'dart-apitool', [ From ab4cdb407d0ae5bf6220846aad0298ef8c7d8cdc Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 11 Sep 2023 09:59:06 +0200 Subject: [PATCH 16/40] dart fix --- 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 2ee2245a..9b0eb898 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -9,6 +9,7 @@ import 'dart:math'; import 'package:collection/collection.dart'; import 'package:firehose/firehose.dart'; +import 'package:path/path.dart' as path; import '../github.dart'; import '../repo.dart'; @@ -16,7 +17,6 @@ import '../utils.dart'; import 'changelog.dart'; import 'coverage.dart'; import 'license.dart'; -import 'package:path/path.dart' as path; const String _botSuffix = '[bot]'; From 36aac52e0bcfa1596ac61982394ec53234937b07 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 12 Sep 2023 13:59:22 +0200 Subject: [PATCH 17/40] Switch to main branch --- .github/workflows/health.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index 4b2457c8..b9648164 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -93,7 +93,7 @@ jobs: if: ${{ !inputs.local_debug }} - name: Install api_tool - run: dart pub global activate --source git https://github.com/devmil/dart_apitool_fork --git-ref=fd64e2fec167d0b2c06085340f95392824946877 + run: dart pub global activate --source git https://github.com/bmw-tech/dart_apitool - name: Install local firehose run: dart pub global activate --source path current_repo/pkgs/firehose/ From 2cbfdc8854195b71dedd3336819f1aa10cc0b10d Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 14:36:25 +0200 Subject: [PATCH 18/40] use new --- pkgs/firehose/lib/src/health/health.dart | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index fbe1c00d..a812f603 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -11,7 +11,6 @@ import 'package:collection/collection.dart'; import 'package:firehose/firehose.dart'; import 'package:path/path.dart' as path; -import '../../firehose.dart'; import '../github.dart'; import '../repo.dart'; import '../utils.dart'; @@ -117,10 +116,9 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati 'dart-apitool', [ 'diff', - '--old', - basePackage, - '--new', - '.', + ...['--old', basePackage], + ...['--new', '.'], + ...['--report-format', 'json'], ], workingDirectory: currentPath, ); From 459b25ce86818894f5af830aa85fa00b66f5a607 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 15:01:22 +0200 Subject: [PATCH 19/40] use report file --- pkgs/firehose/lib/src/health/health.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index a812f603..0633325c 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -112,18 +112,20 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati from: currentPath, ); print('Look for changes in $currentPath with base $basePackage'); - var runApiTool = Process.runSync( + final runApiTool = Process.runSync( 'dart-apitool', [ 'diff', ...['--old', basePackage], ...['--new', '.'], ...['--report-format', 'json'], + ...['--report-file-path', 'report.json'], ], workingDirectory: currentPath, ); print('runApiTool: err:${runApiTool.stderr}, out:${runApiTool.stdout}'); - totalOut += runApiTool.stdout.toString(); + final reportFile = File(path.join(currentPath, 'report.json')); + totalOut += reportFile.readAsStringSync(); } return HealthCheckResult( 'breaking', From ada423495503d0f90d5499af1994eee49f0c87a1 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 15:11:41 +0200 Subject: [PATCH 20/40] Add test argument --- pkgs/firehose/bin/firehose.dart | 2 +- pkgs/firehose/lib/firehose.dart | 4 +++- pkgs/firehose/lib/src/health/health.dart | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/firehose/bin/firehose.dart b/pkgs/firehose/bin/firehose.dart index 089648cd..e86fd7f2 100644 --- a/pkgs/firehose/bin/firehose.dart +++ b/pkgs/firehose/bin/firehose.dart @@ -41,7 +41,7 @@ void main(List arguments) async { exit(1); } - final firehose = Firehose(Directory.current, useFlutter); + final firehose = Firehose(Directory.current, useFlutter, ''); if (validate) { await firehose.validate(); diff --git a/pkgs/firehose/lib/firehose.dart b/pkgs/firehose/lib/firehose.dart index c6dfb44a..18078cc0 100644 --- a/pkgs/firehose/lib/firehose.dart +++ b/pkgs/firehose/lib/firehose.dart @@ -24,7 +24,9 @@ class Firehose { final Directory directory; final bool useFlutter; - Firehose(this.directory, this.useFlutter); + final String testArg; + + Firehose(this.directory, this.useFlutter, this.testArg); /// Validate the packages in the repository. /// diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 0633325c..e248184c 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -81,7 +81,7 @@ class Health { Future validateCheck(Github github) async { //TODO: Add Flutter support for PR health checks - var results = await Firehose(directory, false).verify(github); + var results = await Firehose(directory, false, '').verify(github); var markdownTable = ''' | Package | Version | Status | From 5542840493a498c009638c4b19b190adb5ce185f Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 15:12:42 +0200 Subject: [PATCH 21/40] Organize imports --- 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 e248184c..c10dff45 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -8,9 +8,9 @@ import 'dart:io'; import 'dart:math'; import 'package:collection/collection.dart'; -import 'package:firehose/firehose.dart'; import 'package:path/path.dart' as path; +import '../../firehose.dart'; import '../github.dart'; import '../repo.dart'; import '../utils.dart'; From 0ad660a6420ddf041a1c2689ff53e359d3c6a581 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 15:58:49 +0200 Subject: [PATCH 22/40] Nicer output --- pkgs/firehose/lib/src/health/health.dart | 71 ++++++++++++++++++++++-- pkgs/firehose/lib/src/repo.dart | 3 +- pkgs/firehose/test/repo_test.dart | 2 +- 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index c10dff45..0c14320f 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -4,11 +4,13 @@ // ignore_for_file: always_declare_return_types +import 'dart:convert'; import 'dart:io'; import 'dart:math'; import 'package:collection/collection.dart'; import 'package:path/path.dart' as path; +import 'package:pub_semver/pub_semver.dart'; import '../../firehose.dart'; import '../github.dart'; @@ -102,7 +104,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati Future breakingCheck(Github github) async { final repo = Repository(); final packages = repo.locatePackages(); - var totalOut = ''; + var packagesWithBreakingChanges = {}; var baseDirectory = Directory('../base_repo'); for (var package in packages) { var currentPath = @@ -123,16 +125,47 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati ], workingDirectory: currentPath, ); - print('runApiTool: err:${runApiTool.stderr}, out:${runApiTool.stdout}'); + var stdout = runApiTool.stdout as String; + var lines = stdout.split('\n'); + var oldVersion = Version.parse( + lines.firstWhere((line) => line.startsWith('Old version:'))); + var newVersion = package.version!; + + print('runApiTool: err: ${runApiTool.stderr}, out: $stdout'); final reportFile = File(path.join(currentPath, 'report.json')); - totalOut += reportFile.readAsStringSync(); + var fullReportString = reportFile.readAsStringSync(); + var decoded = jsonDecode(fullReportString) as Map; + var fullReport = decoded['report'] as Map; + BreakingLevel breakingLevel; + if ((fullReport['noChangesDetected'] as bool?) ?? false) { + breakingLevel = BreakingLevel.none; + } else { + var breaking = fullReport['breakingChanges'] as Map; + var nonBreaking = + fullReport['nonBreakingChanges'] as Map; + + if (breaking.isNotEmpty) { + breakingLevel = BreakingLevel.breaking; + } else if (nonBreaking.isNotEmpty) { + breakingLevel = BreakingLevel.nonBreaking; + } else { + breakingLevel = BreakingLevel.none; + } + } + packagesWithBreakingChanges[package] = BreakingChange( + level: breakingLevel, + oldVersion: oldVersion, + newVersion: newVersion, + ); } return HealthCheckResult( 'breaking', _breakingBotTag, Severity.info, ''' -$totalOut +| Package | Has Breaking Changes | Current Version | Needed Version | Needs version rev | +| :--- | :---: | ---: | ---: | ---: | +${packagesWithBreakingChanges.entries.map((e) => '|${e.key}|${e.value.level}|${e.value.newVersion}|${e.value.suggestedNewVersion}|${e.value.versionIsFine}|').join('\n')} ''', ); } @@ -282,6 +315,20 @@ Saving existing comment id $existingCommentId to file ${idFile.path}'''); } } +Version getNewVersion(BreakingLevel level, Version oldVersion) { + return switch (level) { + BreakingLevel.none => oldVersion, + BreakingLevel.nonBreaking => oldVersion.nextMinor, + BreakingLevel.breaking => oldVersion.nextBreaking, + }; +} + +enum BreakingLevel { + none, + nonBreaking, + breaking, +} + class HealthCheckResult { final String name; final String tag; @@ -290,3 +337,19 @@ class HealthCheckResult { HealthCheckResult(this.name, this.tag, this.severity, this.markdown); } + +class BreakingChange { + final BreakingLevel level; + final Version oldVersion; + final Version newVersion; + + BreakingChange({ + required this.level, + required this.oldVersion, + required this.newVersion, + }); + + Version get suggestedNewVersion => getNewVersion(level, oldVersion); + + bool get versionIsFine => newVersion == suggestedNewVersion; +} diff --git a/pkgs/firehose/lib/src/repo.dart b/pkgs/firehose/lib/src/repo.dart index 8336a5a5..0ca96acb 100644 --- a/pkgs/firehose/lib/src/repo.dart +++ b/pkgs/firehose/lib/src/repo.dart @@ -5,6 +5,7 @@ import 'dart:io'; import 'package:path/path.dart' as path; +import 'package:pub_semver/pub_semver.dart'; import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:yaml/yaml.dart' as yaml; @@ -99,7 +100,7 @@ class Package { String get name => pubspec.name; - String? get version => pubspec.version?.toString(); + Version? get version => pubspec.version; @override String toString() { diff --git a/pkgs/firehose/test/repo_test.dart b/pkgs/firehose/test/repo_test.dart index 283a4e3b..34e93aea 100644 --- a/pkgs/firehose/test/repo_test.dart +++ b/pkgs/firehose/test/repo_test.dart @@ -34,7 +34,7 @@ void main() { final queryParams = releaseUri.queryParameters; expect(queryParams['tag'], packages.calculateRepoTag(package)); expect(queryParams['title'], - allOf(contains(package.name), contains(package.version))); + allOf(contains(package.name), contains(package.version.toString()))); expect(queryParams['body'], package.changelog.describeLatestChanges); }); }); From 510abf95576c05153f5ed596fa908156e97b7a2e Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:02:21 +0200 Subject: [PATCH 23/40] Fix version --- pkgs/firehose/lib/src/health/health.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 0c14320f..8b23d99f 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -125,13 +125,10 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati ], workingDirectory: currentPath, ); - var stdout = runApiTool.stdout as String; - var lines = stdout.split('\n'); - var oldVersion = Version.parse( - lines.firstWhere((line) => line.startsWith('Old version:'))); + var oldVersion = Package(Directory(basePackage), package.repository); var newVersion = package.version!; - print('runApiTool: err: ${runApiTool.stderr}, out: $stdout'); + print('runApiTool: err: ${runApiTool.stderr}, out: ${runApiTool.stdout}'); final reportFile = File(path.join(currentPath, 'report.json')); var fullReportString = reportFile.readAsStringSync(); var decoded = jsonDecode(fullReportString) as Map; From dab1b08ce570c1d32cbea8547d1cdc366aa224b2 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:02:44 +0200 Subject: [PATCH 24/40] Really fix --- pkgs/firehose/lib/src/health/health.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 8b23d99f..78932846 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -125,7 +125,8 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati ], workingDirectory: currentPath, ); - var oldVersion = Package(Directory(basePackage), package.repository); + var oldVersion = + Package(Directory(basePackage), package.repository).version!; var newVersion = package.version!; print('runApiTool: err: ${runApiTool.stderr}, out: ${runApiTool.stdout}'); From 6f8bdc499a8b65d05bd7f22855e594f1330befea Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:05:31 +0200 Subject: [PATCH 25/40] fix path --- pkgs/firehose/lib/src/health/health.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 78932846..b38039de 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -125,8 +125,10 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati ], workingDirectory: currentPath, ); - var oldVersion = - Package(Directory(basePackage), package.repository).version!; + var oldVersion = Package( + Directory(path.join(baseDirectory.path, currentPath)), + package.repository) + .version!; var newVersion = package.version!; print('runApiTool: err: ${runApiTool.stderr}, out: ${runApiTool.stdout}'); From 078566c62f3310c2b8aa245d203e705564fc3a84 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:11:39 +0200 Subject: [PATCH 26/40] Make nicer --- pkgs/firehose/lib/src/health/health.dart | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index b38039de..02499fae 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -163,9 +163,9 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati _breakingBotTag, Severity.info, ''' -| Package | Has Breaking Changes | Current Version | Needed Version | Needs version rev | +| Package | Change | Current Version | Needed Version | Needs version rev | | :--- | :---: | ---: | ---: | ---: | -${packagesWithBreakingChanges.entries.map((e) => '|${e.key}|${e.value.level}|${e.value.newVersion}|${e.value.suggestedNewVersion}|${e.value.versionIsFine}|').join('\n')} +${packagesWithBreakingChanges.entries.map((e) => '|${e.key.name}|${e.value.toRow().join('|')}|').join('\n')} ''', ); } @@ -324,9 +324,13 @@ Version getNewVersion(BreakingLevel level, Version oldVersion) { } enum BreakingLevel { - none, - nonBreaking, - breaking, + none('none'), + nonBreaking('Non-Breaking'), + breaking('Breaking'); + + final String name; + + const BreakingLevel(this.name); } class HealthCheckResult { @@ -352,4 +356,11 @@ class BreakingChange { Version get suggestedNewVersion => getNewVersion(level, oldVersion); bool get versionIsFine => newVersion == suggestedNewVersion; + + Iterable toRow() => [ + level.name, + newVersion, + suggestedNewVersion, + versionIsFine ? ':heavy_check_mark:' : ':warning:' + ].map((e) => e.toString()); } From 7fd83a7709597dd60dc9b5e581e223751f7a9d64 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:12:24 +0200 Subject: [PATCH 27/40] Add severity --- pkgs/firehose/lib/src/health/health.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 02499fae..6f616306 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -161,7 +161,10 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati return HealthCheckResult( 'breaking', _breakingBotTag, - Severity.info, + packagesWithBreakingChanges.values + .any((element) => !element.versionIsFine) + ? Severity.warning + : Severity.info, ''' | Package | Change | Current Version | Needed Version | Needs version rev | | :--- | :---: | ---: | ---: | ---: | From bdf61fa1d43519fba62975ffd1e14a99bfd5df13 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:21:44 +0200 Subject: [PATCH 28/40] Even nicer --- pkgs/firehose/lib/src/health/health.dart | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 6f616306..6180df44 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -104,7 +104,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati Future breakingCheck(Github github) async { final repo = Repository(); final packages = repo.locatePackages(); - var packagesWithBreakingChanges = {}; + var changeForPackage = {}; var baseDirectory = Directory('../base_repo'); for (var package in packages) { var currentPath = @@ -152,7 +152,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati breakingLevel = BreakingLevel.none; } } - packagesWithBreakingChanges[package] = BreakingChange( + changeForPackage[package] = BreakingChange( level: breakingLevel, oldVersion: oldVersion, newVersion: newVersion, @@ -161,14 +161,13 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati return HealthCheckResult( 'breaking', _breakingBotTag, - packagesWithBreakingChanges.values - .any((element) => !element.versionIsFine) + changeForPackage.values.any((element) => !element.versionIsFine) ? Severity.warning : Severity.info, ''' -| Package | Change | Current Version | Needed Version | Needs version rev | -| :--- | :---: | ---: | ---: | ---: | -${packagesWithBreakingChanges.entries.map((e) => '|${e.key.name}|${e.value.toRow().join('|')}|').join('\n')} +| Package | Change | Current Version | New Version | Needed Version | Looking good? | +| :--- | :--- | ---: | ---: | ---: | +${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}|').join('\n')} ''', ); } @@ -360,10 +359,11 @@ class BreakingChange { bool get versionIsFine => newVersion == suggestedNewVersion; - Iterable toRow() => [ + String toMarkdownRow() => [ level.name, + oldVersion, newVersion, - suggestedNewVersion, + versionIsFine ? suggestedNewVersion : '*$suggestedNewVersion*', versionIsFine ? ':heavy_check_mark:' : ':warning:' - ].map((e) => e.toString()); + ].map((e) => e.toString()).join('|'); } From 9ebdbabf13022e1eba8462fdfdae3f56a4da3001 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:24:07 +0200 Subject: [PATCH 29/40] Fix layout --- pkgs/firehose/lib/src/health/health.dart | 31 ++++++++++-------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 6180df44..d18a0e9c 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -114,7 +114,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati from: currentPath, ); print('Look for changes in $currentPath with base $basePackage'); - final runApiTool = Process.runSync( + Process.runSync( 'dart-apitool', [ 'diff', @@ -125,37 +125,32 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati ], workingDirectory: currentPath, ); - var oldVersion = Package( - Directory(path.join(baseDirectory.path, currentPath)), - package.repository) - .version!; - var newVersion = package.version!; - print('runApiTool: err: ${runApiTool.stderr}, out: ${runApiTool.stdout}'); final reportFile = File(path.join(currentPath, 'report.json')); var fullReportString = reportFile.readAsStringSync(); var decoded = jsonDecode(fullReportString) as Map; - var fullReport = decoded['report'] as Map; + var report = decoded['report'] as Map; BreakingLevel breakingLevel; - if ((fullReport['noChangesDetected'] as bool?) ?? false) { + if ((report['noChangesDetected'] as bool?) ?? false) { breakingLevel = BreakingLevel.none; } else { - var breaking = fullReport['breakingChanges'] as Map; - var nonBreaking = - fullReport['nonBreakingChanges'] as Map; - - if (breaking.isNotEmpty) { + if ((report['breakingChanges'] as Map).isNotEmpty) { breakingLevel = BreakingLevel.breaking; - } else if (nonBreaking.isNotEmpty) { + } else if ((report['nonBreakingChanges'] as Map).isNotEmpty) { breakingLevel = BreakingLevel.nonBreaking; } else { breakingLevel = BreakingLevel.none; } } + + var oldPackage = Package( + Directory(path.join(baseDirectory.path, currentPath)), + package.repository, + ); changeForPackage[package] = BreakingChange( level: breakingLevel, - oldVersion: oldVersion, - newVersion: newVersion, + oldVersion: oldPackage.version!, + newVersion: package.version!, ); } return HealthCheckResult( @@ -166,7 +161,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati : Severity.info, ''' | Package | Change | Current Version | New Version | Needed Version | Looking good? | -| :--- | :--- | ---: | ---: | ---: | +| :--- | :--- | ---: | ---: | ---: | ---: | ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()}|').join('\n')} ''', ); From bf6746ab91069fa8f1f0d596c00ec82e2d762412 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:26:29 +0200 Subject: [PATCH 30/40] Make bold --- pkgs/firehose/lib/src/health/health.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index d18a0e9c..d38515ac 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -114,7 +114,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati from: currentPath, ); print('Look for changes in $currentPath with base $basePackage'); - Process.runSync( + var runApiTool = Process.runSync( 'dart-apitool', [ 'diff', @@ -125,6 +125,8 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati ], workingDirectory: currentPath, ); + print(runApiTool.stderr); + print(runApiTool.stdout); final reportFile = File(path.join(currentPath, 'report.json')); var fullReportString = reportFile.readAsStringSync(); @@ -358,7 +360,7 @@ class BreakingChange { level.name, oldVersion, newVersion, - versionIsFine ? suggestedNewVersion : '*$suggestedNewVersion*', + versionIsFine ? suggestedNewVersion : '_${suggestedNewVersion}_', versionIsFine ? ':heavy_check_mark:' : ':warning:' ].map((e) => e.toString()).join('|'); } From b88a2d1383a3bf86e95e338f1a1c8586d392e16d Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:26:51 +0200 Subject: [PATCH 31/40] Capitalize --- 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 d38515ac..28c566cd 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -323,7 +323,7 @@ Version getNewVersion(BreakingLevel level, Version oldVersion) { } enum BreakingLevel { - none('none'), + none('None'), nonBreaking('Non-Breaking'), breaking('Breaking'); From f4e9682f90613d40ca15e8d3381a74209156a76b Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:35:32 +0200 Subject: [PATCH 32/40] Really bolden --- 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 28c566cd..93272a92 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -360,7 +360,7 @@ class BreakingChange { level.name, oldVersion, newVersion, - versionIsFine ? suggestedNewVersion : '_${suggestedNewVersion}_', + versionIsFine ? suggestedNewVersion : '**$suggestedNewVersion**', versionIsFine ? ':heavy_check_mark:' : ':warning:' ].map((e) => e.toString()).join('|'); } From f0e944c5906348bc866f3f7eec876f65c26865ad Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:38:39 +0200 Subject: [PATCH 33/40] Enable all checks --- .github/workflows/health_internal.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml index 0577bd9f..826bc488 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -12,4 +12,4 @@ jobs: local_debug: true coverage_web: false upload_coverage: false - checks: breaking + checks: version,changelog,license,coverage,breaking From 26c1ba9fa2b4aec8e0e01cf2464c72398f3e042c Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:42:35 +0200 Subject: [PATCH 34/40] 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 f3d87b93..2efbc418 100644 --- a/pkgs/firehose/CHANGELOG.md +++ b/pkgs/firehose/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.31 + +- Add PR Health checks for breaking changes. + ## 0.3.30 - Improve support for `-dev` and `-wip` package versions. diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml index 3f16ad1c..a2caf145 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.3.30 +version: 0.3.31 repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose environment: From ca1d30016b911d45d87b1b602188795ee70acf7c Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:51:13 +0200 Subject: [PATCH 35/40] Make nullsafer --- pkgs/firehose/lib/src/health/health.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 93272a92..2b72b20f 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -136,9 +136,9 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati if ((report['noChangesDetected'] as bool?) ?? false) { breakingLevel = BreakingLevel.none; } else { - if ((report['breakingChanges'] as Map).isNotEmpty) { + if ((report['breakingChanges'] as Map? ?? {}).isNotEmpty) { breakingLevel = BreakingLevel.breaking; - } else if ((report['nonBreakingChanges'] as Map).isNotEmpty) { + } else if ((report['nonBreakingChanges'] as Map? ?? {}).isNotEmpty) { breakingLevel = BreakingLevel.nonBreaking; } else { breakingLevel = BreakingLevel.none; From 25381344e1409a962afa4757316df2b366f524e1 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 16:52:52 +0200 Subject: [PATCH 36/40] add DO_NOT_SUBMIT --- pkgs/firehose/lib/firehose.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/firehose/lib/firehose.dart b/pkgs/firehose/lib/firehose.dart index 18078cc0..45c556ca 100644 --- a/pkgs/firehose/lib/firehose.dart +++ b/pkgs/firehose/lib/firehose.dart @@ -24,6 +24,7 @@ class Firehose { final Directory directory; final bool useFlutter; + //DO_NOT_SUBMIT final String testArg; Firehose(this.directory, this.useFlutter, this.testArg); From 14c9a94075d3f6cbd715a7635322c2017c892684 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 27 Sep 2023 17:51:45 +0200 Subject: [PATCH 37/40] Remove empty file --- pkgs/base_repo | 1 - 1 file changed, 1 deletion(-) delete mode 160000 pkgs/base_repo diff --git a/pkgs/base_repo b/pkgs/base_repo deleted file mode 160000 index 65817bf1..00000000 --- a/pkgs/base_repo +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 65817bf10a4e5c45a99299aa4ae92a0993bf9847 From 82c2a4fbebb137f2291e1f9532089f8857c4b0de Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 28 Sep 2023 12:55:01 +0200 Subject: [PATCH 38/40] Changes as per review --- pkgs/firehose/lib/src/health/health.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 2b72b20f..1114e0b7 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -115,8 +115,10 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati ); print('Look for changes in $currentPath with base $basePackage'); var runApiTool = Process.runSync( - 'dart-apitool', + 'dart', [ + ...['pub', 'global', 'run'], + 'dart-apitool', 'diff', ...['--old', basePackage], ...['--new', '.'], @@ -132,6 +134,10 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati var fullReportString = reportFile.readAsStringSync(); var decoded = jsonDecode(fullReportString) as Map; var report = decoded['report'] as Map; + + var formattedChanges = const JsonEncoder.withIndent(' ').convert(report); + print('Breaking change report:\n$formattedChanges'); + BreakingLevel breakingLevel; if ((report['noChangesDetected'] as bool?) ?? false) { breakingLevel = BreakingLevel.none; From a2c044cd0e5c1f6f205a59ecd9590d4429af9b70 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 28 Sep 2023 12:57:36 +0200 Subject: [PATCH 39/40] Revert "Add test argument" This reverts commit ada423495503d0f90d5499af1994eee49f0c87a1. --- pkgs/firehose/bin/firehose.dart | 2 +- pkgs/firehose/lib/firehose.dart | 5 +---- pkgs/firehose/lib/src/health/health.dart | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pkgs/firehose/bin/firehose.dart b/pkgs/firehose/bin/firehose.dart index e86fd7f2..089648cd 100644 --- a/pkgs/firehose/bin/firehose.dart +++ b/pkgs/firehose/bin/firehose.dart @@ -41,7 +41,7 @@ void main(List arguments) async { exit(1); } - final firehose = Firehose(Directory.current, useFlutter, ''); + final firehose = Firehose(Directory.current, useFlutter); if (validate) { await firehose.validate(); diff --git a/pkgs/firehose/lib/firehose.dart b/pkgs/firehose/lib/firehose.dart index 45c556ca..c6dfb44a 100644 --- a/pkgs/firehose/lib/firehose.dart +++ b/pkgs/firehose/lib/firehose.dart @@ -24,10 +24,7 @@ class Firehose { final Directory directory; final bool useFlutter; - //DO_NOT_SUBMIT - final String testArg; - - Firehose(this.directory, this.useFlutter, this.testArg); + Firehose(this.directory, this.useFlutter); /// Validate the packages in the repository. /// diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 1114e0b7..7d057fdf 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -83,7 +83,7 @@ class Health { Future validateCheck(Github github) async { //TODO: Add Flutter support for PR health checks - var results = await Firehose(directory, false, '').verify(github); + var results = await Firehose(directory, false).verify(github); var markdownTable = ''' | Package | Version | Status | From 8702ab8a971816e7dd0d38e06b2ffadd15cdc0bd Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 28 Sep 2023 13:08:41 +0200 Subject: [PATCH 40/40] Fix call --- 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 7d057fdf..bb6487a0 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -118,7 +118,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati 'dart', [ ...['pub', 'global', 'run'], - 'dart-apitool', + 'dart_apitool:main', 'diff', ...['--old', basePackage], ...['--new', '.'],