From 0c31c59b0ed4ba4b9e2aa8a0a5b9816e52f300c8 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 8 Jan 2024 16:08:08 +0100 Subject: [PATCH 01/34] Add `ignore` flag to health workflows --- .github/workflows/health_base.yaml | 16 +++++++++++++--- pkgs/firehose/bin/health.dart | 7 ++++++- pkgs/firehose/lib/src/health/health.dart | 7 +++++-- pkgs/firehose/lib/src/health/license.dart | 10 +++++++--- pkgs/firehose/test/license_test.dart | 2 +- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 8870ec0c..835d7f70 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -45,11 +45,14 @@ on: type: boolean required: false use-flutter: - description: >- - Whether to setup Flutter in this workflow. + description: Whether to setup Flutter in this workflow. default: false required: false type: boolean + ignore: + description: The files to ignore for this check. + required: false + type: string jobs: health: @@ -109,7 +112,14 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ISSUE_NUMBER: ${{ github.event.number }} PR_LABELS: "${{ join(github.event.pull_request.labels.*.name) }}" - run: cd current_repo/ && dart pub global run firehose:health --check ${{ inputs.check }} ${{ fromJSON('{"true":"--coverage_web","false":""}')[inputs.coverage_web] }} --fail_on ${{ inputs.fail_on }} --warn_on ${{ inputs.warn_on }} + run: | + cd current_repo/ && \ + dart pub global run firehose:health \ + --check ${{ inputs.check }} \ + ${{ fromJSON('{"true":"--coverage_web","false":""}')[inputs.coverage_web] }} \ + --fail_on ${{ inputs.fail_on }} \ + --warn_on ${{ inputs.warn_on }} \ + --ignore ${{ inputs.ignore }} - name: Upload coverage to Coveralls if: ${{ inputs.upload_coverage }} diff --git a/pkgs/firehose/bin/health.dart b/pkgs/firehose/bin/health.dart index 19a98d40..13006338 100644 --- a/pkgs/firehose/bin/health.dart +++ b/pkgs/firehose/bin/health.dart @@ -14,6 +14,10 @@ void main(List arguments) async { allowed: checkTypes, help: 'Check PR health.', ) + ..addMultiOption( + 'ignore', + help: 'Check PR health.', + ) ..addMultiOption( 'warn_on', allowed: checkTypes, @@ -32,11 +36,12 @@ void main(List arguments) async { var check = parsedArgs['check'] as String; var warnOn = parsedArgs['warn_on'] as List; var failOn = parsedArgs['fail_on'] as List; + var ignore = parsedArgs['ignore'] as List; var coverageWeb = parsedArgs['coverage_web'] as bool; if (warnOn.toSet().intersection(failOn.toSet()).isNotEmpty) { throw ArgumentError('The checks for which warnings are displayed and the ' 'checks which lead to failure must be disjoint.'); } - await Health(Directory.current, check, warnOn, failOn, coverageWeb) + await Health(Directory.current, check, warnOn, failOn, coverageWeb, ignore) .healthCheck(); } diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 5dab5e4d..461e90e4 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -52,13 +52,15 @@ class Health { this.warnOn, this.failOn, this.coverageweb, - ); + List ignored, + ) : ignoredFiles = ignored.map(RegExp.new).toList(); final github = GithubApi(); final String check; final List warnOn; final List failOn; final bool coverageweb; + final List ignoredFiles; Future healthCheck() async { // Do basic validation of our expected env var. @@ -206,7 +208,8 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} Future licenseCheck() async { var files = await github.listFilesForPR(); - var allFilePaths = await getFilesWithoutLicenses(Directory.current); + var allFilePaths = + await getFilesWithoutLicenses(Directory.current, ignoredFiles); var groupedPaths = allFilePaths .groupListsBy((path) => files.any((f) => f.relativePath == path)); diff --git a/pkgs/firehose/lib/src/health/license.dart b/pkgs/firehose/lib/src/health/license.dart index 0a2a6572..421b5601 100644 --- a/pkgs/firehose/lib/src/health/license.dart +++ b/pkgs/firehose/lib/src/health/license.dart @@ -4,6 +4,7 @@ import 'dart:io'; +import 'package:collection/collection.dart'; import 'package:path/path.dart' as path; final license = ''' @@ -11,7 +12,8 @@ final license = ''' // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file.'''; -Future> getFilesWithoutLicenses(Directory repositoryDir) async { +Future> getFilesWithoutLicenses( + Directory repositoryDir, List ignoredFiles) async { var dartFiles = await repositoryDir .list(recursive: true) .where((f) => f.path.endsWith('.dart')) @@ -24,8 +26,10 @@ Future> getFilesWithoutLicenses(Directory repositoryDir) async { if (!fileContainsCopyright) { var relativePath = path.relative(file.path, from: Directory.current.path); - print(relativePath); - return relativePath; + if (ignoredFiles.none((regex) => regex.hasMatch(relativePath))) { + print(relativePath); + return relativePath; + } } }) .whereType() diff --git a/pkgs/firehose/test/license_test.dart b/pkgs/firehose/test/license_test.dart index f269d73c..fa15bbe3 100644 --- a/pkgs/firehose/test/license_test.dart +++ b/pkgs/firehose/test/license_test.dart @@ -21,7 +21,7 @@ void main() { test('Check for licenses', () async { var filesWithoutLicenses = - await getFilesWithoutLicenses(Directory('test/')); + await getFilesWithoutLicenses(Directory('test/'), []); expect(filesWithoutLicenses, [fileWithoutLicense.path]); }); From 6b487f8d00671f1f6f024e14f8cc95c64065ae46 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 8 Jan 2024 16:12:23 +0100 Subject: [PATCH 02/34] Switch to glob --- .github/workflows/health.yaml | 8 ++++++-- .github/workflows/health_base.yaml | 1 + .github/workflows/health_internal.yaml | 1 + pkgs/firehose/lib/src/health/health.dart | 5 +++-- pkgs/firehose/lib/src/health/license.dart | 5 +++-- pkgs/firehose/pubspec.yaml | 1 + 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index d2cf26e1..84896687 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -78,11 +78,14 @@ on: type: boolean required: false use-flutter: - description: >- - Whether to setup Flutter in this workflow. + description: Whether to setup Flutter in this workflow. default: false required: false type: boolean + ignore_license: + description: Which files to ignore when checking for licenses. + required: false + type: string jobs: version: @@ -117,6 +120,7 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} + ignore: ${{ inputs.ignore_license }} coverage: if: contains(${{ inputs.checks }}, 'coverage') diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 835d7f70..8d7a3501 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -51,6 +51,7 @@ on: type: boolean ignore: description: The files to ignore for this check. + default: "" required: false type: string diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml index cf46b50f..28a10a56 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -15,3 +15,4 @@ jobs: checks: version,changelog,license,coverage,breaking,do-not-submit fail_on: version,changelog,do-not-submit warn_on: license,coverage,breaking + ignore_license: '**.g.dart' diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 461e90e4..fe68d705 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -9,6 +9,7 @@ import 'dart:io'; import 'dart:math'; import 'package:collection/collection.dart'; +import 'package:glob/glob.dart'; import 'package:path/path.dart' as path; import 'package:pub_semver/pub_semver.dart'; @@ -53,14 +54,14 @@ class Health { this.failOn, this.coverageweb, List ignored, - ) : ignoredFiles = ignored.map(RegExp.new).toList(); + ) : ignoredFiles = ignored.map((e) => Glob(e)).toList(); final github = GithubApi(); final String check; final List warnOn; final List failOn; final bool coverageweb; - final List ignoredFiles; + final List ignoredFiles; Future healthCheck() async { // Do basic validation of our expected env var. diff --git a/pkgs/firehose/lib/src/health/license.dart b/pkgs/firehose/lib/src/health/license.dart index 421b5601..4c4e5f93 100644 --- a/pkgs/firehose/lib/src/health/license.dart +++ b/pkgs/firehose/lib/src/health/license.dart @@ -5,6 +5,7 @@ import 'dart:io'; import 'package:collection/collection.dart'; +import 'package:glob/glob.dart'; import 'package:path/path.dart' as path; final license = ''' @@ -13,7 +14,7 @@ final license = ''' // BSD-style license that can be found in the LICENSE file.'''; Future> getFilesWithoutLicenses( - Directory repositoryDir, List ignoredFiles) async { + Directory repositoryDir, List ignoredFiles) async { var dartFiles = await repositoryDir .list(recursive: true) .where((f) => f.path.endsWith('.dart')) @@ -26,7 +27,7 @@ Future> getFilesWithoutLicenses( if (!fileContainsCopyright) { var relativePath = path.relative(file.path, from: Directory.current.path); - if (ignoredFiles.none((regex) => regex.hasMatch(relativePath))) { + if (ignoredFiles.none((regex) => regex.matches(relativePath))) { print(relativePath); return relativePath; } diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml index 57e90f3f..56c3b72f 100644 --- a/pkgs/firehose/pubspec.yaml +++ b/pkgs/firehose/pubspec.yaml @@ -19,6 +19,7 @@ dependencies: pub_semver: ^2.1.0 pubspec_parse: ^1.2.3 yaml: ^3.1.0 + glob: ^2.1.2 dev_dependencies: dart_flutter_team_lints: ^2.0.0 From ee185bcd13ed2a4104adda867894f4d5887d8139 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 8 Jan 2024 16:14:43 +0100 Subject: [PATCH 03/34] Fix multiline --- .github/workflows/health_base.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 8d7a3501..62804383 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -117,7 +117,7 @@ jobs: cd current_repo/ && \ dart pub global run firehose:health \ --check ${{ inputs.check }} \ - ${{ fromJSON('{"true":"--coverage_web","false":""}')[inputs.coverage_web] }} \ + ${{ fromJSON('{"true":"--coverage_web \","false":""}')[inputs.coverage_web] }} --fail_on ${{ inputs.fail_on }} \ --warn_on ${{ inputs.warn_on }} \ --ignore ${{ inputs.ignore }} From 7a9ab59c1bdc2e22d17d8459aead3ccedaa267be Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 8 Jan 2024 16:17:02 +0100 Subject: [PATCH 04/34] Add default glob --- .github/workflows/health_base.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 62804383..29857fc8 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -51,7 +51,7 @@ on: type: boolean ignore: description: The files to ignore for this check. - default: "" + default: "[!*]" required: false type: string From cbb7266ae983f53d098330bda701c799fef71ebf Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 8 Jan 2024 16:19:38 +0100 Subject: [PATCH 05/34] Delete multiline --- .github/workflows/health_base.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 29857fc8..75170446 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -117,7 +117,7 @@ jobs: cd current_repo/ && \ dart pub global run firehose:health \ --check ${{ inputs.check }} \ - ${{ fromJSON('{"true":"--coverage_web \","false":""}')[inputs.coverage_web] }} + ${{ fromJSON('{"true":"--coverage_web","false":""}')[inputs.coverage_web] }} \ --fail_on ${{ inputs.fail_on }} \ --warn_on ${{ inputs.warn_on }} \ --ignore ${{ inputs.ignore }} From 9f84be42f95704dccf240cd2c8ae274c8317d63e Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 8 Jan 2024 16:22:22 +0100 Subject: [PATCH 06/34] Fix errors --- pkgs/firehose/lib/src/health/health.dart | 2 +- pkgs/firehose/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index fe68d705..51642970 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -54,7 +54,7 @@ class Health { this.failOn, this.coverageweb, List ignored, - ) : ignoredFiles = ignored.map((e) => Glob(e)).toList(); + ) : ignoredFiles = ignored.map(Glob.new).toList(); final github = GithubApi(); final String check; diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml index 56c3b72f..06ffa54c 100644 --- a/pkgs/firehose/pubspec.yaml +++ b/pkgs/firehose/pubspec.yaml @@ -14,12 +14,12 @@ dependencies: args: ^2.3.0 collection: ^1.17.2 github: ^9.20.0 + glob: ^2.1.2 http: ^1.0.0 path: ^1.8.0 pub_semver: ^2.1.0 pubspec_parse: ^1.2.3 yaml: ^3.1.0 - glob: ^2.1.2 dev_dependencies: dart_flutter_team_lints: ^2.0.0 From 6f1c834cf802608da274acdc71ebfe893430f5d6 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 8 Jan 2024 16:29:13 +0100 Subject: [PATCH 07/34] Fix health commenting --- .github/workflows/health_internal.yaml | 2 +- .github/workflows/post_summaries.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml index 28a10a56..43dc4fdc 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -1,6 +1,6 @@ # A CI configuration to check PR health. -name: Health +name: Health:Internal on: pull_request: branches: [ main ] diff --git a/.github/workflows/post_summaries.yaml b/.github/workflows/post_summaries.yaml index 10e82c91..a0f3c673 100644 --- a/.github/workflows/post_summaries.yaml +++ b/.github/workflows/post_summaries.yaml @@ -7,7 +7,7 @@ on: workflow_run: workflows: - Publish - - Health:Comment + - Health:Internal types: - completed From 9919dd04082d95098de0e5344273a2d3f01d13e5 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 12 Jan 2024 18:36:09 +0100 Subject: [PATCH 08/34] Propagate ignore --- .github/workflows/health.yaml | 9 +++++++-- .github/workflows/health_base.yaml | 3 ++- pkgs/firehose/bin/health.dart | 2 +- pkgs/firehose/lib/firehose.dart | 9 +++++++-- pkgs/firehose/lib/src/github.dart | 17 ++++++++++++----- pkgs/firehose/lib/src/health/changelog.dart | 7 ++++--- pkgs/firehose/lib/src/health/coverage.dart | 10 ++++++---- pkgs/firehose/lib/src/health/health.dart | 15 ++++++++------- pkgs/firehose/lib/src/repo.dart | 5 ++++- pkgs/firehose/test/coverage_test.dart | 2 +- 10 files changed, 52 insertions(+), 27 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index 1a9b53f2..17f0ff9c 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -82,7 +82,7 @@ on: default: false required: false type: boolean - ignore_license: + ignore: description: Which files to ignore when checking for licenses. required: false type: string @@ -98,6 +98,7 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} + ignore: ${{ inputs.ignore }} changelog: if: ${{ contains(inputs.checks, 'changelog') }} @@ -109,6 +110,7 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} + ignore: ${{ inputs.ignore }} license: if: ${{ contains(inputs.checks, 'license') }} @@ -120,7 +122,7 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore: ${{ inputs.ignore_license }} + ignore: ${{ inputs.ignore }} coverage: if: ${{ contains(inputs.checks, 'coverage') }} @@ -134,6 +136,7 @@ jobs: coverage_web: ${{ inputs.coverage_web }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} + ignore: ${{ inputs.ignore }} breaking: if: ${{ contains(inputs.checks, 'breaking') }} @@ -145,6 +148,7 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} + ignore: ${{ inputs.ignore }} do-not-submit: if: ${{ contains(inputs.checks, 'do-not-submit') }} @@ -156,6 +160,7 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} + ignore: ${{ inputs.ignore }} comment: needs: [version, changelog, license, coverage, breaking, do-not-submit] diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index ba609517..d7c54cb9 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -116,7 +116,8 @@ jobs: --check ${{ inputs.check }} \ ${{ fromJSON('{"true":"--coverage_web","false":""}')[inputs.coverage_web] }} \ --fail_on ${{ inputs.fail_on }} \ - --warn_on ${{ inputs.warn_on }} + --warn_on ${{ inputs.warn_on }} \ + --ignore ${{ inputs.ignore }} - run: test -f current_repo/output/comment.md || echo $'The ${{ inputs.check }} workflow has encountered an exception and did not complete.' >> current_repo/output/comment.md if: ${{ '$action_state' == 1 }} diff --git a/pkgs/firehose/bin/health.dart b/pkgs/firehose/bin/health.dart index 13006338..5782b1a9 100644 --- a/pkgs/firehose/bin/health.dart +++ b/pkgs/firehose/bin/health.dart @@ -16,7 +16,7 @@ void main(List arguments) async { ) ..addMultiOption( 'ignore', - help: 'Check PR health.', + help: 'File which should be ignored by the health workflow.', ) ..addMultiOption( 'warn_on', diff --git a/pkgs/firehose/lib/firehose.dart b/pkgs/firehose/lib/firehose.dart index b1b107bd..9bc92daa 100644 --- a/pkgs/firehose/lib/firehose.dart +++ b/pkgs/firehose/lib/firehose.dart @@ -7,6 +7,8 @@ import 'dart:io'; import 'dart:math'; +import 'package:glob/glob.dart'; + import 'src/github.dart'; import 'src/pub.dart'; import 'src/repo.dart'; @@ -90,9 +92,12 @@ Saving existing comment id $existingCommentId to file ${idFile.path}'''); github.close(); } - Future verify(GithubApi github) async { + Future verify( + GithubApi github, [ + List ignoredFiles = const [], + ]) async { var repo = Repository(); - var packages = repo.locatePackages(); + var packages = repo.locatePackages(ignoredFiles); var pub = Pub(); diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index c37da5b7..0aad68aa 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart @@ -5,7 +5,9 @@ import 'dart:io'; +import 'package:collection/collection.dart'; import 'package:github/github.dart'; +import 'package:glob/glob.dart'; import 'package:http/http.dart' as http; import 'package:path/path.dart' as path; @@ -110,11 +112,16 @@ class GithubApi { return matchingComment?.id; } - Future> listFilesForPR() async => await github.pullRequests - .listFiles(repoSlug!, issueNumber!) - .map((prFile) => - GitFile(prFile.filename!, FileStatus.fromString(prFile.status!))) - .toList(); + Future> listFilesForPR([ + List ignoredFiles = const [], + ]) async => + await github.pullRequests + .listFiles(repoSlug!, issueNumber!) + .map((prFile) => + GitFile(prFile.filename!, FileStatus.fromString(prFile.status!))) + .where((file) => + ignoredFiles.none((glob) => glob.matches(file.relativePath))) + .toList(); /// Write a notice message to the github log. void notice({required String message}) { diff --git a/pkgs/firehose/lib/src/health/changelog.dart b/pkgs/firehose/lib/src/health/changelog.dart index a671433f..fe91121b 100644 --- a/pkgs/firehose/lib/src/health/changelog.dart +++ b/pkgs/firehose/lib/src/health/changelog.dart @@ -4,6 +4,7 @@ import 'dart:io'; +import 'package:glob/glob.dart'; import 'package:path/path.dart' as path; import '../github.dart'; @@ -11,11 +12,11 @@ import '../repo.dart'; import '../utils.dart'; Future>> packagesWithoutChangelog( - GithubApi github) async { + GithubApi github, List ignoredFiles) async { final repo = Repository(); - final packages = repo.locatePackages(); + final packages = repo.locatePackages(ignoredFiles); - final files = await github.listFilesForPR(); + final files = await github.listFilesForPR(ignoredFiles); var packagesWithoutChangedChangelog = collectPackagesWithoutChangelogChanges(packages, files); diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index b1e8aa12..0fabf96c 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -5,6 +5,7 @@ import 'dart:io'; +import 'package:glob/glob.dart'; import 'package:path/path.dart' as path; import '../github.dart'; @@ -14,11 +15,12 @@ import 'lcov.dart'; class Coverage { final bool coverageWeb; + final List ignoredFiles; - Coverage(this.coverageWeb); + Coverage(this.coverageWeb, this.ignoredFiles); Future compareCoverages(GithubApi github) async { - var files = await github.listFilesForPR(); + var files = await github.listFilesForPR(ignoredFiles); var basePath = '../base_repo/'; return compareCoveragesFor(files, basePath); @@ -26,7 +28,7 @@ class Coverage { CoverageResult compareCoveragesFor(List files, String basePath) { var repository = Repository(); - var packages = repository.locatePackages(); + var packages = repository.locatePackages(ignoredFiles); print('Found packages $packages at ${Directory.current}'); var filesOfInterest = files @@ -40,7 +42,7 @@ class Coverage { var base = Directory(basePath); var baseRepository = Repository(base); - var basePackages = baseRepository.locatePackages(); + var basePackages = baseRepository.locatePackages(ignoredFiles); print('Found packages $basePackages at $base'); var changedPackages = packages diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index f291fe2d..56c23fe4 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -110,7 +110,7 @@ class Health { Future validateCheck() 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, ignoredFiles); var markdownTable = ''' | Package | Version | Status | @@ -128,7 +128,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati } Future breakingCheck() async { - final filesInPR = await github.listFilesForPR(); + final filesInPR = await github.listFilesForPR(ignoredFiles); final changeForPackage = {}; final baseDirectory = Directory('../base_repo'); for (var package in packagesContaining(filesInPR)) { @@ -201,7 +201,7 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} } Future licenseCheck() async { - var files = await github.listFilesForPR(); + var files = await github.listFilesForPR(ignoredFiles); var allFilePaths = await getFilesWithoutLicenses(Directory.current, ignoredFiles); @@ -245,7 +245,7 @@ ${unchangedFilesPaths.isNotEmpty ? unchangedMarkdown : ''} } Future changelogCheck() async { - var filePaths = await packagesWithoutChangelog(github); + var filePaths = await packagesWithoutChangelog(github, ignoredFiles); final markdownResult = ''' | Package | Changed Files | @@ -264,7 +264,7 @@ Changes to files need to be [accounted for](https://github.com/dart-lang/ecosyst Future doNotSubmitCheck() async { final body = await github.pullrequestBody(); - final files = await github.listFilesForPR(); + final files = await github.listFilesForPR(ignoredFiles); print('Checking for DO_NOT${'_'}SUBMIT strings: $files'); final filesWithDNS = files .where((file) => @@ -294,7 +294,8 @@ ${filesWithDNS.map((e) => e.filename).map((e) => '|$e|').join('\n')} } Future coverageCheck() async { - var coverage = await Coverage(coverageweb).compareCoverages(github); + var coverage = + await Coverage(coverageweb, ignoredFiles).compareCoverages(github); var markdownResult = ''' | File | Coverage | @@ -351,7 +352,7 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r List packagesContaining(List filesInPR) { var files = filesInPR.where((element) => element.status.isRelevant); final repo = Repository(); - return repo.locatePackages().where((package) { + return repo.locatePackages(ignoredFiles).where((package) { var relativePackageDirectory = path.relative(package.directory.path, from: Directory.current.path); return files.any( diff --git a/pkgs/firehose/lib/src/repo.dart b/pkgs/firehose/lib/src/repo.dart index 8b29aa42..2342ecae 100644 --- a/pkgs/firehose/lib/src/repo.dart +++ b/pkgs/firehose/lib/src/repo.dart @@ -4,6 +4,7 @@ import 'dart:io'; +import 'package:glob/glob.dart'; import 'package:path/path.dart' as path; import 'package:pub_semver/pub_semver.dart'; import 'package:pubspec_parse/pubspec_parse.dart'; @@ -39,9 +40,11 @@ class Repository { /// `publish_to: none` key. /// /// Once we find a package, we don't look for packages in sub-directories. - List locatePackages() { + List locatePackages([List ignore = const []]) { final packages = []; _recurseAndGather(baseDirectory, packages); + packages.removeWhere((package) => + ignore.any((glob) => glob.matches(package.directory.path))); packages.sort((a, b) => a.name.compareTo(b.name)); return packages; } diff --git a/pkgs/firehose/test/coverage_test.dart b/pkgs/firehose/test/coverage_test.dart index beb865c6..2cfbeaa2 100644 --- a/pkgs/firehose/test/coverage_test.dart +++ b/pkgs/firehose/test/coverage_test.dart @@ -43,7 +43,7 @@ void main() { } class FakeHealth extends Coverage { - FakeHealth() : super(true); + FakeHealth() : super(true, []); @override Map getCoverage(Package? package) { From c7073d5de9f040efa23167f5c40d21eec3e3a688 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 12 Jan 2024 19:14:27 +0100 Subject: [PATCH 09/34] Switch to specific ignores --- .github/workflows/health.yaml | 26 +++++++++----- .github/workflows/health_base.yaml | 17 ++++++--- .github/workflows/health_internal.yaml | 2 +- pkgs/firehose/bin/health.dart | 28 ++++++++++++--- pkgs/firehose/lib/firehose.dart | 4 +-- pkgs/firehose/lib/src/health/changelog.dart | 6 ++-- pkgs/firehose/lib/src/health/coverage.dart | 6 ++-- pkgs/firehose/lib/src/health/health.dart | 38 ++++++++++++++------- pkgs/firehose/test/coverage_test.dart | 2 +- 9 files changed, 90 insertions(+), 39 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index 17f0ff9c..d6656678 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -82,8 +82,16 @@ on: default: false required: false type: boolean - ignore: - description: Which files to ignore when checking for licenses. + ignore_license: + description: Which files to ignore for the license check. + required: false + type: string + ignore_coverage: + description: Which files to ignore for the coverage check. + required: false + type: string + ignore_packages: + description: Which packages to ignore. required: false type: string @@ -98,7 +106,7 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore: ${{ inputs.ignore }} + ignore_packages: ${{ inputs.ignore_packages }} changelog: if: ${{ contains(inputs.checks, 'changelog') }} @@ -110,7 +118,7 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore: ${{ inputs.ignore }} + ignore_packages: ${{ inputs.ignore_packages }} license: if: ${{ contains(inputs.checks, 'license') }} @@ -122,7 +130,8 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore: ${{ inputs.ignore }} + ignore_license: ${{ inputs.ignore_license }} + ignore_packages: ${{ inputs.ignore_packages }} coverage: if: ${{ contains(inputs.checks, 'coverage') }} @@ -136,7 +145,8 @@ jobs: coverage_web: ${{ inputs.coverage_web }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore: ${{ inputs.ignore }} + ignore_coverage: ${{ inputs.ignore_coverage }} + ignore_packages: ${{ inputs.ignore_packages }} breaking: if: ${{ contains(inputs.checks, 'breaking') }} @@ -148,7 +158,7 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore: ${{ inputs.ignore }} + ignore_packages: ${{ inputs.ignore_packages }} do-not-submit: if: ${{ contains(inputs.checks, 'do-not-submit') }} @@ -160,7 +170,7 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore: ${{ inputs.ignore }} + ignore_packages: ${{ inputs.ignore_packages }} comment: needs: [version, changelog, license, coverage, breaking, do-not-submit] diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index d7c54cb9..32bf8562 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -49,9 +49,16 @@ on: default: false required: false type: boolean - ignore: - description: The files to ignore for this check. - default: "[!*]" + ignore_license: + description: Which files to ignore for the license check. + required: false + type: string + ignore_coverage: + description: Which files to ignore for the coverage check. + required: false + type: string + ignore_packages: + description: Which packages to ignore. required: false type: string @@ -117,7 +124,9 @@ jobs: ${{ fromJSON('{"true":"--coverage_web","false":""}')[inputs.coverage_web] }} \ --fail_on ${{ inputs.fail_on }} \ --warn_on ${{ inputs.warn_on }} \ - --ignore ${{ inputs.ignore }} + --ignore_license ${{ inputs.ignore_license }} \ + --ignore_coverage ${{ inputs.ignore_coverage }} \ + --ignore_packages ${{ inputs.ignore_packages }} - run: test -f current_repo/output/comment.md || echo $'The ${{ inputs.check }} workflow has encountered an exception and did not complete.' >> current_repo/output/comment.md if: ${{ '$action_state' == 1 }} diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml index 43dc4fdc..f99c4d9d 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -15,4 +15,4 @@ jobs: checks: version,changelog,license,coverage,breaking,do-not-submit fail_on: version,changelog,do-not-submit warn_on: license,coverage,breaking - ignore_license: '**.g.dart' + ignore: '**.g.dart' diff --git a/pkgs/firehose/bin/health.dart b/pkgs/firehose/bin/health.dart index 5782b1a9..5a936b1a 100644 --- a/pkgs/firehose/bin/health.dart +++ b/pkgs/firehose/bin/health.dart @@ -15,8 +15,16 @@ void main(List arguments) async { help: 'Check PR health.', ) ..addMultiOption( - 'ignore', - help: 'File which should be ignored by the health workflow.', + 'ignore_packages', + help: 'Which packages to ignore.', + ) + ..addMultiOption( + 'ignore_license', + help: 'Which files to ignore for the license check.', + ) + ..addMultiOption( + 'ignore_coverage', + help: 'Which files to ignore for the coverage check.', ) ..addMultiOption( 'warn_on', @@ -36,12 +44,22 @@ void main(List arguments) async { var check = parsedArgs['check'] as String; var warnOn = parsedArgs['warn_on'] as List; var failOn = parsedArgs['fail_on'] as List; - var ignore = parsedArgs['ignore'] as List; + var ignorePackages = parsedArgs['ignore_packages'] as List; + var ignoreLicense = parsedArgs['ignore_license'] as List; + var ignoreCoverage = parsedArgs['ignore_coverage'] as List; var coverageWeb = parsedArgs['coverage_web'] as bool; if (warnOn.toSet().intersection(failOn.toSet()).isNotEmpty) { throw ArgumentError('The checks for which warnings are displayed and the ' 'checks which lead to failure must be disjoint.'); } - await Health(Directory.current, check, warnOn, failOn, coverageWeb, ignore) - .healthCheck(); + await Health( + Directory.current, + check, + warnOn, + failOn, + coverageWeb, + ignorePackages, + ignoreLicense, + ignoreCoverage, + ).healthCheck(); } diff --git a/pkgs/firehose/lib/firehose.dart b/pkgs/firehose/lib/firehose.dart index 9bc92daa..b2d24999 100644 --- a/pkgs/firehose/lib/firehose.dart +++ b/pkgs/firehose/lib/firehose.dart @@ -94,10 +94,10 @@ Saving existing comment id $existingCommentId to file ${idFile.path}'''); Future verify( GithubApi github, [ - List ignoredFiles = const [], + List ignoredPackages = const [], ]) async { var repo = Repository(); - var packages = repo.locatePackages(ignoredFiles); + var packages = repo.locatePackages(ignoredPackages); var pub = Pub(); diff --git a/pkgs/firehose/lib/src/health/changelog.dart b/pkgs/firehose/lib/src/health/changelog.dart index fe91121b..2e934777 100644 --- a/pkgs/firehose/lib/src/health/changelog.dart +++ b/pkgs/firehose/lib/src/health/changelog.dart @@ -12,11 +12,11 @@ import '../repo.dart'; import '../utils.dart'; Future>> packagesWithoutChangelog( - GithubApi github, List ignoredFiles) async { + GithubApi github, List ignoredPackages) async { final repo = Repository(); - final packages = repo.locatePackages(ignoredFiles); + final packages = repo.locatePackages(ignoredPackages); - final files = await github.listFilesForPR(ignoredFiles); + final files = await github.listFilesForPR(); var packagesWithoutChangedChangelog = collectPackagesWithoutChangelogChanges(packages, files); diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index 0fabf96c..45cbb73f 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -17,7 +17,9 @@ class Coverage { final bool coverageWeb; final List ignoredFiles; - Coverage(this.coverageWeb, this.ignoredFiles); + final List ignoredPackages; + + Coverage(this.coverageWeb, this.ignoredFiles, this.ignoredPackages); Future compareCoverages(GithubApi github) async { var files = await github.listFilesForPR(ignoredFiles); @@ -28,7 +30,7 @@ class Coverage { CoverageResult compareCoveragesFor(List files, String basePath) { var repository = Repository(); - var packages = repository.locatePackages(ignoredFiles); + var packages = repository.locatePackages(ignoredPackages); print('Found packages $packages at ${Directory.current}'); var filesOfInterest = files diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 56c23fe4..018095de 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -51,15 +51,21 @@ class Health { this.warnOn, this.failOn, this.coverageweb, - List ignored, - ) : ignoredFiles = ignored.map(Glob.new).toList(); + List ignoredPackages, + List ignoredLicense, + List ignoredCoverage, + ) : ignoredPackages = ignoredPackages.map(Glob.new).toList(), + ignoredFilesForCoverage = ignoredCoverage.map(Glob.new).toList(), + ignoredFilesForLicense = ignoredLicense.map(Glob.new).toList(); final github = GithubApi(); final String check; final List warnOn; final List failOn; final bool coverageweb; - final List ignoredFiles; + final List ignoredPackages; + final List ignoredFilesForLicense; + final List ignoredFilesForCoverage; Future healthCheck() async { // Do basic validation of our expected env var. @@ -110,7 +116,8 @@ class Health { Future validateCheck() async { //TODO: Add Flutter support for PR health checks - var results = await Firehose(directory, false).verify(github, ignoredFiles); + var results = + await Firehose(directory, false).verify(github, ignoredPackages); var markdownTable = ''' | Package | Version | Status | @@ -128,7 +135,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati } Future breakingCheck() async { - final filesInPR = await github.listFilesForPR(ignoredFiles); + final filesInPR = await github.listFilesForPR(); final changeForPackage = {}; final baseDirectory = Directory('../base_repo'); for (var package in packagesContaining(filesInPR)) { @@ -201,9 +208,11 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} } Future licenseCheck() async { - var files = await github.listFilesForPR(ignoredFiles); - var allFilePaths = - await getFilesWithoutLicenses(Directory.current, ignoredFiles); + var files = await github.listFilesForPR(ignoredFilesForLicense); + var allFilePaths = await getFilesWithoutLicenses( + Directory.current, + ignoredFilesForLicense, + ); var groupedPaths = allFilePaths .groupListsBy((path) => files.any((f) => f.relativePath == path)); @@ -245,7 +254,7 @@ ${unchangedFilesPaths.isNotEmpty ? unchangedMarkdown : ''} } Future changelogCheck() async { - var filePaths = await packagesWithoutChangelog(github, ignoredFiles); + var filePaths = await packagesWithoutChangelog(github, ignoredPackages); final markdownResult = ''' | Package | Changed Files | @@ -264,7 +273,7 @@ Changes to files need to be [accounted for](https://github.com/dart-lang/ecosyst Future doNotSubmitCheck() async { final body = await github.pullrequestBody(); - final files = await github.listFilesForPR(ignoredFiles); + final files = await github.listFilesForPR(); print('Checking for DO_NOT${'_'}SUBMIT strings: $files'); final filesWithDNS = files .where((file) => @@ -294,8 +303,11 @@ ${filesWithDNS.map((e) => e.filename).map((e) => '|$e|').join('\n')} } Future coverageCheck() async { - var coverage = - await Coverage(coverageweb, ignoredFiles).compareCoverages(github); + var coverage = await Coverage( + coverageweb, + ignoredFilesForCoverage, + ignoredPackages, + ).compareCoverages(github); var markdownResult = ''' | File | Coverage | @@ -352,7 +364,7 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r List packagesContaining(List filesInPR) { var files = filesInPR.where((element) => element.status.isRelevant); final repo = Repository(); - return repo.locatePackages(ignoredFiles).where((package) { + return repo.locatePackages(ignoredPackages).where((package) { var relativePackageDirectory = path.relative(package.directory.path, from: Directory.current.path); return files.any( diff --git a/pkgs/firehose/test/coverage_test.dart b/pkgs/firehose/test/coverage_test.dart index 2cfbeaa2..e46b435a 100644 --- a/pkgs/firehose/test/coverage_test.dart +++ b/pkgs/firehose/test/coverage_test.dart @@ -43,7 +43,7 @@ void main() { } class FakeHealth extends Coverage { - FakeHealth() : super(true, []); + FakeHealth() : super(true, [], []); @override Map getCoverage(Package? package) { From 2bacc71e22beaffaf7fa8b2664f492f8a570788f Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 12 Jan 2024 19:22:51 +0100 Subject: [PATCH 10/34] Add defaults --- pkgs/firehose/bin/health.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/firehose/bin/health.dart b/pkgs/firehose/bin/health.dart index 5a936b1a..9cb6831d 100644 --- a/pkgs/firehose/bin/health.dart +++ b/pkgs/firehose/bin/health.dart @@ -16,14 +16,17 @@ void main(List arguments) async { ) ..addMultiOption( 'ignore_packages', + defaultsTo: [], help: 'Which packages to ignore.', ) ..addMultiOption( 'ignore_license', + defaultsTo: [], help: 'Which files to ignore for the license check.', ) ..addMultiOption( 'ignore_coverage', + defaultsTo: [], help: 'Which files to ignore for the coverage check.', ) ..addMultiOption( From 4e15f4d58e3873c6598c23f7358b5bbdc51160fa Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 10:46:47 +0100 Subject: [PATCH 11/34] Add test repos --- .../base_test_repo/pkgs/package1/.gitignore | 3 ++ .../base_test_repo/pkgs/package1/CHANGELOG.md | 3 ++ .../base_test_repo/pkgs/package1/README.md | 2 ++ .../pkgs/package1/analysis_options.yaml | 30 +++++++++++++++++++ .../pkgs/package1/bin/package1.dart | 6 ++++ .../pkgs/package1/lib/package1.dart | 3 ++ .../base_test_repo/pkgs/package1/pubspec.yaml | 15 ++++++++++ .../pkgs/package1/test/package1_test.dart | 8 +++++ .../base_test_repo/pkgs/package2/.gitignore | 3 ++ .../base_test_repo/pkgs/package2/CHANGELOG.md | 3 ++ .../base_test_repo/pkgs/package2/README.md | 2 ++ .../pkgs/package2/analysis_options.yaml | 30 +++++++++++++++++++ .../pkgs/package2/bin/package2.dart | 5 ++++ .../pkgs/package2/lib/anotherLib.dart | 3 ++ .../pkgs/package2/lib/package2.dart | 3 ++ .../base_test_repo/pkgs/package2/pubspec.yaml | 15 ++++++++++ .../pkgs/package2/test/package2_test.dart | 8 +++++ .../base_test_repo/pkgs/package3/.gitignore | 3 ++ .../base_test_repo/pkgs/package3/CHANGELOG.md | 3 ++ .../base_test_repo/pkgs/package3/README.md | 2 ++ .../pkgs/package3/analysis_options.yaml | 30 +++++++++++++++++++ .../pkgs/package3/bin/package3.dart | 5 ++++ .../pkgs/package3/lib/package3.dart | 3 ++ .../base_test_repo/pkgs/package3/pubspec.yaml | 15 ++++++++++ .../pkgs/package3/test/package3_test.dart | 8 +++++ .../data/test_repo/pkgs/package1/.gitignore | 3 ++ .../data/test_repo/pkgs/package1/CHANGELOG.md | 3 ++ .../data/test_repo/pkgs/package1/README.md | 2 ++ .../pkgs/package1/analysis_options.yaml | 30 +++++++++++++++++++ .../test_repo/pkgs/package1/bin/package1.dart | 6 ++++ .../test_repo/pkgs/package1/lib/package1.dart | 3 ++ .../data/test_repo/pkgs/package1/pubspec.yaml | 15 ++++++++++ .../pkgs/package1/test/package1_test.dart | 8 +++++ .../data/test_repo/pkgs/package2/.gitignore | 3 ++ .../data/test_repo/pkgs/package2/CHANGELOG.md | 3 ++ .../data/test_repo/pkgs/package2/README.md | 2 ++ .../pkgs/package2/analysis_options.yaml | 30 +++++++++++++++++++ .../test_repo/pkgs/package2/bin/package2.dart | 5 ++++ .../pkgs/package2/lib/anotherLib.dart | 3 ++ .../test_repo/pkgs/package2/lib/package2.dart | 3 ++ .../data/test_repo/pkgs/package2/pubspec.yaml | 15 ++++++++++ .../pkgs/package2/test/package2_test.dart | 8 +++++ .../data/test_repo/pkgs/package3/.gitignore | 3 ++ .../data/test_repo/pkgs/package3/CHANGELOG.md | 3 ++ .../data/test_repo/pkgs/package3/README.md | 2 ++ .../pkgs/package3/analysis_options.yaml | 30 +++++++++++++++++++ .../test_repo/pkgs/package3/bin/package3.dart | 5 ++++ .../test_repo/pkgs/package3/lib/package3.dart | 3 ++ .../data/test_repo/pkgs/package3/pubspec.yaml | 15 ++++++++++ .../pkgs/package3/test/package3_test.dart | 8 +++++ 50 files changed, 422 insertions(+) create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/.gitignore create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/CHANGELOG.md create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/README.md create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/analysis_options.yaml create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/lib/package1.dart create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/test/package1_test.dart create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/.gitignore create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/CHANGELOG.md create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/README.md create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/analysis_options.yaml create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/anotherLib.dart create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/package2.dart create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/test/package2_test.dart create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/.gitignore create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/CHANGELOG.md create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/README.md create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/analysis_options.yaml create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/bin/package3.dart create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/lib/package3.dart create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml create mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/test/package3_test.dart create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/.gitignore create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/CHANGELOG.md create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/README.md create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/analysis_options.yaml create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/lib/package1.dart create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/test/package1_test.dart create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/.gitignore create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/CHANGELOG.md create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/README.md create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/analysis_options.yaml create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/lib/anotherLib.dart create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/lib/package2.dart create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/.gitignore create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/CHANGELOG.md create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/README.md create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/analysis_options.yaml create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/bin/package3.dart create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/lib/package3.dart create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml create mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/test/package3_test.dart diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/.gitignore b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/.gitignore new file mode 100644 index 00000000..3a857904 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/CHANGELOG.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/CHANGELOG.md new file mode 100644 index 00000000..effe43c8 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/README.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/README.md new file mode 100644 index 00000000..3816eca3 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/README.md @@ -0,0 +1,2 @@ +A sample command-line application with an entrypoint in `bin/`, library code +in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/analysis_options.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/analysis_options.yaml new file mode 100644 index 00000000..dee8927a --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart new file mode 100644 index 00000000..ff95264e --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart @@ -0,0 +1,6 @@ +import 'package:package1/package1.dart' as package1; + +void main(List arguments) { + // Add a comment + print('Hello world: ${package1.calculate()}!'); +} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/lib/package1.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/lib/package1.dart new file mode 100644 index 00000000..f64ad726 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/lib/package1.dart @@ -0,0 +1,3 @@ +int calculate() { + return 6 * 7; +} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml new file mode 100644 index 00000000..e4663470 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml @@ -0,0 +1,15 @@ +name: package1 +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.0-4.0.dev + +# Add regular dependencies here. +dependencies: + # path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/test/package1_test.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/test/package1_test.dart new file mode 100644 index 00000000..5d8a815f --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/test/package1_test.dart @@ -0,0 +1,8 @@ +import 'package:package1/package1.dart'; +import 'package:test/test.dart'; + +void main() { + test('calculate', () { + expect(calculate(), 42); + }); +} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/.gitignore b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/.gitignore new file mode 100644 index 00000000..3a857904 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/CHANGELOG.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/CHANGELOG.md new file mode 100644 index 00000000..effe43c8 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/README.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/README.md new file mode 100644 index 00000000..3816eca3 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/README.md @@ -0,0 +1,2 @@ +A sample command-line application with an entrypoint in `bin/`, library code +in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/analysis_options.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/analysis_options.yaml new file mode 100644 index 00000000..dee8927a --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart new file mode 100644 index 00000000..8b179182 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart @@ -0,0 +1,5 @@ +import 'package:package2/package2.dart' as package2; + +void main(List arguments) { + print('Hello world: ${package2.calculate()}!'); +} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/anotherLib.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/anotherLib.dart new file mode 100644 index 00000000..af52fa18 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/anotherLib.dart @@ -0,0 +1,3 @@ +int calculateUnused() { + return 6 * 7; +} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/package2.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/package2.dart new file mode 100644 index 00000000..f64ad726 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/package2.dart @@ -0,0 +1,3 @@ +int calculate() { + return 6 * 7; +} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml new file mode 100644 index 00000000..7a037494 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml @@ -0,0 +1,15 @@ +name: package2 +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.0-4.0.dev + +# Add regular dependencies here. +dependencies: + # path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/test/package2_test.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/test/package2_test.dart new file mode 100644 index 00000000..0b0e31b6 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/test/package2_test.dart @@ -0,0 +1,8 @@ +import 'package:package2/package2.dart'; +import 'package:test/test.dart'; + +void main() { + test('calculate', () { + expect(calculate(), 42); + }); +} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/.gitignore b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/.gitignore new file mode 100644 index 00000000..3a857904 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/CHANGELOG.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/CHANGELOG.md new file mode 100644 index 00000000..effe43c8 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/README.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/README.md new file mode 100644 index 00000000..3816eca3 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/README.md @@ -0,0 +1,2 @@ +A sample command-line application with an entrypoint in `bin/`, library code +in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/analysis_options.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/analysis_options.yaml new file mode 100644 index 00000000..dee8927a --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/bin/package3.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/bin/package3.dart new file mode 100644 index 00000000..b6ba11df --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/bin/package3.dart @@ -0,0 +1,5 @@ +import 'package:package3/package3.dart' as package3; + +void main(List arguments) { + print('Hello world: ${package3.calculate()}!'); +} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/lib/package3.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/lib/package3.dart new file mode 100644 index 00000000..f64ad726 --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/lib/package3.dart @@ -0,0 +1,3 @@ +int calculate() { + return 6 * 7; +} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml new file mode 100644 index 00000000..e6ad38ab --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml @@ -0,0 +1,15 @@ +name: package3 +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.0-4.0.dev + +# Add regular dependencies here. +dependencies: + # path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/test/package3_test.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/test/package3_test.dart new file mode 100644 index 00000000..a2f5a1bc --- /dev/null +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/test/package3_test.dart @@ -0,0 +1,8 @@ +import 'package:package3/package3.dart'; +import 'package:test/test.dart'; + +void main() { + test('calculate', () { + expect(calculate(), 42); + }); +} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/.gitignore b/pkgs/firehose/test/data/test_repo/pkgs/package1/.gitignore new file mode 100644 index 00000000..3a857904 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package1/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/CHANGELOG.md b/pkgs/firehose/test/data/test_repo/pkgs/package1/CHANGELOG.md new file mode 100644 index 00000000..effe43c8 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package1/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/README.md b/pkgs/firehose/test/data/test_repo/pkgs/package1/README.md new file mode 100644 index 00000000..3816eca3 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package1/README.md @@ -0,0 +1,2 @@ +A sample command-line application with an entrypoint in `bin/`, library code +in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/analysis_options.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package1/analysis_options.yaml new file mode 100644 index 00000000..dee8927a --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package1/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart b/pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart new file mode 100644 index 00000000..ff95264e --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart @@ -0,0 +1,6 @@ +import 'package:package1/package1.dart' as package1; + +void main(List arguments) { + // Add a comment + print('Hello world: ${package1.calculate()}!'); +} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/lib/package1.dart b/pkgs/firehose/test/data/test_repo/pkgs/package1/lib/package1.dart new file mode 100644 index 00000000..f64ad726 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package1/lib/package1.dart @@ -0,0 +1,3 @@ +int calculate() { + return 6 * 7; +} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml new file mode 100644 index 00000000..e4663470 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml @@ -0,0 +1,15 @@ +name: package1 +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.0-4.0.dev + +# Add regular dependencies here. +dependencies: + # path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/test/package1_test.dart b/pkgs/firehose/test/data/test_repo/pkgs/package1/test/package1_test.dart new file mode 100644 index 00000000..5d8a815f --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package1/test/package1_test.dart @@ -0,0 +1,8 @@ +import 'package:package1/package1.dart'; +import 'package:test/test.dart'; + +void main() { + test('calculate', () { + expect(calculate(), 42); + }); +} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/.gitignore b/pkgs/firehose/test/data/test_repo/pkgs/package2/.gitignore new file mode 100644 index 00000000..3a857904 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/CHANGELOG.md b/pkgs/firehose/test/data/test_repo/pkgs/package2/CHANGELOG.md new file mode 100644 index 00000000..effe43c8 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/README.md b/pkgs/firehose/test/data/test_repo/pkgs/package2/README.md new file mode 100644 index 00000000..3816eca3 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/README.md @@ -0,0 +1,2 @@ +A sample command-line application with an entrypoint in `bin/`, library code +in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/analysis_options.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package2/analysis_options.yaml new file mode 100644 index 00000000..dee8927a --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart b/pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart new file mode 100644 index 00000000..8b179182 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart @@ -0,0 +1,5 @@ +import 'package:package2/package2.dart' as package2; + +void main(List arguments) { + print('Hello world: ${package2.calculate()}!'); +} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/anotherLib.dart b/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/anotherLib.dart new file mode 100644 index 00000000..af52fa18 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/anotherLib.dart @@ -0,0 +1,3 @@ +int calculateUnused() { + return 6 * 7; +} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/package2.dart b/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/package2.dart new file mode 100644 index 00000000..f64ad726 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/package2.dart @@ -0,0 +1,3 @@ +int calculate() { + return 6 * 7; +} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml new file mode 100644 index 00000000..7a037494 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml @@ -0,0 +1,15 @@ +name: package2 +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.0-4.0.dev + +# Add regular dependencies here. +dependencies: + # path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart b/pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart new file mode 100644 index 00000000..0b0e31b6 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart @@ -0,0 +1,8 @@ +import 'package:package2/package2.dart'; +import 'package:test/test.dart'; + +void main() { + test('calculate', () { + expect(calculate(), 42); + }); +} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/.gitignore b/pkgs/firehose/test/data/test_repo/pkgs/package3/.gitignore new file mode 100644 index 00000000..3a857904 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package3/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/CHANGELOG.md b/pkgs/firehose/test/data/test_repo/pkgs/package3/CHANGELOG.md new file mode 100644 index 00000000..effe43c8 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package3/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/README.md b/pkgs/firehose/test/data/test_repo/pkgs/package3/README.md new file mode 100644 index 00000000..3816eca3 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package3/README.md @@ -0,0 +1,2 @@ +A sample command-line application with an entrypoint in `bin/`, library code +in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/analysis_options.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package3/analysis_options.yaml new file mode 100644 index 00000000..dee8927a --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package3/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/bin/package3.dart b/pkgs/firehose/test/data/test_repo/pkgs/package3/bin/package3.dart new file mode 100644 index 00000000..b6ba11df --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package3/bin/package3.dart @@ -0,0 +1,5 @@ +import 'package:package3/package3.dart' as package3; + +void main(List arguments) { + print('Hello world: ${package3.calculate()}!'); +} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/lib/package3.dart b/pkgs/firehose/test/data/test_repo/pkgs/package3/lib/package3.dart new file mode 100644 index 00000000..f64ad726 --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package3/lib/package3.dart @@ -0,0 +1,3 @@ +int calculate() { + return 6 * 7; +} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml new file mode 100644 index 00000000..e6ad38ab --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml @@ -0,0 +1,15 @@ +name: package3 +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.4.0-4.0.dev + +# Add regular dependencies here. +dependencies: + # path: ^1.8.0 + +dev_dependencies: + lints: ^3.0.0 + test: ^1.24.0 diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/test/package3_test.dart b/pkgs/firehose/test/data/test_repo/pkgs/package3/test/package3_test.dart new file mode 100644 index 00000000..a2f5a1bc --- /dev/null +++ b/pkgs/firehose/test/data/test_repo/pkgs/package3/test/package3_test.dart @@ -0,0 +1,8 @@ +import 'package:package3/package3.dart'; +import 'package:test/test.dart'; + +void main() { + test('calculate', () { + expect(calculate(), 42); + }); +} From 09621842dc80a0660f99d7ceb9571d6704ff7a02 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 10:47:07 +0100 Subject: [PATCH 12/34] Start adding health tests --- pkgs/firehose/bin/health.dart | 2 + pkgs/firehose/lib/src/github.dart | 15 ++- pkgs/firehose/lib/src/health/changelog.dart | 7 +- pkgs/firehose/lib/src/health/coverage.dart | 10 +- pkgs/firehose/lib/src/health/health.dart | 38 ++++--- pkgs/firehose/test/coverage_test.dart | 2 +- pkgs/firehose/test/health_test.dart | 108 ++++++++++++++++++++ 7 files changed, 153 insertions(+), 29 deletions(-) create mode 100644 pkgs/firehose/test/health_test.dart diff --git a/pkgs/firehose/bin/health.dart b/pkgs/firehose/bin/health.dart index 9cb6831d..776cb87f 100644 --- a/pkgs/firehose/bin/health.dart +++ b/pkgs/firehose/bin/health.dart @@ -5,6 +5,7 @@ import 'dart:io'; import 'package:args/args.dart'; +import 'package:firehose/src/github.dart'; import 'package:firehose/src/health/health.dart'; void main(List arguments) async { @@ -61,6 +62,7 @@ void main(List arguments) async { warnOn, failOn, coverageWeb, + GithubApi(), ignorePackages, ignoreLicense, ignoreCoverage, diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index 0aad68aa..5a1b074e 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart @@ -21,16 +21,13 @@ class GithubApi { static Map get _env => Platform.environment; - /// When true, details of any RPC error are printed to the console. - final bool verbose; - - GithubApi({this.verbose = false, RepositorySlug? repoSlug, int? issueNumber}) + GithubApi({RepositorySlug? repoSlug, int? issueNumber}) : _repoSlug = repoSlug, _issueNumber = issueNumber; final http.Client _client = DelayedClient(const Duration(milliseconds: 50)); - late GitHub github = githubAuthToken != null + late final GitHub _github = githubAuthToken != null ? GitHub( auth: Authentication.withToken(githubAuthToken), client: _client, @@ -97,7 +94,7 @@ class GithubApi { required String user, String? searchTerm, }) async { - final matchingComment = await github.issues + final matchingComment = await _github.issues .listCommentsByIssue(repoSlug!, issueNumber!) .map((comment) => comment) .firstWhere( @@ -115,7 +112,7 @@ class GithubApi { Future> listFilesForPR([ List ignoredFiles = const [], ]) async => - await github.pullRequests + await _github.pullRequests .listFiles(repoSlug!, issueNumber!) .map((prFile) => GitFile(prFile.filename!, FileStatus.fromString(prFile.status!))) @@ -129,11 +126,11 @@ class GithubApi { } Future pullrequestBody() async { - final pullRequest = await github.pullRequests.get(repoSlug!, issueNumber!); + final pullRequest = await _github.pullRequests.get(repoSlug!, issueNumber!); return pullRequest.body ?? ''; } - void close() => github.dispose(); + void close() => _github.dispose(); } class GitFile { diff --git a/pkgs/firehose/lib/src/health/changelog.dart b/pkgs/firehose/lib/src/health/changelog.dart index 2e934777..b40f5e84 100644 --- a/pkgs/firehose/lib/src/health/changelog.dart +++ b/pkgs/firehose/lib/src/health/changelog.dart @@ -12,8 +12,11 @@ import '../repo.dart'; import '../utils.dart'; Future>> packagesWithoutChangelog( - GithubApi github, List ignoredPackages) async { - final repo = Repository(); + GithubApi github, + List ignoredPackages, + Directory directory, +) async { + final repo = Repository(directory); final packages = repo.locatePackages(ignoredPackages); final files = await github.listFilesForPR(); diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index 45cbb73f..bdc3ca6b 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -18,8 +18,14 @@ class Coverage { final List ignoredFiles; final List ignoredPackages; + final Directory directory; - Coverage(this.coverageWeb, this.ignoredFiles, this.ignoredPackages); + Coverage( + this.coverageWeb, + this.ignoredFiles, + this.ignoredPackages, + this.directory, + ); Future compareCoverages(GithubApi github) async { var files = await github.listFilesForPR(ignoredFiles); @@ -29,7 +35,7 @@ class Coverage { } CoverageResult compareCoveragesFor(List files, String basePath) { - var repository = Repository(); + var repository = Repository(directory); var packages = repository.locatePackages(ignoredPackages); print('Found packages $packages at ${Directory.current}'); diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 018095de..92b702e6 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -46,18 +46,21 @@ class Health { final Directory directory; Health( - this.directory, - this.check, - this.warnOn, - this.failOn, - this.coverageweb, - List ignoredPackages, - List ignoredLicense, - List ignoredCoverage, - ) : ignoredPackages = ignoredPackages.map(Glob.new).toList(), + this.directory, + this.check, + this.warnOn, + this.failOn, + this.coverageweb, + this.github, + List ignoredPackages, + List ignoredLicense, + List ignoredCoverage, + {Directory? base}) + : ignoredPackages = ignoredPackages.map(Glob.new).toList(), ignoredFilesForCoverage = ignoredCoverage.map(Glob.new).toList(), - ignoredFilesForLicense = ignoredLicense.map(Glob.new).toList(); - final github = GithubApi(); + ignoredFilesForLicense = ignoredLicense.map(Glob.new).toList(), + baseDirectory = base ?? Directory('../base_repo'); + final GithubApi github; final String check; final List warnOn; @@ -66,6 +69,7 @@ class Health { final List ignoredPackages; final List ignoredFilesForLicense; final List ignoredFilesForCoverage; + final Directory baseDirectory; Future healthCheck() async { // Do basic validation of our expected env var. @@ -137,7 +141,6 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati Future breakingCheck() async { final filesInPR = await github.listFilesForPR(); final changeForPackage = {}; - final baseDirectory = Directory('../base_repo'); for (var package in packagesContaining(filesInPR)) { var currentPath = path.relative(package.directory.path, from: Directory.current.path); @@ -254,7 +257,11 @@ ${unchangedFilesPaths.isNotEmpty ? unchangedMarkdown : ''} } Future changelogCheck() async { - var filePaths = await packagesWithoutChangelog(github, ignoredPackages); + var filePaths = await packagesWithoutChangelog( + github, + ignoredPackages, + directory, + ); final markdownResult = ''' | Package | Changed Files | @@ -307,6 +314,7 @@ ${filesWithDNS.map((e) => e.filename).map((e) => '|$e|').join('\n')} coverageweb, ignoredFilesForCoverage, ignoredPackages, + directory, ).compareCoverages(github); var markdownResult = ''' @@ -363,10 +371,10 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r List packagesContaining(List filesInPR) { var files = filesInPR.where((element) => element.status.isRelevant); - final repo = Repository(); + final repo = Repository(directory); return repo.locatePackages(ignoredPackages).where((package) { var relativePackageDirectory = - path.relative(package.directory.path, from: Directory.current.path); + path.relative(package.directory.path, from: directory.path); return files.any( (file) => path.isWithin(relativePackageDirectory, file.relativePath)); }).toList(); diff --git a/pkgs/firehose/test/coverage_test.dart b/pkgs/firehose/test/coverage_test.dart index e46b435a..0c0e300e 100644 --- a/pkgs/firehose/test/coverage_test.dart +++ b/pkgs/firehose/test/coverage_test.dart @@ -43,7 +43,7 @@ void main() { } class FakeHealth extends Coverage { - FakeHealth() : super(true, [], []); + FakeHealth() : super(true, [], [], Directory.current); @override Map getCoverage(Package? package) { diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart new file mode 100644 index 00000000..7848c068 --- /dev/null +++ b/pkgs/firehose/test/health_test.dart @@ -0,0 +1,108 @@ +import 'dart:io'; + +import 'package:firehose/src/github.dart'; +import 'package:firehose/src/health/health.dart'; +import 'package:github/src/common/model/repos.dart'; +import 'package:glob/glob.dart'; +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; + +void main() { + test('test name', () async { + var fakeGithubApi = FakeGithubApi(prLabels: [], files: [ + GitFile('pkgs/package1/bin/package1.dart', FileStatus.modified), + GitFile('pkgs/package2/lib/anotherLib.dart', FileStatus.added), + ]); + // await checkFor('version', fakeGithubApi); + // await checkFor('license', fakeGithubApi); + await checkFor('breaking', fakeGithubApi); + }); +} + +Future checkFor(String check, FakeGithubApi fakeGithubApi) async => + await Health( + Directory(p.join('test', 'data', 'test_repo')), + check, + [], + [], + false, + fakeGithubApi, + [], + [], + [], + base: Directory(p.join('test', 'data', 'base_test_repo')), + ).healthCheck(); + +class FakeGithubApi implements GithubApi { + final List files; + + FakeGithubApi({ + required this.prLabels, + required this.files, + }); + + @override + // TODO: implement actor + String? get actor => throw UnimplementedError(); + + @override + void appendStepSummary(String markdownSummary) { + // TODO: implement appendStepSummary + } + + @override + // TODO: implement baseRef + String? get baseRef => throw UnimplementedError(); + + @override + void close() { + // TODO: implement close + } + + @override + Future findCommentId({required String user, String? searchTerm}) { + // TODO: implement findCommentId + throw UnimplementedError(); + } + + @override + // TODO: implement githubAuthToken + String? get githubAuthToken => throw UnimplementedError(); + + @override + // TODO: implement inGithubContext + bool get inGithubContext => throw UnimplementedError(); + + @override + int? get issueNumber => 1; + + @override + Future> listFilesForPR( + [List ignoredFiles = const []]) async { + return files; + } + + @override + void notice({required String message}) { + // TODO: implement notice + } + + @override + final List prLabels; + + @override + Future pullrequestBody() { + // TODO: implement pullrequestBody + throw UnimplementedError(); + } + + @override + // TODO: implement refName + String? get refName => throw UnimplementedError(); + + @override + RepositorySlug? get repoSlug => RepositorySlug('test_owner', 'test_repo'); + + @override + String? get sha => 'test_sha'; +} From da5d59b56beba81f7a965a511b2404646d10b83a Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 11:29:46 +0100 Subject: [PATCH 13/34] Add golden files --- pkgs/firehose/lib/src/health/health.dart | 43 +++++++----- .../pkgs/package1/bin/package1.dart | 1 - .../pkgs/package2/lib/anotherLib.dart | 3 - .../test/data/golden/comment_breaking.md | 16 +++++ .../test/data/golden/comment_changelog.md | 17 +++++ .../test/data/golden/comment_coverage.md | 17 +++++ .../test/data/golden/comment_do-not-submit.md | 0 .../test/data/golden/comment_license.md | 54 +++++++++++++++ .../test/data/golden/comment_version.md | 17 +++++ pkgs/firehose/test/health_test.dart | 67 +++++++++---------- 10 files changed, 179 insertions(+), 56 deletions(-) delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/anotherLib.dart create mode 100644 pkgs/firehose/test/data/golden/comment_breaking.md create mode 100644 pkgs/firehose/test/data/golden/comment_changelog.md create mode 100644 pkgs/firehose/test/data/golden/comment_coverage.md create mode 100644 pkgs/firehose/test/data/golden/comment_do-not-submit.md create mode 100644 pkgs/firehose/test/data/golden/comment_license.md create mode 100644 pkgs/firehose/test/data/golden/comment_version.md diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 92b702e6..93b00e87 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -45,6 +45,8 @@ const checkTypes = [ class Health { final Directory directory; + final String commentPath; + Health( this.directory, this.check, @@ -55,11 +57,18 @@ class Health { List ignoredPackages, List ignoredLicense, List ignoredCoverage, - {Directory? base}) + {Directory? base, + String? comment}) : ignoredPackages = ignoredPackages.map(Glob.new).toList(), ignoredFilesForCoverage = ignoredCoverage.map(Glob.new).toList(), ignoredFilesForLicense = ignoredLicense.map(Glob.new).toList(), - baseDirectory = base ?? Directory('../base_repo'); + baseDirectory = base ?? Directory('../base_repo'), + commentPath = comment ?? + path.join( + directory.path, + 'output', + 'comment.md', + ); final GithubApi github; final String check; @@ -142,31 +151,31 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati final filesInPR = await github.listFilesForPR(); final changeForPackage = {}; for (var package in packagesContaining(filesInPR)) { - var currentPath = - path.relative(package.directory.path, from: Directory.current.path); - var basePackage = path.relative( - path.join(baseDirectory.absolute.path, currentPath), - from: currentPath, - ); - print('Look for changes in $currentPath with base $basePackage'); + print('Look for changes in $package with base $baseDirectory'); + var relativePath = + path.relative(package.directory.path, from: directory.path); + var baseRelativePath = path.relative( + path.join(baseDirectory.path, relativePath), + from: directory.path); + var tempDirectory = Directory.systemTemp..createSync(); + var reportPath = path.join(tempDirectory.path, 'report.json'); var runApiTool = Process.runSync( 'dart', [ ...['pub', 'global', 'run'], 'dart_apitool:main', 'diff', - ...['--old', basePackage], - ...['--new', '.'], + ...['--old', baseRelativePath], + ...['--new', relativePath], ...['--report-format', 'json'], - ...['--report-file-path', 'report.json'], + ...['--report-file-path', reportPath], ], - workingDirectory: currentPath, + workingDirectory: directory.path, ); print(runApiTool.stderr); print(runApiTool.stdout); - final reportFile = File(path.join(currentPath, 'report.json')); - var fullReportString = reportFile.readAsStringSync(); + var fullReportString = File(reportPath).readAsStringSync(); var decoded = jsonDecode(fullReportString) as Map; var report = decoded['report'] as Map; @@ -285,7 +294,7 @@ Changes to files need to be [accounted for](https://github.com/dart-lang/ecosyst final filesWithDNS = files .where((file) => ![FileStatus.removed, FileStatus.unchanged].contains(file.status)) - .where((file) => File(file.relativePath) + .where((file) => File(path.join(directory.path, file.relativePath)) .readAsStringSync() .contains('DO_NOT${'_'}SUBMIT')) .toList(); @@ -359,7 +368,7 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r github.appendStepSummary(markdownSummary); - var commentFile = File('./output/comment.md'); + var commentFile = File(commentPath); print('Saving comment markdown to file ${commentFile.path}'); await commentFile.create(recursive: true); await commentFile.writeAsString(markdownSummary); diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart index ff95264e..a8525dd6 100644 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart @@ -1,6 +1,5 @@ import 'package:package1/package1.dart' as package1; void main(List arguments) { - // Add a comment print('Hello world: ${package1.calculate()}!'); } diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/anotherLib.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/anotherLib.dart deleted file mode 100644 index af52fa18..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/anotherLib.dart +++ /dev/null @@ -1,3 +0,0 @@ -int calculateUnused() { - return 6 * 7; -} diff --git a/pkgs/firehose/test/data/golden/comment_breaking.md b/pkgs/firehose/test/data/golden/comment_breaking.md new file mode 100644 index 00000000..85987b04 --- /dev/null +++ b/pkgs/firehose/test/data/golden/comment_breaking.md @@ -0,0 +1,16 @@ +### Breaking changes :heavy_check_mark: + +
+ +Details + + +| Package | Change | Current Version | New Version | Needed Version | Looking good? | +| :--- | :--- | ---: | ---: | ---: | ---: | +|package1|None|1.0.0|1.0.0|1.0.0|:heavy_check_mark:| +|package2|None|1.0.0|1.0.0|1.0.0|:heavy_check_mark:| + + + +
+ diff --git a/pkgs/firehose/test/data/golden/comment_changelog.md b/pkgs/firehose/test/data/golden/comment_changelog.md new file mode 100644 index 00000000..1c3fae90 --- /dev/null +++ b/pkgs/firehose/test/data/golden/comment_changelog.md @@ -0,0 +1,17 @@ +### Changelog Entry :heavy_check_mark: + +
+ +Details + + +| Package | Changed Files | +| :--- | :--- | + + +Changes to files need to be [accounted for](https://github.com/dart-lang/ecosystem/wiki/Changelog) in their respective changelogs. + + + +
+ diff --git a/pkgs/firehose/test/data/golden/comment_coverage.md b/pkgs/firehose/test/data/golden/comment_coverage.md new file mode 100644 index 00000000..e6870d34 --- /dev/null +++ b/pkgs/firehose/test/data/golden/comment_coverage.md @@ -0,0 +1,17 @@ +### Coverage :heavy_check_mark: + +
+ +Details + + +| File | Coverage | +| :--- | :--- | + + +This check for [test coverage](https://github.com/dart-lang/ecosystem/wiki/Test-Coverage) is informational (issues shown here will not fail the PR). + + + +
+ diff --git a/pkgs/firehose/test/data/golden/comment_do-not-submit.md b/pkgs/firehose/test/data/golden/comment_do-not-submit.md new file mode 100644 index 00000000..e69de29b diff --git a/pkgs/firehose/test/data/golden/comment_license.md b/pkgs/firehose/test/data/golden/comment_license.md new file mode 100644 index 00000000..b1f437c3 --- /dev/null +++ b/pkgs/firehose/test/data/golden/comment_license.md @@ -0,0 +1,54 @@ +### License Headers :heavy_check_mark: + +
+ +Details + + +``` +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +``` + +| Files | +| :--- | +| _no missing headers_ | + +All source files should start with a [license header](https://github.com/dart-lang/ecosystem/wiki/License-Header). + +
+ +Unrelated files missing license headers + + +| Files | +| :--- | +|test/health_test.dart| +|test/data/test_repo/pkgs/package2/test/package2_test.dart| +|test/data/test_repo/pkgs/package2/lib/package2.dart| +|test/data/test_repo/pkgs/package2/lib/anotherLib.dart| +|test/data/test_repo/pkgs/package2/bin/package2.dart| +|test/data/test_repo/pkgs/package1/test/package1_test.dart| +|test/data/test_repo/pkgs/package1/lib/package1.dart| +|test/data/test_repo/pkgs/package1/bin/package1.dart| +|test/data/test_repo/pkgs/package3/test/package3_test.dart| +|test/data/test_repo/pkgs/package3/lib/package3.dart| +|test/data/test_repo/pkgs/package3/bin/package3.dart| +|test/data/base_test_repo/pkgs/package2/test/package2_test.dart| +|test/data/base_test_repo/pkgs/package2/lib/package2.dart| +|test/data/base_test_repo/pkgs/package2/bin/package2.dart| +|test/data/base_test_repo/pkgs/package1/test/package1_test.dart| +|test/data/base_test_repo/pkgs/package1/lib/package1.dart| +|test/data/base_test_repo/pkgs/package1/bin/package1.dart| +|test/data/base_test_repo/pkgs/package3/test/package3_test.dart| +|test/data/base_test_repo/pkgs/package3/lib/package3.dart| +|test/data/base_test_repo/pkgs/package3/bin/package3.dart| +
+ + + + + +
+ diff --git a/pkgs/firehose/test/data/golden/comment_version.md b/pkgs/firehose/test/data/golden/comment_version.md new file mode 100644 index 00000000..ad153064 --- /dev/null +++ b/pkgs/firehose/test/data/golden/comment_version.md @@ -0,0 +1,17 @@ +### Package publish validation :heavy_check_mark: + +
+ +Details + + +| Package | Version | Status | +| :--- | ---: | :--- | +| package:firehose | 0.5.2 | already published at pub.dev | + +Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. + + + +
+ diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index 7848c068..a5600180 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -13,25 +13,37 @@ void main() { GitFile('pkgs/package1/bin/package1.dart', FileStatus.modified), GitFile('pkgs/package2/lib/anotherLib.dart', FileStatus.added), ]); - // await checkFor('version', fakeGithubApi); - // await checkFor('license', fakeGithubApi); - await checkFor('breaking', fakeGithubApi); + for (var check in checkTypes) { + var comment = await checkFor(check, fakeGithubApi); + var goldenFile = + File(p.join('test', 'data', 'golden', 'comment_$check.md')); + var goldenComment = goldenFile.readAsStringSync(); + if (Platform.environment.containsKey('RESET_GOLDEN')) { + goldenFile.writeAsStringSync(comment); + } else { + expect(comment, goldenComment); + } + } }); } -Future checkFor(String check, FakeGithubApi fakeGithubApi) async => - await Health( - Directory(p.join('test', 'data', 'test_repo')), - check, - [], - [], - false, - fakeGithubApi, - [], - [], - [], - base: Directory(p.join('test', 'data', 'base_test_repo')), - ).healthCheck(); +Future checkFor(String check, FakeGithubApi fakeGithubApi) async { + final comment = p.join(Directory.systemTemp.path, 'comment_$check.md'); + await Health( + Directory(p.join('test', 'data', 'test_repo')), + check, + [], + [], + false, + fakeGithubApi, + [], + [], + [], + base: Directory(p.join('test', 'data', 'base_test_repo')), + comment: comment, + ).healthCheck(); + return await File(comment).readAsString(); +} class FakeGithubApi implements GithubApi { final List files; @@ -42,35 +54,26 @@ class FakeGithubApi implements GithubApi { }); @override - // TODO: implement actor String? get actor => throw UnimplementedError(); @override - void appendStepSummary(String markdownSummary) { - // TODO: implement appendStepSummary - } + void appendStepSummary(String markdownSummary) {} @override - // TODO: implement baseRef String? get baseRef => throw UnimplementedError(); @override - void close() { - // TODO: implement close - } + void close() {} @override Future findCommentId({required String user, String? searchTerm}) { - // TODO: implement findCommentId throw UnimplementedError(); } @override - // TODO: implement githubAuthToken String? get githubAuthToken => throw UnimplementedError(); @override - // TODO: implement inGithubContext bool get inGithubContext => throw UnimplementedError(); @override @@ -83,21 +86,15 @@ class FakeGithubApi implements GithubApi { } @override - void notice({required String message}) { - // TODO: implement notice - } + void notice({required String message}) {} @override final List prLabels; @override - Future pullrequestBody() { - // TODO: implement pullrequestBody - throw UnimplementedError(); - } + Future pullrequestBody() async => 'Test body'; @override - // TODO: implement refName String? get refName => throw UnimplementedError(); @override From 05e0dc919dfbee2dcc49dfe797723f21b3cd34b3 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 11:54:36 +0100 Subject: [PATCH 14/34] Fix changelog --- pkgs/firehose/lib/src/github.dart | 16 +++++--- pkgs/firehose/lib/src/health/changelog.dart | 33 ++++++++++------- pkgs/firehose/lib/src/health/coverage.dart | 2 +- pkgs/firehose/lib/src/health/health.dart | 15 ++++---- pkgs/firehose/lib/src/health/license.dart | 3 +- pkgs/firehose/lib/src/utils.dart | 7 ---- pkgs/firehose/test/coverage_test.dart | 2 +- .../test/data/golden/comment_breaking.md | 8 ++-- .../test/data/golden/comment_changelog.md | 9 +++-- .../test/data/golden/comment_license.md | 37 +++++++------------ pkgs/firehose/test/github_test.dart | 10 ++++- pkgs/firehose/test/health_test.dart | 27 ++++++++++---- 12 files changed, 90 insertions(+), 79 deletions(-) diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index 5a1b074e..f57ba291 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart @@ -109,13 +109,17 @@ class GithubApi { return matchingComment?.id; } - Future> listFilesForPR([ + Future> listFilesForPR( + Directory directory, [ List ignoredFiles = const [], ]) async => await _github.pullRequests .listFiles(repoSlug!, issueNumber!) - .map((prFile) => - GitFile(prFile.filename!, FileStatus.fromString(prFile.status!))) + .map((prFile) => GitFile( + prFile.filename!, + FileStatus.fromString(prFile.status!), + directory, + )) .where((file) => ignoredFiles.none((glob) => glob.matches(file.relativePath))) .toList(); @@ -136,16 +140,16 @@ class GithubApi { class GitFile { final String filename; final FileStatus status; + final Directory directory; bool isInPackage(Package package) { print('Check if $relativePath is in ${package.directory.path}'); return path.isWithin(package.directory.path, relativePath); } - GitFile(this.filename, this.status); + GitFile(this.filename, this.status, this.directory); - String get relativePath => - path.relative(filename, from: Directory.current.path); + String get relativePath => path.relative(filename, from: directory.path); @override String toString() => '$filename: $status'; diff --git a/pkgs/firehose/lib/src/health/changelog.dart b/pkgs/firehose/lib/src/health/changelog.dart index b40f5e84..970d85ff 100644 --- a/pkgs/firehose/lib/src/health/changelog.dart +++ b/pkgs/firehose/lib/src/health/changelog.dart @@ -9,7 +9,6 @@ import 'package:path/path.dart' as path; import '../github.dart'; import '../repo.dart'; -import '../utils.dart'; Future>> packagesWithoutChangelog( GithubApi github, @@ -19,16 +18,19 @@ Future>> packagesWithoutChangelog( final repo = Repository(directory); final packages = repo.locatePackages(ignoredPackages); - final files = await github.listFilesForPR(); + final files = await github.listFilesForPR(directory); - var packagesWithoutChangedChangelog = - collectPackagesWithoutChangelogChanges(packages, files); + var packagesWithoutChangedChangelog = collectPackagesWithoutChangelogChanges( + packages, + files, + directory, + ); print('Collecting files without license headers in those packages:'); var packagesWithChanges = >{}; for (final file in files) { for (final package in packagesWithoutChangedChangelog) { - if (fileNeedsEntryInChangelog(package, file.relativePath)) { + if (fileNeedsEntryInChangelog(package, file.filename, directory)) { print(file); packagesWithChanges.update( package, @@ -44,21 +46,24 @@ Done, found ${packagesWithChanges.length} packages with a need for a changelog.' } List collectPackagesWithoutChangelogChanges( - List packages, List files) { + List packages, + List files, + Directory directory, +) { print('Collecting packages without changed changelogs:'); - final packagesWithoutChangedChangelog = packages - .where((package) => package.changelog.exists) - .where((package) => !files - .map((e) => e.relativePath) - .contains(package.changelog.file.relativePath)) - .toList(); + final packagesWithoutChangedChangelog = + packages.where((package) => package.changelog.exists).where((package) { + var changelogPath = + path.relative(package.changelog.file.path, from: directory.path); + return !files.map((e) => e.filename).contains(changelogPath); + }).toList(); print('Done, found ${packagesWithoutChangedChangelog.length} packages.'); return packagesWithoutChangedChangelog; } -bool fileNeedsEntryInChangelog(Package package, String file) { +bool fileNeedsEntryInChangelog(Package package, String file, Directory d) { final directoryPath = package.directory.path; - final directory = path.relative(directoryPath, from: Directory.current.path); + final directory = path.relative(directoryPath, from: d.path); final isInPackage = path.isWithin(directory, file); final isInLib = path.isWithin(path.join(directory, 'lib'), file); final isInBin = path.isWithin(path.join(directory, 'bin'), file); diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index bdc3ca6b..769e05f0 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -28,7 +28,7 @@ class Coverage { ); Future compareCoverages(GithubApi github) async { - var files = await github.listFilesForPR(ignoredFiles); + var files = await github.listFilesForPR(directory, ignoredFiles); var basePath = '../base_repo/'; return compareCoveragesFor(files, basePath); diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 93b00e87..37460ad1 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -148,7 +148,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati } Future breakingCheck() async { - final filesInPR = await github.listFilesForPR(); + final filesInPR = await github.listFilesForPR(directory); final changeForPackage = {}; for (var package in packagesContaining(filesInPR)) { print('Look for changes in $package with base $baseDirectory'); @@ -220,14 +220,15 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} } Future licenseCheck() async { - var files = await github.listFilesForPR(ignoredFilesForLicense); + var files = await github.listFilesForPR(directory, ignoredFilesForLicense); var allFilePaths = await getFilesWithoutLicenses( - Directory.current, + directory, ignoredFilesForLicense, ); - var groupedPaths = allFilePaths - .groupListsBy((path) => files.any((f) => f.relativePath == path)); + var groupedPaths = allFilePaths.groupListsBy((filePath) { + return files.any((f) => f.filename == filePath); + }); var unchangedFilesPaths = groupedPaths[false] ?? []; var unchangedMarkdown = ''' @@ -275,7 +276,7 @@ ${unchangedFilesPaths.isNotEmpty ? unchangedMarkdown : ''} final markdownResult = ''' | Package | Changed Files | | :--- | :--- | -${filePaths.entries.map((e) => '| package:${e.key.name} | ${e.value.map((e) => e.relativePath).join('
')} |').join('\n')} +${filePaths.entries.map((e) => '| package:${e.key.name} | ${e.value.map((e) => e.filename).join('
')} |').join('\n')} Changes to files need to be [accounted for](https://github.com/dart-lang/ecosystem/wiki/Changelog) in their respective changelogs. '''; @@ -289,7 +290,7 @@ Changes to files need to be [accounted for](https://github.com/dart-lang/ecosyst Future doNotSubmitCheck() async { final body = await github.pullrequestBody(); - final files = await github.listFilesForPR(); + final files = await github.listFilesForPR(directory); print('Checking for DO_NOT${'_'}SUBMIT strings: $files'); final filesWithDNS = files .where((file) => diff --git a/pkgs/firehose/lib/src/health/license.dart b/pkgs/firehose/lib/src/health/license.dart index 4c4e5f93..e37a077a 100644 --- a/pkgs/firehose/lib/src/health/license.dart +++ b/pkgs/firehose/lib/src/health/license.dart @@ -25,8 +25,7 @@ Future> getFilesWithoutLicenses( var fileContents = File(file.path).readAsStringSync(); var fileContainsCopyright = fileContents.contains('// Copyright (c)'); if (!fileContainsCopyright) { - var relativePath = - path.relative(file.path, from: Directory.current.path); + var relativePath = path.relative(file.path, from: repositoryDir.path); if (ignoredFiles.none((regex) => regex.matches(relativePath))) { print(relativePath); return relativePath; diff --git a/pkgs/firehose/lib/src/utils.dart b/pkgs/firehose/lib/src/utils.dart index 90320836..bcc5d7c3 100644 --- a/pkgs/firehose/lib/src/utils.dart +++ b/pkgs/firehose/lib/src/utils.dart @@ -5,8 +5,6 @@ import 'dart:convert'; import 'dart:io'; -import 'package:path/path.dart' as path; - /// Execute the given CLI command asynchronously, streaming stdout and stderr to /// the console. /// @@ -113,11 +111,6 @@ bool expectEnv(String? value, String name) { } } -extension FileExtension on File { - String get relativePath => - path.relative(this.path, from: Directory.current.path); -} - enum Severity { success(':heavy_check_mark:'), info(':heavy_check_mark:'), diff --git a/pkgs/firehose/test/coverage_test.dart b/pkgs/firehose/test/coverage_test.dart index 0c0e300e..1915daa6 100644 --- a/pkgs/firehose/test/coverage_test.dart +++ b/pkgs/firehose/test/coverage_test.dart @@ -33,7 +33,7 @@ void main() { }); test('Compare coverage', () async { var coverages = FakeHealth().compareCoveragesFor( - [GitFile('testfile.dart', FileStatus.modified)], + [GitFile('testfile.dart', FileStatus.modified, Directory.current)], 'base_path_does_not_exist', ); diff --git a/pkgs/firehose/test/data/golden/comment_breaking.md b/pkgs/firehose/test/data/golden/comment_breaking.md index 85987b04..422549bd 100644 --- a/pkgs/firehose/test/data/golden/comment_breaking.md +++ b/pkgs/firehose/test/data/golden/comment_breaking.md @@ -1,6 +1,6 @@ -### Breaking changes :heavy_check_mark: +### Breaking changes :warning: -
+
Details @@ -8,9 +8,9 @@ Details | Package | Change | Current Version | New Version | Needed Version | Looking good? | | :--- | :--- | ---: | ---: | ---: | ---: | |package1|None|1.0.0|1.0.0|1.0.0|:heavy_check_mark:| -|package2|None|1.0.0|1.0.0|1.0.0|:heavy_check_mark:| - +|package2|Non-Breaking|1.0.0|1.0.0|**1.1.0**
Got "1.0.0" expected >= "1.1.0" (non-breaking changes)|:warning:| +This check can be disabled by tagging the PR with `skip-breaking-check`
diff --git a/pkgs/firehose/test/data/golden/comment_changelog.md b/pkgs/firehose/test/data/golden/comment_changelog.md index 1c3fae90..dfbadb2b 100644 --- a/pkgs/firehose/test/data/golden/comment_changelog.md +++ b/pkgs/firehose/test/data/golden/comment_changelog.md @@ -1,17 +1,18 @@ -### Changelog Entry :heavy_check_mark: +### Changelog Entry :exclamation: -
+
Details | Package | Changed Files | | :--- | :--- | - +| package:package1 | pkgs/package1/bin/package1.dart | +| package:package2 | pkgs/package2/lib/anotherLib.dart | Changes to files need to be [accounted for](https://github.com/dart-lang/ecosystem/wiki/Changelog) in their respective changelogs. - +This check can be disabled by tagging the PR with `skip-changelog-check`
diff --git a/pkgs/firehose/test/data/golden/comment_license.md b/pkgs/firehose/test/data/golden/comment_license.md index b1f437c3..a6100c32 100644 --- a/pkgs/firehose/test/data/golden/comment_license.md +++ b/pkgs/firehose/test/data/golden/comment_license.md @@ -1,6 +1,6 @@ -### License Headers :heavy_check_mark: +### License Headers :exclamation: -
+
Details @@ -13,7 +13,8 @@ Details | Files | | :--- | -| _no missing headers_ | +|pkgs/package2/lib/anotherLib.dart| +|pkgs/package1/bin/package1.dart| All source files should start with a [license header](https://github.com/dart-lang/ecosystem/wiki/License-Header). @@ -24,31 +25,19 @@ Unrelated files missing license headers | Files | | :--- | -|test/health_test.dart| -|test/data/test_repo/pkgs/package2/test/package2_test.dart| -|test/data/test_repo/pkgs/package2/lib/package2.dart| -|test/data/test_repo/pkgs/package2/lib/anotherLib.dart| -|test/data/test_repo/pkgs/package2/bin/package2.dart| -|test/data/test_repo/pkgs/package1/test/package1_test.dart| -|test/data/test_repo/pkgs/package1/lib/package1.dart| -|test/data/test_repo/pkgs/package1/bin/package1.dart| -|test/data/test_repo/pkgs/package3/test/package3_test.dart| -|test/data/test_repo/pkgs/package3/lib/package3.dart| -|test/data/test_repo/pkgs/package3/bin/package3.dart| -|test/data/base_test_repo/pkgs/package2/test/package2_test.dart| -|test/data/base_test_repo/pkgs/package2/lib/package2.dart| -|test/data/base_test_repo/pkgs/package2/bin/package2.dart| -|test/data/base_test_repo/pkgs/package1/test/package1_test.dart| -|test/data/base_test_repo/pkgs/package1/lib/package1.dart| -|test/data/base_test_repo/pkgs/package1/bin/package1.dart| -|test/data/base_test_repo/pkgs/package3/test/package3_test.dart| -|test/data/base_test_repo/pkgs/package3/lib/package3.dart| -|test/data/base_test_repo/pkgs/package3/bin/package3.dart| +|pkgs/package2/test/package2_test.dart| +|pkgs/package2/lib/package2.dart| +|pkgs/package2/bin/package2.dart| +|pkgs/package1/test/package1_test.dart| +|pkgs/package1/lib/package1.dart| +|pkgs/package3/test/package3_test.dart| +|pkgs/package3/lib/package3.dart| +|pkgs/package3/bin/package3.dart|
- +This check can be disabled by tagging the PR with `skip-license-check`
diff --git a/pkgs/firehose/test/github_test.dart b/pkgs/firehose/test/github_test.dart index ef47b54e..10941440 100644 --- a/pkgs/firehose/test/github_test.dart +++ b/pkgs/firehose/test/github_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:io'; + import 'package:firehose/src/github.dart'; import 'package:github/github.dart'; import 'package:test/test.dart'; @@ -19,9 +21,13 @@ Future main() async { 'Bumps [actions/labeler](https://github.com/actions/labeler) from 4.0.4 to 4.3.0.\n')); }); test('Listing files for PR', () async { - var files = await github.listFilesForPR(); + var files = await github.listFilesForPR(Directory.current); expect(files, [ - GitFile('.github/workflows/pull_request_label.yml', FileStatus.modified), + GitFile( + '.github/workflows/pull_request_label.yml', + FileStatus.modified, + Directory.current, + ), ]); }); test('Find comment', () async { diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index a5600180..1eb2a72a 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -9,12 +9,21 @@ import 'package:test/test.dart'; void main() { test('test name', () async { + final directory = Directory(p.join('test', 'data', 'test_repo')); var fakeGithubApi = FakeGithubApi(prLabels: [], files: [ - GitFile('pkgs/package1/bin/package1.dart', FileStatus.modified), - GitFile('pkgs/package2/lib/anotherLib.dart', FileStatus.added), + GitFile( + 'pkgs/package1/bin/package1.dart', + FileStatus.modified, + directory, + ), + GitFile( + 'pkgs/package2/lib/anotherLib.dart', + FileStatus.added, + directory, + ), ]); - for (var check in checkTypes) { - var comment = await checkFor(check, fakeGithubApi); + for (var check in ['changelog']) { + var comment = await checkFor(check, fakeGithubApi, directory); var goldenFile = File(p.join('test', 'data', 'golden', 'comment_$check.md')); var goldenComment = goldenFile.readAsStringSync(); @@ -27,10 +36,14 @@ void main() { }); } -Future checkFor(String check, FakeGithubApi fakeGithubApi) async { +Future checkFor( + String check, + FakeGithubApi fakeGithubApi, + Directory directory, +) async { final comment = p.join(Directory.systemTemp.path, 'comment_$check.md'); await Health( - Directory(p.join('test', 'data', 'test_repo')), + directory, check, [], [], @@ -80,7 +93,7 @@ class FakeGithubApi implements GithubApi { int? get issueNumber => 1; @override - Future> listFilesForPR( + Future> listFilesForPR(Directory directory, [List ignoredFiles = const []]) async { return files; } From f623f41a60e104ab45af1b8a793841269c288e88 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 12:04:22 +0100 Subject: [PATCH 15/34] Fix coverage --- pkgs/firehose/lib/src/github.dart | 4 +-- pkgs/firehose/lib/src/health/coverage.dart | 32 +++++++++---------- pkgs/firehose/lib/src/health/health.dart | 2 +- .../test/data/golden/comment_coverage.md | 9 +++--- pkgs/firehose/test/health_test.dart | 2 +- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index f57ba291..12bd650a 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart @@ -143,8 +143,8 @@ class GitFile { final Directory directory; bool isInPackage(Package package) { - print('Check if $relativePath is in ${package.directory.path}'); - return path.isWithin(package.directory.path, relativePath); + return path.isWithin( + package.directory.path, path.join(directory.path, filename)); } GitFile(this.filename, this.status, this.directory); diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index 769e05f0..abc64bf4 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -27,28 +27,26 @@ class Coverage { this.directory, ); - Future compareCoverages(GithubApi github) async { + Future compareCoverages( + GithubApi github, Directory base) async { var files = await github.listFilesForPR(directory, ignoredFiles); - var basePath = '../base_repo/'; - return compareCoveragesFor(files, basePath); + return compareCoveragesFor(files, base); } - CoverageResult compareCoveragesFor(List files, String basePath) { + CoverageResult compareCoveragesFor(List files, Directory base) { var repository = Repository(directory); var packages = repository.locatePackages(ignoredPackages); - print('Found packages $packages at ${Directory.current}'); + print('Found packages $packages at $directory'); var filesOfInterest = files .where((file) => path.extension(file.filename) == '.dart') .where((file) => file.status != FileStatus.removed) - .where((file) => isInSomePackage(packages, file.relativePath)) - .where((file) => isNotATest(packages, file.relativePath)) + .where((file) => isInSomePackage(packages, file.filename)) + .where((file) => isNotATest(packages, file.filename)) .toList(); print('The files of interest are $filesOfInterest'); - var base = Directory(basePath); - var baseRepository = Repository(base); var basePackages = baseRepository.locatePackages(ignoredFiles); print('Found packages $basePackages at $base'); @@ -70,7 +68,7 @@ class Coverage { final oldCoverages = getCoverage(basePackage); var filePaths = filesOfInterest .where((file) => file.isInPackage(package)) - .map((file) => file.relativePath); + .map((file) => file.filename); for (var filePath in filePaths) { var oldCoverage = oldCoverages[filePath]; var newCoverage = newCoverages[filePath]; @@ -85,14 +83,16 @@ class Coverage { } bool isNotATest(List packages, String file) { - return packages.every((package) => - !path.isWithin(path.join(package.directory.path, 'test'), file)); + return packages.every((package) => !path.isWithin( + path.join(package.directory.path, 'test'), + path.join(directory.path, file))); } - bool isInSomePackage(List packages, String file) { - return packages - .any((package) => path.isWithin(package.directory.path, file)); - } + bool isInSomePackage(List packages, String file) => + packages.any((package) => path.isWithin( + package.directory.path, + path.join(directory.path, file), + )); Map getCoverage(Package? package) { if (package != null) { diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 37460ad1..8e70cbad 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -325,7 +325,7 @@ ${filesWithDNS.map((e) => e.filename).map((e) => '|$e|').join('\n')} ignoredFilesForCoverage, ignoredPackages, directory, - ).compareCoverages(github); + ).compareCoverages(github, baseDirectory); var markdownResult = ''' | File | Coverage | diff --git a/pkgs/firehose/test/data/golden/comment_coverage.md b/pkgs/firehose/test/data/golden/comment_coverage.md index e6870d34..909e7df8 100644 --- a/pkgs/firehose/test/data/golden/comment_coverage.md +++ b/pkgs/firehose/test/data/golden/comment_coverage.md @@ -1,17 +1,18 @@ -### Coverage :heavy_check_mark: +### Coverage :warning: -
+
Details | File | Coverage | | :--- | :--- | - +|pkgs/package1/bin/package1.dart| :broken_heart: Not covered | +|pkgs/package2/lib/anotherLib.dart| :broken_heart: Not covered | This check for [test coverage](https://github.com/dart-lang/ecosystem/wiki/Test-Coverage) is informational (issues shown here will not fail the PR). - +This check can be disabled by tagging the PR with `skip-coverage-check`
diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index 1eb2a72a..badd9d03 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -22,7 +22,7 @@ void main() { directory, ), ]); - for (var check in ['changelog']) { + for (var check in ['coverage']) { var comment = await checkFor(check, fakeGithubApi, directory); var goldenFile = File(p.join('test', 'data', 'golden', 'comment_$check.md')); From 93a0d44c634fed4a5a52892228eacb28709835ca Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 12:07:06 +0100 Subject: [PATCH 16/34] Fix breaking --- pkgs/firehose/lib/src/health/health.dart | 2 +- pkgs/firehose/test/health_test.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 8e70cbad..6a928ec9 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -386,7 +386,7 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r var relativePackageDirectory = path.relative(package.directory.path, from: directory.path); return files.any( - (file) => path.isWithin(relativePackageDirectory, file.relativePath)); + (file) => path.isWithin(relativePackageDirectory, file.filename)); }).toList(); } } diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index badd9d03..a98e939b 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -22,7 +22,7 @@ void main() { directory, ), ]); - for (var check in ['coverage']) { + for (var check in ['breaking']) { var comment = await checkFor(check, fakeGithubApi, directory); var goldenFile = File(p.join('test', 'data', 'golden', 'comment_$check.md')); From 989649e42e70fa0b7fe27fecdbe0b4812bac63df Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:00:09 +0100 Subject: [PATCH 17/34] More fixes --- pkgs/firehose/lib/firehose.dart | 2 +- pkgs/firehose/lib/src/github.dart | 9 ++++----- pkgs/firehose/lib/src/health/changelog.dart | 6 +++--- pkgs/firehose/lib/src/health/health.dart | 13 ++++++------- pkgs/firehose/test/coverage_test.dart | 2 +- .../pkgs/package2/bin/package2.dart | 4 ++++ .../test/data/golden/comment_coverage.md | 2 +- .../test/data/golden/comment_do-not-submit.md | 17 +++++++++++++++++ .../test/data/golden/comment_license.md | 1 - .../test/data/golden/comment_version.md | 10 ++++++---- .../test_repo/pkgs/package1/bin/package1.dart | 2 +- .../test_repo/pkgs/package2/bin/package2.dart | 4 ++++ .../pkgs/package2/test/package2_test.dart | 8 ++++++-- pkgs/firehose/test/health_test.dart | 4 ++-- 14 files changed, 56 insertions(+), 28 deletions(-) diff --git a/pkgs/firehose/lib/firehose.dart b/pkgs/firehose/lib/firehose.dart index b2d24999..3f4ce73e 100644 --- a/pkgs/firehose/lib/firehose.dart +++ b/pkgs/firehose/lib/firehose.dart @@ -96,7 +96,7 @@ Saving existing comment id $existingCommentId to file ${idFile.path}'''); GithubApi github, [ List ignoredPackages = const [], ]) async { - var repo = Repository(); + var repo = Repository(directory); var packages = repo.locatePackages(ignoredPackages); var pub = Pub(); diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index 12bd650a..a13781f5 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart @@ -121,7 +121,7 @@ class GithubApi { directory, )) .where((file) => - ignoredFiles.none((glob) => glob.matches(file.relativePath))) + ignoredFiles.none((glob) => glob.matches(file.filename))) .toList(); /// Write a notice message to the github log. @@ -143,13 +143,12 @@ class GitFile { final Directory directory; bool isInPackage(Package package) { - return path.isWithin( - package.directory.path, path.join(directory.path, filename)); + return path.isWithin(package.directory.path, pathInRepository); } - GitFile(this.filename, this.status, this.directory); + String get pathInRepository => path.join(directory.path, filename); - String get relativePath => path.relative(filename, from: directory.path); + GitFile(this.filename, this.status, this.directory); @override String toString() => '$filename: $status'; diff --git a/pkgs/firehose/lib/src/health/changelog.dart b/pkgs/firehose/lib/src/health/changelog.dart index 970d85ff..a5107706 100644 --- a/pkgs/firehose/lib/src/health/changelog.dart +++ b/pkgs/firehose/lib/src/health/changelog.dart @@ -53,9 +53,9 @@ List collectPackagesWithoutChangelogChanges( print('Collecting packages without changed changelogs:'); final packagesWithoutChangedChangelog = packages.where((package) => package.changelog.exists).where((package) { - var changelogPath = - path.relative(package.changelog.file.path, from: directory.path); - return !files.map((e) => e.filename).contains(changelogPath); + return !files + .map((e) => e.pathInRepository) + .contains(package.changelog.file.path); }).toList(); print('Done, found ${packagesWithoutChangedChangelog.length} packages.'); return packagesWithoutChangedChangelog; diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 6a928ec9..2a0f1691 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -295,7 +295,7 @@ Changes to files need to be [accounted for](https://github.com/dart-lang/ecosyst final filesWithDNS = files .where((file) => ![FileStatus.removed, FileStatus.unchanged].contains(file.status)) - .where((file) => File(path.join(directory.path, file.relativePath)) + .where((file) => File(file.pathInRepository) .readAsStringSync() .contains('DO_NOT${'_'}SUBMIT')) .toList(); @@ -382,12 +382,11 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r List packagesContaining(List filesInPR) { var files = filesInPR.where((element) => element.status.isRelevant); final repo = Repository(directory); - return repo.locatePackages(ignoredPackages).where((package) { - var relativePackageDirectory = - path.relative(package.directory.path, from: directory.path); - return files.any( - (file) => path.isWithin(relativePackageDirectory, file.filename)); - }).toList(); + return repo + .locatePackages(ignoredPackages) + .where((package) => files.any((file) => + path.isWithin(package.directory.path, file.pathInRepository))) + .toList(); } } diff --git a/pkgs/firehose/test/coverage_test.dart b/pkgs/firehose/test/coverage_test.dart index 1915daa6..0119c733 100644 --- a/pkgs/firehose/test/coverage_test.dart +++ b/pkgs/firehose/test/coverage_test.dart @@ -34,7 +34,7 @@ void main() { test('Compare coverage', () async { var coverages = FakeHealth().compareCoveragesFor( [GitFile('testfile.dart', FileStatus.modified, Directory.current)], - 'base_path_does_not_exist', + Directory('base_path_does_not_exist'), ); expect(coverages.coveragePerFile, diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart index 8b179182..dcc9c524 100644 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + import 'package:package2/package2.dart' as package2; void main(List arguments) { diff --git a/pkgs/firehose/test/data/golden/comment_coverage.md b/pkgs/firehose/test/data/golden/comment_coverage.md index 909e7df8..c594cbfa 100644 --- a/pkgs/firehose/test/data/golden/comment_coverage.md +++ b/pkgs/firehose/test/data/golden/comment_coverage.md @@ -8,7 +8,7 @@ Details | File | Coverage | | :--- | :--- | |pkgs/package1/bin/package1.dart| :broken_heart: Not covered | -|pkgs/package2/lib/anotherLib.dart| :broken_heart: Not covered | +|pkgs/package2/lib/anotherLib.dart| :green_heart: 100 % | This check for [test coverage](https://github.com/dart-lang/ecosystem/wiki/Test-Coverage) is informational (issues shown here will not fail the PR). diff --git a/pkgs/firehose/test/data/golden/comment_do-not-submit.md b/pkgs/firehose/test/data/golden/comment_do-not-submit.md index e69de29b..8daf42da 100644 --- a/pkgs/firehose/test/data/golden/comment_do-not-submit.md +++ b/pkgs/firehose/test/data/golden/comment_do-not-submit.md @@ -0,0 +1,17 @@ +### Do Not Submit :exclamation: + +
+ +Details + + +Body contains `DO_NOT_SUBMIT`: false + +| Files with `DO_NOT_SUBMIT` | +| :--- | +|pkgs/package1/bin/package1.dart| + + +This check can be disabled by tagging the PR with `skip-do-not-submit-check` +
+ diff --git a/pkgs/firehose/test/data/golden/comment_license.md b/pkgs/firehose/test/data/golden/comment_license.md index a6100c32..f24025eb 100644 --- a/pkgs/firehose/test/data/golden/comment_license.md +++ b/pkgs/firehose/test/data/golden/comment_license.md @@ -27,7 +27,6 @@ Unrelated files missing license headers | :--- | |pkgs/package2/test/package2_test.dart| |pkgs/package2/lib/package2.dart| -|pkgs/package2/bin/package2.dart| |pkgs/package1/test/package1_test.dart| |pkgs/package1/lib/package1.dart| |pkgs/package3/test/package3_test.dart| diff --git a/pkgs/firehose/test/data/golden/comment_version.md b/pkgs/firehose/test/data/golden/comment_version.md index ad153064..c03092a4 100644 --- a/pkgs/firehose/test/data/golden/comment_version.md +++ b/pkgs/firehose/test/data/golden/comment_version.md @@ -1,17 +1,19 @@ -### Package publish validation :heavy_check_mark: +### Package publish validation :exclamation: -
+
Details | Package | Version | Status | | :--- | ---: | :--- | -| package:firehose | 0.5.2 | already published at pub.dev | +| package:package1 | 1.0.0 | (error) pub publish dry-run failed; add the `publish-ignore-warnings` label to ignore | +| package:package2 | 1.0.0 | (error) pub publish dry-run failed; add the `publish-ignore-warnings` label to ignore | +| package:package3 | 1.0.0 | (error) pub publish dry-run failed; add the `publish-ignore-warnings` label to ignore | Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. - +This check can be disabled by tagging the PR with `skip-version-check`
diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart b/pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart index ff95264e..9fb09431 100644 --- a/pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart +++ b/pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart @@ -1,6 +1,6 @@ import 'package:package1/package1.dart' as package1; void main(List arguments) { - // Add a comment + // Add a comment DO_NOT_SUBMIT print('Hello world: ${package1.calculate()}!'); } diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart b/pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart index 8b179182..dcc9c524 100644 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + import 'package:package2/package2.dart' as package2; void main(List arguments) { diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart b/pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart index 0b0e31b6..cbf30f4f 100644 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart @@ -1,8 +1,12 @@ -import 'package:package2/package2.dart'; +import 'package:package2/anotherLib.dart' as anotherLib; +import 'package:package2/package2.dart' as p2; import 'package:test/test.dart'; void main() { test('calculate', () { - expect(calculate(), 42); + expect(p2.calculate(), 42); + }); + test('calculate', () { + expect(anotherLib.calculateUnused(), 42); }); } diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index a98e939b..4596d78c 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -22,7 +22,7 @@ void main() { directory, ), ]); - for (var check in ['breaking']) { + for (var check in checkTypes) { var comment = await checkFor(check, fakeGithubApi, directory); var goldenFile = File(p.join('test', 'data', 'golden', 'comment_$check.md')); @@ -33,7 +33,7 @@ void main() { expect(comment, goldenComment); } } - }); + }, timeout: const Timeout(Duration(minutes: 2))); } Future checkFor( From 938801e243c4a69be81748bb4ad6fe45c0ba4c2a Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 23 Jan 2024 16:41:29 +0100 Subject: [PATCH 18/34] Merge --- pkgs/firehose/lib/src/github.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index e3e07b82..45484bd0 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart @@ -6,6 +6,7 @@ import 'dart:io'; import 'package:github/github.dart'; +import 'package:glob/glob.dart'; import 'package:http/http.dart' as http; import 'package:path/path.dart' as path; @@ -107,7 +108,10 @@ class GithubApi { return matchingComment?.id; } - Future> listFilesForPR(Directory directory) async => + Future> listFilesForPR( + Directory directory, [ + List ignoredFiles = const [], + ]) async => await _github.pullRequests .listFiles(repoSlug!, issueNumber!) .map((prFile) => GitFile( From 1c87747a7ecd1586d065e432078b7eb218bfc07f Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 23 Jan 2024 16:49:34 +0100 Subject: [PATCH 19/34] Fixes --- .github/workflows/health_internal.yaml | 2 +- pkgs/firehose/lib/src/health/changelog.dart | 2 +- pkgs/firehose/lib/src/health/health.dart | 13 +++--- .../base_test_repo/pkgs/package1/.gitignore | 3 -- .../base_test_repo/pkgs/package1/CHANGELOG.md | 3 -- .../base_test_repo/pkgs/package1/README.md | 2 - .../pkgs/package1/analysis_options.yaml | 30 ------------- .../pkgs/package1/bin/package1.dart | 5 --- .../pkgs/package1/lib/package1.dart | 3 -- .../base_test_repo/pkgs/package1/pubspec.yaml | 15 ------- .../pkgs/package1/test/package1_test.dart | 8 ---- .../base_test_repo/pkgs/package2/.gitignore | 3 -- .../base_test_repo/pkgs/package2/CHANGELOG.md | 3 -- .../base_test_repo/pkgs/package2/README.md | 2 - .../pkgs/package2/analysis_options.yaml | 30 ------------- .../pkgs/package2/bin/package2.dart | 9 ---- .../pkgs/package2/lib/package2.dart | 3 -- .../base_test_repo/pkgs/package2/pubspec.yaml | 15 ------- .../pkgs/package2/test/package2_test.dart | 8 ---- .../base_test_repo/pkgs/package3/.gitignore | 3 -- .../base_test_repo/pkgs/package3/CHANGELOG.md | 3 -- .../base_test_repo/pkgs/package3/README.md | 2 - .../pkgs/package3/analysis_options.yaml | 30 ------------- .../pkgs/package3/bin/package3.dart | 5 --- .../pkgs/package3/lib/package3.dart | 3 -- .../base_test_repo/pkgs/package3/pubspec.yaml | 15 ------- .../pkgs/package3/test/package3_test.dart | 8 ---- .../test/data/golden/comment_breaking.md | 16 ------- .../test/data/golden/comment_changelog.md | 18 -------- .../test/data/golden/comment_coverage.md | 18 -------- .../test/data/golden/comment_do-not-submit.md | 17 -------- .../test/data/golden/comment_license.md | 42 ------------------- .../test/data/golden/comment_version.md | 19 --------- .../data/test_repo/pkgs/package1/.gitignore | 3 -- .../data/test_repo/pkgs/package1/CHANGELOG.md | 3 -- .../data/test_repo/pkgs/package1/README.md | 2 - .../pkgs/package1/analysis_options.yaml | 30 ------------- .../test_repo/pkgs/package1/bin/package1.dart | 6 --- .../test_repo/pkgs/package1/lib/package1.dart | 3 -- .../data/test_repo/pkgs/package1/pubspec.yaml | 15 ------- .../pkgs/package1/test/package1_test.dart | 8 ---- .../data/test_repo/pkgs/package2/.gitignore | 3 -- .../data/test_repo/pkgs/package2/CHANGELOG.md | 3 -- .../data/test_repo/pkgs/package2/README.md | 2 - .../pkgs/package2/analysis_options.yaml | 30 ------------- .../test_repo/pkgs/package2/bin/package2.dart | 9 ---- .../pkgs/package2/lib/anotherLib.dart | 3 -- .../test_repo/pkgs/package2/lib/package2.dart | 3 -- .../data/test_repo/pkgs/package2/pubspec.yaml | 15 ------- .../pkgs/package2/test/package2_test.dart | 12 ------ .../data/test_repo/pkgs/package3/.gitignore | 3 -- .../data/test_repo/pkgs/package3/CHANGELOG.md | 3 -- .../data/test_repo/pkgs/package3/README.md | 2 - .../pkgs/package3/analysis_options.yaml | 30 ------------- .../test_repo/pkgs/package3/bin/package3.dart | 5 --- .../test_repo/pkgs/package3/lib/package3.dart | 3 -- .../data/test_repo/pkgs/package3/pubspec.yaml | 15 ------- .../pkgs/package3/test/package3_test.dart | 8 ---- 58 files changed, 10 insertions(+), 567 deletions(-) delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/.gitignore delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/CHANGELOG.md delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/README.md delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/analysis_options.yaml delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/lib/package1.dart delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package1/test/package1_test.dart delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/.gitignore delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/CHANGELOG.md delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/README.md delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/analysis_options.yaml delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/package2.dart delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package2/test/package2_test.dart delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/.gitignore delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/CHANGELOG.md delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/README.md delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/analysis_options.yaml delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/bin/package3.dart delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/lib/package3.dart delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml delete mode 100644 pkgs/firehose/test/data/base_test_repo/pkgs/package3/test/package3_test.dart delete mode 100644 pkgs/firehose/test/data/golden/comment_breaking.md delete mode 100644 pkgs/firehose/test/data/golden/comment_changelog.md delete mode 100644 pkgs/firehose/test/data/golden/comment_coverage.md delete mode 100644 pkgs/firehose/test/data/golden/comment_do-not-submit.md delete mode 100644 pkgs/firehose/test/data/golden/comment_license.md delete mode 100644 pkgs/firehose/test/data/golden/comment_version.md delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/.gitignore delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/CHANGELOG.md delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/README.md delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/analysis_options.yaml delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/lib/package1.dart delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package1/test/package1_test.dart delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/.gitignore delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/CHANGELOG.md delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/README.md delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/analysis_options.yaml delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/lib/anotherLib.dart delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/lib/package2.dart delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/.gitignore delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/CHANGELOG.md delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/README.md delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/analysis_options.yaml delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/bin/package3.dart delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/lib/package3.dart delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml delete mode 100644 pkgs/firehose/test/data/test_repo/pkgs/package3/test/package3_test.dart diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml index f99c4d9d..43dc4fdc 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -15,4 +15,4 @@ jobs: checks: version,changelog,license,coverage,breaking,do-not-submit fail_on: version,changelog,do-not-submit warn_on: license,coverage,breaking - ignore: '**.g.dart' + ignore_license: '**.g.dart' diff --git a/pkgs/firehose/lib/src/health/changelog.dart b/pkgs/firehose/lib/src/health/changelog.dart index a5107706..95ad14ab 100644 --- a/pkgs/firehose/lib/src/health/changelog.dart +++ b/pkgs/firehose/lib/src/health/changelog.dart @@ -18,7 +18,7 @@ Future>> packagesWithoutChangelog( final repo = Repository(directory); final packages = repo.locatePackages(ignoredPackages); - final files = await github.listFilesForPR(directory); + final files = await github.listFilesForPR(directory, ignoredPackages); var packagesWithoutChangedChangelog = collectPackagesWithoutChangelogChanges( packages, diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index e672f408..6fbac171 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -150,9 +150,9 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati } Future breakingCheck() async { - final filesInPR = await github.listFilesForPR(directory); + final filesInPR = await github.listFilesForPR(directory, ignoredPackages); final changeForPackage = {}; - for (var package in packagesContaining(filesInPR)) { + for (var package in packagesContaining(filesInPR, ignoredPackages)) { print('Look for changes in $package with base $baseDirectory'); var relativePath = path.relative(package.directory.path, from: directory.path); @@ -222,7 +222,7 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} } Future licenseCheck() async { - var files = await github.listFilesForPR(directory); + var files = await github.listFilesForPR(directory, ignoredPackages); var allFilePaths = await getFilesWithoutLicenses( directory, ignoredFilesForLicense, @@ -384,10 +384,13 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r } } - List packagesContaining(List filesInPR) { + List packagesContaining( + List filesInPR, + List ignoredPackages, + ) { var files = filesInPR.where((element) => element.status.isRelevant); final repo = Repository(); - return repo.locatePackages().where((package) { + return repo.locatePackages(ignoredPackages).where((package) { var relativePackageDirectory = path.relative(package.directory.path, from: Directory.current.path); return files.any((file) => diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/.gitignore b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/.gitignore deleted file mode 100644 index 3a857904..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# https://dart.dev/guides/libraries/private-files -# Created by `dart pub` -.dart_tool/ diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/CHANGELOG.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/CHANGELOG.md deleted file mode 100644 index effe43c8..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 1.0.0 - -- Initial version. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/README.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/README.md deleted file mode 100644 index 3816eca3..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/README.md +++ /dev/null @@ -1,2 +0,0 @@ -A sample command-line application with an entrypoint in `bin/`, library code -in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/analysis_options.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/analysis_options.yaml deleted file mode 100644 index dee8927a..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart deleted file mode 100644 index a8525dd6..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:package1/package1.dart' as package1; - -void main(List arguments) { - print('Hello world: ${package1.calculate()}!'); -} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/lib/package1.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/lib/package1.dart deleted file mode 100644 index f64ad726..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/lib/package1.dart +++ /dev/null @@ -1,3 +0,0 @@ -int calculate() { - return 6 * 7; -} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml deleted file mode 100644 index e4663470..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: package1 -description: A sample command-line application. -version: 1.0.0 -# repository: https://github.com/my_org/my_repo - -environment: - sdk: ^3.4.0-4.0.dev - -# Add regular dependencies here. -dependencies: - # path: ^1.8.0 - -dev_dependencies: - lints: ^3.0.0 - test: ^1.24.0 diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/test/package1_test.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/test/package1_test.dart deleted file mode 100644 index 5d8a815f..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/test/package1_test.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:package1/package1.dart'; -import 'package:test/test.dart'; - -void main() { - test('calculate', () { - expect(calculate(), 42); - }); -} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/.gitignore b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/.gitignore deleted file mode 100644 index 3a857904..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# https://dart.dev/guides/libraries/private-files -# Created by `dart pub` -.dart_tool/ diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/CHANGELOG.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/CHANGELOG.md deleted file mode 100644 index effe43c8..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 1.0.0 - -- Initial version. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/README.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/README.md deleted file mode 100644 index 3816eca3..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/README.md +++ /dev/null @@ -1,2 +0,0 @@ -A sample command-line application with an entrypoint in `bin/`, library code -in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/analysis_options.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/analysis_options.yaml deleted file mode 100644 index dee8927a..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart deleted file mode 100644 index dcc9c524..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:package2/package2.dart' as package2; - -void main(List arguments) { - print('Hello world: ${package2.calculate()}!'); -} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/package2.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/package2.dart deleted file mode 100644 index f64ad726..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/package2.dart +++ /dev/null @@ -1,3 +0,0 @@ -int calculate() { - return 6 * 7; -} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml deleted file mode 100644 index 7a037494..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: package2 -description: A sample command-line application. -version: 1.0.0 -# repository: https://github.com/my_org/my_repo - -environment: - sdk: ^3.4.0-4.0.dev - -# Add regular dependencies here. -dependencies: - # path: ^1.8.0 - -dev_dependencies: - lints: ^3.0.0 - test: ^1.24.0 diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/test/package2_test.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/test/package2_test.dart deleted file mode 100644 index 0b0e31b6..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/test/package2_test.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:package2/package2.dart'; -import 'package:test/test.dart'; - -void main() { - test('calculate', () { - expect(calculate(), 42); - }); -} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/.gitignore b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/.gitignore deleted file mode 100644 index 3a857904..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# https://dart.dev/guides/libraries/private-files -# Created by `dart pub` -.dart_tool/ diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/CHANGELOG.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/CHANGELOG.md deleted file mode 100644 index effe43c8..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 1.0.0 - -- Initial version. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/README.md b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/README.md deleted file mode 100644 index 3816eca3..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/README.md +++ /dev/null @@ -1,2 +0,0 @@ -A sample command-line application with an entrypoint in `bin/`, library code -in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/analysis_options.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/analysis_options.yaml deleted file mode 100644 index dee8927a..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/bin/package3.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/bin/package3.dart deleted file mode 100644 index b6ba11df..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/bin/package3.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:package3/package3.dart' as package3; - -void main(List arguments) { - print('Hello world: ${package3.calculate()}!'); -} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/lib/package3.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/lib/package3.dart deleted file mode 100644 index f64ad726..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/lib/package3.dart +++ /dev/null @@ -1,3 +0,0 @@ -int calculate() { - return 6 * 7; -} diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml deleted file mode 100644 index e6ad38ab..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: package3 -description: A sample command-line application. -version: 1.0.0 -# repository: https://github.com/my_org/my_repo - -environment: - sdk: ^3.4.0-4.0.dev - -# Add regular dependencies here. -dependencies: - # path: ^1.8.0 - -dev_dependencies: - lints: ^3.0.0 - test: ^1.24.0 diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/test/package3_test.dart b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/test/package3_test.dart deleted file mode 100644 index a2f5a1bc..00000000 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/test/package3_test.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:package3/package3.dart'; -import 'package:test/test.dart'; - -void main() { - test('calculate', () { - expect(calculate(), 42); - }); -} diff --git a/pkgs/firehose/test/data/golden/comment_breaking.md b/pkgs/firehose/test/data/golden/comment_breaking.md deleted file mode 100644 index 422549bd..00000000 --- a/pkgs/firehose/test/data/golden/comment_breaking.md +++ /dev/null @@ -1,16 +0,0 @@ -### Breaking changes :warning: - -
- -Details - - -| Package | Change | Current Version | New Version | Needed Version | Looking good? | -| :--- | :--- | ---: | ---: | ---: | ---: | -|package1|None|1.0.0|1.0.0|1.0.0|:heavy_check_mark:| -|package2|Non-Breaking|1.0.0|1.0.0|**1.1.0**
Got "1.0.0" expected >= "1.1.0" (non-breaking changes)|:warning:| - - -This check can be disabled by tagging the PR with `skip-breaking-check` -
- diff --git a/pkgs/firehose/test/data/golden/comment_changelog.md b/pkgs/firehose/test/data/golden/comment_changelog.md deleted file mode 100644 index dfbadb2b..00000000 --- a/pkgs/firehose/test/data/golden/comment_changelog.md +++ /dev/null @@ -1,18 +0,0 @@ -### Changelog Entry :exclamation: - -
- -Details - - -| Package | Changed Files | -| :--- | :--- | -| package:package1 | pkgs/package1/bin/package1.dart | -| package:package2 | pkgs/package2/lib/anotherLib.dart | - -Changes to files need to be [accounted for](https://github.com/dart-lang/ecosystem/wiki/Changelog) in their respective changelogs. - - -This check can be disabled by tagging the PR with `skip-changelog-check` -
- diff --git a/pkgs/firehose/test/data/golden/comment_coverage.md b/pkgs/firehose/test/data/golden/comment_coverage.md deleted file mode 100644 index c594cbfa..00000000 --- a/pkgs/firehose/test/data/golden/comment_coverage.md +++ /dev/null @@ -1,18 +0,0 @@ -### Coverage :warning: - -
- -Details - - -| File | Coverage | -| :--- | :--- | -|pkgs/package1/bin/package1.dart| :broken_heart: Not covered | -|pkgs/package2/lib/anotherLib.dart| :green_heart: 100 % | - -This check for [test coverage](https://github.com/dart-lang/ecosystem/wiki/Test-Coverage) is informational (issues shown here will not fail the PR). - - -This check can be disabled by tagging the PR with `skip-coverage-check` -
- diff --git a/pkgs/firehose/test/data/golden/comment_do-not-submit.md b/pkgs/firehose/test/data/golden/comment_do-not-submit.md deleted file mode 100644 index 8daf42da..00000000 --- a/pkgs/firehose/test/data/golden/comment_do-not-submit.md +++ /dev/null @@ -1,17 +0,0 @@ -### Do Not Submit :exclamation: - -
- -Details - - -Body contains `DO_NOT_SUBMIT`: false - -| Files with `DO_NOT_SUBMIT` | -| :--- | -|pkgs/package1/bin/package1.dart| - - -This check can be disabled by tagging the PR with `skip-do-not-submit-check` -
- diff --git a/pkgs/firehose/test/data/golden/comment_license.md b/pkgs/firehose/test/data/golden/comment_license.md deleted file mode 100644 index f24025eb..00000000 --- a/pkgs/firehose/test/data/golden/comment_license.md +++ /dev/null @@ -1,42 +0,0 @@ -### License Headers :exclamation: - -
- -Details - - -``` -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. -``` - -| Files | -| :--- | -|pkgs/package2/lib/anotherLib.dart| -|pkgs/package1/bin/package1.dart| - -All source files should start with a [license header](https://github.com/dart-lang/ecosystem/wiki/License-Header). - -
- -Unrelated files missing license headers - - -| Files | -| :--- | -|pkgs/package2/test/package2_test.dart| -|pkgs/package2/lib/package2.dart| -|pkgs/package1/test/package1_test.dart| -|pkgs/package1/lib/package1.dart| -|pkgs/package3/test/package3_test.dart| -|pkgs/package3/lib/package3.dart| -|pkgs/package3/bin/package3.dart| -
- - - - -This check can be disabled by tagging the PR with `skip-license-check` -
- diff --git a/pkgs/firehose/test/data/golden/comment_version.md b/pkgs/firehose/test/data/golden/comment_version.md deleted file mode 100644 index c03092a4..00000000 --- a/pkgs/firehose/test/data/golden/comment_version.md +++ /dev/null @@ -1,19 +0,0 @@ -### Package publish validation :exclamation: - -
- -Details - - -| Package | Version | Status | -| :--- | ---: | :--- | -| package:package1 | 1.0.0 | (error) pub publish dry-run failed; add the `publish-ignore-warnings` label to ignore | -| package:package2 | 1.0.0 | (error) pub publish dry-run failed; add the `publish-ignore-warnings` label to ignore | -| package:package3 | 1.0.0 | (error) pub publish dry-run failed; add the `publish-ignore-warnings` label to ignore | - -Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. - - -This check can be disabled by tagging the PR with `skip-version-check` -
- diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/.gitignore b/pkgs/firehose/test/data/test_repo/pkgs/package1/.gitignore deleted file mode 100644 index 3a857904..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package1/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# https://dart.dev/guides/libraries/private-files -# Created by `dart pub` -.dart_tool/ diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/CHANGELOG.md b/pkgs/firehose/test/data/test_repo/pkgs/package1/CHANGELOG.md deleted file mode 100644 index effe43c8..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package1/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 1.0.0 - -- Initial version. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/README.md b/pkgs/firehose/test/data/test_repo/pkgs/package1/README.md deleted file mode 100644 index 3816eca3..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package1/README.md +++ /dev/null @@ -1,2 +0,0 @@ -A sample command-line application with an entrypoint in `bin/`, library code -in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/analysis_options.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package1/analysis_options.yaml deleted file mode 100644 index dee8927a..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package1/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart b/pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart deleted file mode 100644 index 9fb09431..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart +++ /dev/null @@ -1,6 +0,0 @@ -import 'package:package1/package1.dart' as package1; - -void main(List arguments) { - // Add a comment DO_NOT_SUBMIT - print('Hello world: ${package1.calculate()}!'); -} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/lib/package1.dart b/pkgs/firehose/test/data/test_repo/pkgs/package1/lib/package1.dart deleted file mode 100644 index f64ad726..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package1/lib/package1.dart +++ /dev/null @@ -1,3 +0,0 @@ -int calculate() { - return 6 * 7; -} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml deleted file mode 100644 index e4663470..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: package1 -description: A sample command-line application. -version: 1.0.0 -# repository: https://github.com/my_org/my_repo - -environment: - sdk: ^3.4.0-4.0.dev - -# Add regular dependencies here. -dependencies: - # path: ^1.8.0 - -dev_dependencies: - lints: ^3.0.0 - test: ^1.24.0 diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/test/package1_test.dart b/pkgs/firehose/test/data/test_repo/pkgs/package1/test/package1_test.dart deleted file mode 100644 index 5d8a815f..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package1/test/package1_test.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:package1/package1.dart'; -import 'package:test/test.dart'; - -void main() { - test('calculate', () { - expect(calculate(), 42); - }); -} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/.gitignore b/pkgs/firehose/test/data/test_repo/pkgs/package2/.gitignore deleted file mode 100644 index 3a857904..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# https://dart.dev/guides/libraries/private-files -# Created by `dart pub` -.dart_tool/ diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/CHANGELOG.md b/pkgs/firehose/test/data/test_repo/pkgs/package2/CHANGELOG.md deleted file mode 100644 index effe43c8..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 1.0.0 - -- Initial version. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/README.md b/pkgs/firehose/test/data/test_repo/pkgs/package2/README.md deleted file mode 100644 index 3816eca3..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/README.md +++ /dev/null @@ -1,2 +0,0 @@ -A sample command-line application with an entrypoint in `bin/`, library code -in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/analysis_options.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package2/analysis_options.yaml deleted file mode 100644 index dee8927a..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart b/pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart deleted file mode 100644 index dcc9c524..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:package2/package2.dart' as package2; - -void main(List arguments) { - print('Hello world: ${package2.calculate()}!'); -} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/anotherLib.dart b/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/anotherLib.dart deleted file mode 100644 index af52fa18..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/anotherLib.dart +++ /dev/null @@ -1,3 +0,0 @@ -int calculateUnused() { - return 6 * 7; -} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/package2.dart b/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/package2.dart deleted file mode 100644 index f64ad726..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/lib/package2.dart +++ /dev/null @@ -1,3 +0,0 @@ -int calculate() { - return 6 * 7; -} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml deleted file mode 100644 index 7a037494..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: package2 -description: A sample command-line application. -version: 1.0.0 -# repository: https://github.com/my_org/my_repo - -environment: - sdk: ^3.4.0-4.0.dev - -# Add regular dependencies here. -dependencies: - # path: ^1.8.0 - -dev_dependencies: - lints: ^3.0.0 - test: ^1.24.0 diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart b/pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart deleted file mode 100644 index cbf30f4f..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:package2/anotherLib.dart' as anotherLib; -import 'package:package2/package2.dart' as p2; -import 'package:test/test.dart'; - -void main() { - test('calculate', () { - expect(p2.calculate(), 42); - }); - test('calculate', () { - expect(anotherLib.calculateUnused(), 42); - }); -} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/.gitignore b/pkgs/firehose/test/data/test_repo/pkgs/package3/.gitignore deleted file mode 100644 index 3a857904..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package3/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# https://dart.dev/guides/libraries/private-files -# Created by `dart pub` -.dart_tool/ diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/CHANGELOG.md b/pkgs/firehose/test/data/test_repo/pkgs/package3/CHANGELOG.md deleted file mode 100644 index effe43c8..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package3/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 1.0.0 - -- Initial version. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/README.md b/pkgs/firehose/test/data/test_repo/pkgs/package3/README.md deleted file mode 100644 index 3816eca3..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package3/README.md +++ /dev/null @@ -1,2 +0,0 @@ -A sample command-line application with an entrypoint in `bin/`, library code -in `lib/`, and example unit test in `test/`. diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/analysis_options.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package3/analysis_options.yaml deleted file mode 100644 index dee8927a..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package3/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/bin/package3.dart b/pkgs/firehose/test/data/test_repo/pkgs/package3/bin/package3.dart deleted file mode 100644 index b6ba11df..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package3/bin/package3.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:package3/package3.dart' as package3; - -void main(List arguments) { - print('Hello world: ${package3.calculate()}!'); -} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/lib/package3.dart b/pkgs/firehose/test/data/test_repo/pkgs/package3/lib/package3.dart deleted file mode 100644 index f64ad726..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package3/lib/package3.dart +++ /dev/null @@ -1,3 +0,0 @@ -int calculate() { - return 6 * 7; -} diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml deleted file mode 100644 index e6ad38ab..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: package3 -description: A sample command-line application. -version: 1.0.0 -# repository: https://github.com/my_org/my_repo - -environment: - sdk: ^3.4.0-4.0.dev - -# Add regular dependencies here. -dependencies: - # path: ^1.8.0 - -dev_dependencies: - lints: ^3.0.0 - test: ^1.24.0 diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/test/package3_test.dart b/pkgs/firehose/test/data/test_repo/pkgs/package3/test/package3_test.dart deleted file mode 100644 index a2f5a1bc..00000000 --- a/pkgs/firehose/test/data/test_repo/pkgs/package3/test/package3_test.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:package3/package3.dart'; -import 'package:test/test.dart'; - -void main() { - test('calculate', () { - expect(calculate(), 42); - }); -} From 075ad902cb3f9f64df5bb0930244b46c768a44a4 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 23 Jan 2024 16:50:15 +0100 Subject: [PATCH 20/34] Move --- pkgs/firehose/test/health_test.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index 9ac24dd1..a63ff248 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -98,6 +98,12 @@ class FakeGithubApi implements GithubApi { @override int? get issueNumber => 1; + @override + Future> listFilesForPR(Directory directory, + [List ignoredFiles = const []]) async { + return files; + } + @override void notice({required String message}) {} @@ -115,10 +121,4 @@ class FakeGithubApi implements GithubApi { @override String? get sha => 'test_sha'; - - @override - Future> listFilesForPR(Directory directory, - [List ignoredFiles = const []]) async { - return files; - } } From 15ce667865fffdadef1ca4d8dd9e254afad6b5e2 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 23 Jan 2024 17:04:12 +0100 Subject: [PATCH 21/34] Fix tests --- pkgs/firehose/lib/src/health/health.dart | 13 ++++---- pkgs/firehose/test/health_test.dart | 40 ++++++++++++------------ 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 6fbac171..8cb3e299 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -389,13 +389,12 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r List ignoredPackages, ) { var files = filesInPR.where((element) => element.status.isRelevant); - final repo = Repository(); - return repo.locatePackages(ignoredPackages).where((package) { - var relativePackageDirectory = - path.relative(package.directory.path, from: Directory.current.path); - return files.any((file) => - path.isWithin(relativePackageDirectory, file.pathInRepository)); - }).toList(); + final repo = Repository(directory); + return repo + .locatePackages(ignoredPackages) + .where((package) => files.any((file) => + path.isWithin(package.directory.path, file.pathInRepository))) + .toList(); } } diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index a63ff248..76725f51 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -11,24 +11,24 @@ import 'package:glob/glob.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; -void main() { - test('Check health workflow against golden files', () async { - final directory = Directory(p.join('test_data', 'test_repo')); - var fakeGithubApi = FakeGithubApi(prLabels: [], files: [ - GitFile( - 'pkgs/package1/bin/package1.dart', - FileStatus.modified, - directory, - ), - GitFile( - 'pkgs/package2/lib/anotherLib.dart', - FileStatus.added, - directory, - ), - ]); - await Process.run('dart', ['pub', 'global', 'activate', 'dart_apitool']); - await Process.run('dart', ['pub', 'global', 'activate', 'coverage']); - for (var check in checkTypes) { +Future main() async { + final directory = Directory(p.join('test_data', 'test_repo')); + var fakeGithubApi = FakeGithubApi(prLabels: [], files: [ + GitFile( + 'pkgs/package1/bin/package1.dart', + FileStatus.modified, + directory, + ), + GitFile( + 'pkgs/package2/lib/anotherLib.dart', + FileStatus.added, + directory, + ), + ]); + await Process.run('dart', ['pub', 'global', 'activate', 'dart_apitool']); + await Process.run('dart', ['pub', 'global', 'activate', 'coverage']); + for (var check in checkTypes) { + test('Check health workflow "$check" against golden files', () async { var comment = await checkFor(check, fakeGithubApi, directory); var goldenFile = File(p.join('test_data', 'golden', 'comment_$check.md')); var goldenComment = goldenFile.readAsStringSync(); @@ -37,8 +37,8 @@ void main() { } else { expect(comment, goldenComment); } - } - }, timeout: const Timeout(Duration(minutes: 2))); + }, timeout: const Timeout(Duration(minutes: 2))); + } } Future checkFor( From 2b504533f51df810af8098ceb4795ca92e16c629 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 23 Jan 2024 17:07:47 +0100 Subject: [PATCH 22/34] Ignore test data licenses --- .github/workflows/health_internal.yaml | 2 +- pkgs/firehose/lib/src/health/health.dart | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml index 43dc4fdc..5c2e970c 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -15,4 +15,4 @@ jobs: checks: version,changelog,license,coverage,breaking,do-not-submit fail_on: version,changelog,do-not-submit warn_on: license,coverage,breaking - ignore_license: '**.g.dart' + ignore_license: 'pkgs/firehose/test_data/**' diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 8cb3e299..40341dc4 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -389,8 +389,7 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r List ignoredPackages, ) { var files = filesInPR.where((element) => element.status.isRelevant); - final repo = Repository(directory); - return repo + return Repository(directory) .locatePackages(ignoredPackages) .where((package) => files.any((file) => path.isWithin(package.directory.path, file.pathInRepository))) From b9e2d2d69cb322e8d3804d76eefbf034d2f167e5 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 24 Jan 2024 09:28:17 +0100 Subject: [PATCH 23/34] Add golden without license --- .../golden/comment_license_ignore.md | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 pkgs/firehose/test_data/golden/comment_license_ignore.md diff --git a/pkgs/firehose/test_data/golden/comment_license_ignore.md b/pkgs/firehose/test_data/golden/comment_license_ignore.md new file mode 100644 index 00000000..a53ef1cb --- /dev/null +++ b/pkgs/firehose/test_data/golden/comment_license_ignore.md @@ -0,0 +1,42 @@ +### License Headers :exclamation: + +
+ +Details + + +``` +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +``` + +| Files | +| :--- | +|pkgs/package1/bin/package1.dart| +|pkgs/package2/lib/anotherLib.dart| + +All source files should start with a [license header](https://github.com/dart-lang/ecosystem/wiki/License-Header). + +
+ +Unrelated files missing license headers + + +| Files | +| :--- | +|pkgs/package1/lib/package1.dart| +|pkgs/package1/test/package1_test.dart| +|pkgs/package2/lib/package2.dart| +|pkgs/package2/test/package2_test.dart| +|pkgs/package3/bin/package3.dart| +|pkgs/package3/lib/package3.dart| +|pkgs/package3/test/package3_test.dart| +
+ + + + +This check can be disabled by tagging the PR with `skip-license-check` +
+ From 7dda2a59edfdca5806212d597751e6e674666c7c Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 24 Jan 2024 09:28:46 +0100 Subject: [PATCH 24/34] Fix license --- pkgs/firehose/CHANGELOG.md | 4 ++ pkgs/firehose/lib/src/health/license.dart | 19 ++++---- pkgs/firehose/pubspec.yaml | 2 +- pkgs/firehose/test/health_test.dart | 43 ++++++++++++------- .../golden/comment_license_ignore.md | 3 -- 5 files changed, 44 insertions(+), 27 deletions(-) diff --git a/pkgs/firehose/CHANGELOG.md b/pkgs/firehose/CHANGELOG.md index 2d232c98..ca3a4010 100644 --- a/pkgs/firehose/CHANGELOG.md +++ b/pkgs/firehose/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.1 + +- Add `ignore` flags to the health workflow. + ## 0.6.0 - Make the health workflow testable with golden tests. diff --git a/pkgs/firehose/lib/src/health/license.dart b/pkgs/firehose/lib/src/health/license.dart index c10146ad..66462ee0 100644 --- a/pkgs/firehose/lib/src/health/license.dart +++ b/pkgs/firehose/lib/src/health/license.dart @@ -17,17 +17,20 @@ Future> getFilesWithoutLicenses( Directory repositoryDir, List ignoredFiles) async { var dartFiles = await repositoryDir .list(recursive: true) - .where((f) => f.path.endsWith('.dart')) + .where((file) => file.path.endsWith('.dart')) .toList(); - print('Collecting files without license headers:'); + print('Collecting files without license headers $dartFiles:'); var filesWithoutLicenses = dartFiles .map((file) { - var fileContents = File(file.path).readAsStringSync(); - var fileContainsCopyright = fileContents.contains('// Copyright (c)'); - if (!fileContainsCopyright) { - var relativePath = path.relative(file.path, from: repositoryDir.path); - print(relativePath); - return relativePath; + var relativePath = path.relative(file.path, from: repositoryDir.path); + if (ignoredFiles.none((glob) => + glob.matches(path.relative(file.path, from: repositoryDir.path)))) { + var fileContents = File(file.path).readAsStringSync(); + var fileContainsCopyright = fileContents.contains('// Copyright (c)'); + if (!fileContainsCopyright) { + print(relativePath); + return relativePath; + } } }) .whereType() diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml index 687629cf..8c064218 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.6.0 +version: 0.6.1 repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose environment: diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index 76725f51..5633e1d3 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -27,26 +27,32 @@ Future main() async { ]); await Process.run('dart', ['pub', 'global', 'activate', 'dart_apitool']); await Process.run('dart', ['pub', 'global', 'activate', 'coverage']); + for (var check in checkTypes) { test('Check health workflow "$check" against golden files', () async { - var comment = await checkFor(check, fakeGithubApi, directory); - var goldenFile = File(p.join('test_data', 'golden', 'comment_$check.md')); - var goldenComment = goldenFile.readAsStringSync(); - if (Platform.environment.containsKey('RESET_GOLDEN')) { - goldenFile.writeAsStringSync(comment); - } else { - expect(comment, goldenComment); - } + await checkGolden(check, fakeGithubApi, directory); }, timeout: const Timeout(Duration(minutes: 2))); } + + test('Ignore license test', () async { + await checkGolden( + 'license', + fakeGithubApi, + directory, + suffix: '_ignore', + ignoredLicense: ['pkgs/package3/**'], + ); + }); } -Future checkFor( +Future checkGolden( String check, FakeGithubApi fakeGithubApi, - Directory directory, -) async { - final comment = p.join(Directory.systemTemp.path, 'comment_$check.md'); + Directory directory, { + String suffix = '', + List ignoredLicense = const [], +}) async { + final commentPath = p.join(Directory.systemTemp.path, 'comment_$check.md'); await Health( directory, check, @@ -54,14 +60,21 @@ Future checkFor( [], false, [], - [], + ignoredLicense, [], [], fakeGithubApi, base: Directory(p.join('test_data', 'base_test_repo')), - comment: comment, + comment: commentPath, ).healthCheck(); - return await File(comment).readAsString(); + var comment = await File(commentPath).readAsString(); + var goldenFile = + File(p.join('test_data', 'golden', 'comment_$check$suffix.md')); + if (Platform.environment['RESET_GOLDEN'] == '1') { + goldenFile.writeAsStringSync(comment); + } else { + expect(comment, goldenFile.readAsStringSync()); + } } class FakeGithubApi implements GithubApi { diff --git a/pkgs/firehose/test_data/golden/comment_license_ignore.md b/pkgs/firehose/test_data/golden/comment_license_ignore.md index a53ef1cb..4fa23f1a 100644 --- a/pkgs/firehose/test_data/golden/comment_license_ignore.md +++ b/pkgs/firehose/test_data/golden/comment_license_ignore.md @@ -29,9 +29,6 @@ Unrelated files missing license headers |pkgs/package1/test/package1_test.dart| |pkgs/package2/lib/package2.dart| |pkgs/package2/test/package2_test.dart| -|pkgs/package3/bin/package3.dart| -|pkgs/package3/lib/package3.dart| -|pkgs/package3/test/package3_test.dart|
From 40d255825ca778101a182572ed0eb51c77b5fe77 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 24 Jan 2024 09:30:35 +0100 Subject: [PATCH 25/34] Rename --- ...omment_license_ignore.md => comment_license_ignore_license.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pkgs/firehose/test_data/golden/{comment_license_ignore.md => comment_license_ignore_license.md} (100%) diff --git a/pkgs/firehose/test_data/golden/comment_license_ignore.md b/pkgs/firehose/test_data/golden/comment_license_ignore_license.md similarity index 100% rename from pkgs/firehose/test_data/golden/comment_license_ignore.md rename to pkgs/firehose/test_data/golden/comment_license_ignore_license.md From 075024426b73fba6913e7d2c38be18a82b6ff13d Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 26 Jan 2024 08:35:43 +0100 Subject: [PATCH 26/34] Fix --- pkgs/firehose/lib/src/github.dart | 8 ++-- pkgs/firehose/lib/src/health/coverage.dart | 20 +++++++--- pkgs/firehose/lib/src/health/health.dart | 9 +++-- pkgs/firehose/lib/src/health/license.dart | 2 +- pkgs/firehose/lib/src/repo.dart | 4 +- pkgs/firehose/test/health_test.dart | 35 ++++++++++++++--- .../golden/comment_breaking_ignore_package.md | 15 +++++++ .../comment_changelog_ignore_package.md | 17 ++++++++ .../golden/comment_coverage_ignore_package.md | 17 ++++++++ .../comment_do-not-submit_ignore_package.md | 0 .../golden/comment_license_ignore_package.md | 39 +++++++++++++++++++ .../golden/comment_version_ignore_package.md | 18 +++++++++ 12 files changed, 163 insertions(+), 21 deletions(-) create mode 100644 pkgs/firehose/test_data/golden/comment_breaking_ignore_package.md create mode 100644 pkgs/firehose/test_data/golden/comment_changelog_ignore_package.md create mode 100644 pkgs/firehose/test_data/golden/comment_coverage_ignore_package.md create mode 100644 pkgs/firehose/test_data/golden/comment_do-not-submit_ignore_package.md create mode 100644 pkgs/firehose/test_data/golden/comment_license_ignore_package.md create mode 100644 pkgs/firehose/test_data/golden/comment_version_ignore_package.md diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index 45484bd0..4904c83a 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart @@ -5,6 +5,7 @@ import 'dart:io'; +import 'package:collection/collection.dart'; import 'package:github/github.dart'; import 'package:glob/glob.dart'; import 'package:http/http.dart' as http; @@ -119,6 +120,8 @@ class GithubApi { FileStatus.fromString(prFile.status!), directory, )) + .where((file) => + ignoredFiles.none((glob) => glob.matches(file.filename))) .toList(); /// Write a notice message to the github log. @@ -139,9 +142,8 @@ class GitFile { final FileStatus status; final Directory directory; - bool isInPackage(Package package) { - return path.isWithin(package.directory.path, pathInRepository); - } + bool isInPackage(Package package) => + path.isWithin(package.directory.path, pathInRepository); String get pathInRepository => path.join(directory.path, filename); diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index ab21d7bb..bb0610dc 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -128,9 +128,12 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path ], workingDirectory: package.directory.path, ); - print(resultChrome.stdout); - print(resultChrome.stderr); + if (resultChrome.exitCode != 0) { + print(resultChrome.stderr); + } + print('Dart test browser: ${resultChrome.stdout}'); } + print('Run tests with coverage for vm'); var resultVm = Process.runSync( 'dart', @@ -142,8 +145,11 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path ], workingDirectory: package.directory.path, ); - print('dart test stdout: ${resultVm.stdout}'); - print('dart test stderr: ${resultVm.stderr}'); + if (resultVm.exitCode != 0) { + print(resultVm.stderr); + } + print('Dart test VM: ${resultVm.stdout}'); + print('Compute coverage from runs'); var resultLcov = Process.runSync( 'dart', @@ -162,8 +168,10 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path ], workingDirectory: package.directory.path, ); - print('dart coverage stdout: ${resultLcov.stdout}'); - print('dart coverage stderr: ${resultLcov.stderr}'); + if (resultLcov.exitCode != 0) { + print(resultLcov.stderr); + } + print('Dart coverage: ${resultLcov.stdout}'); return parseLCOV( path.join(package.directory.path, 'coverage/lcov.info'), relativeTo: package.repository.baseDirectory.path, diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 40341dc4..0e929b3f 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -60,7 +60,9 @@ class Health { this.github, { Directory? base, String? comment, - }) : ignoredPackages = ignoredPackages.map(Glob.new).toList(), + }) : ignoredPackages = ignoredPackages + .map((pattern) => Glob(pattern, recursive: true)) + .toList(), ignoredFilesForCoverage = ignoredCoverage.map(Glob.new).toList(), ignoredFilesForLicense = ignoredLicense.map(Glob.new).toList(), baseDirectory = base ?? Directory('../base_repo'), @@ -225,7 +227,7 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} var files = await github.listFilesForPR(directory, ignoredPackages); var allFilePaths = await getFilesWithoutLicenses( directory, - ignoredFilesForLicense, + [...ignoredFilesForLicense, ...ignoredPackages], ); var groupedPaths = allFilePaths.groupListsBy((filePath) { @@ -295,7 +297,8 @@ Changes to files need to be [accounted for](https://github.com/dart-lang/ecosyst final body = await github.pullrequestBody(); final files = await github.listFilesForPR(directory, ignoredPackages); - print('Checking for DO_NOT${'_'}SUBMIT strings: $files'); + print( + 'Checking for DO_NOT${'_'}SUBMIT strings with $ignoredPackages: $files'); final filesWithDNS = files .where((file) => ![FileStatus.removed, FileStatus.unchanged].contains(file.status)) diff --git a/pkgs/firehose/lib/src/health/license.dart b/pkgs/firehose/lib/src/health/license.dart index 66462ee0..18a1e433 100644 --- a/pkgs/firehose/lib/src/health/license.dart +++ b/pkgs/firehose/lib/src/health/license.dart @@ -19,7 +19,7 @@ Future> getFilesWithoutLicenses( .list(recursive: true) .where((file) => file.path.endsWith('.dart')) .toList(); - print('Collecting files without license headers $dartFiles:'); + print('Collecting files without license headers:'); var filesWithoutLicenses = dartFiles .map((file) { var relativePath = path.relative(file.path, from: repositoryDir.path); diff --git a/pkgs/firehose/lib/src/repo.dart b/pkgs/firehose/lib/src/repo.dart index 2342ecae..1cdd1df6 100644 --- a/pkgs/firehose/lib/src/repo.dart +++ b/pkgs/firehose/lib/src/repo.dart @@ -43,8 +43,8 @@ class Repository { List locatePackages([List ignore = const []]) { final packages = []; _recurseAndGather(baseDirectory, packages); - packages.removeWhere((package) => - ignore.any((glob) => glob.matches(package.directory.path))); + packages.removeWhere((package) => ignore.any((glob) => glob.matches( + path.relative(package.directory.path, from: baseDirectory.path)))); packages.sort((a, b) => a.name.compareTo(b.name)); return packages; } diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index 5633e1d3..33025f66 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -4,6 +4,7 @@ import 'dart:io'; +import 'package:collection/collection.dart'; import 'package:firehose/src/github.dart'; import 'package:firehose/src/health/health.dart'; import 'package:github/src/common/model/repos.dart'; @@ -29,9 +30,11 @@ Future main() async { await Process.run('dart', ['pub', 'global', 'activate', 'coverage']); for (var check in checkTypes) { - test('Check health workflow "$check" against golden files', () async { - await checkGolden(check, fakeGithubApi, directory); - }, timeout: const Timeout(Duration(minutes: 2))); + test( + 'Check health workflow "$check" against golden files', + () async => await checkGolden(check, fakeGithubApi, directory), + timeout: const Timeout(Duration(minutes: 2)), + ); } test('Ignore license test', () async { @@ -39,10 +42,26 @@ Future main() async { 'license', fakeGithubApi, directory, - suffix: '_ignore', + suffix: '_ignore_license', ignoredLicense: ['pkgs/package3/**'], ); }); + + test( + 'Ignore packages test', + () async { + for (var check in checkTypes) { + await checkGolden( + check, + fakeGithubApi, + directory, + suffix: '_ignore_package', + ignoredPackage: ['pkgs/package1'], + ); + } + }, + timeout: const Timeout(Duration(minutes: 2)), + ); } Future checkGolden( @@ -51,6 +70,7 @@ Future checkGolden( Directory directory, { String suffix = '', List ignoredLicense = const [], + List ignoredPackage = const [], }) async { final commentPath = p.join(Directory.systemTemp.path, 'comment_$check.md'); await Health( @@ -59,7 +79,7 @@ Future checkGolden( [], [], false, - [], + ignoredPackage, ignoredLicense, [], [], @@ -114,7 +134,10 @@ class FakeGithubApi implements GithubApi { @override Future> listFilesForPR(Directory directory, [List ignoredFiles = const []]) async { - return files; + return files + .where((element) => + ignoredFiles.none((p0) => p0.matches(element.filename))) + .toList(); } @override diff --git a/pkgs/firehose/test_data/golden/comment_breaking_ignore_package.md b/pkgs/firehose/test_data/golden/comment_breaking_ignore_package.md new file mode 100644 index 00000000..d3368608 --- /dev/null +++ b/pkgs/firehose/test_data/golden/comment_breaking_ignore_package.md @@ -0,0 +1,15 @@ +### Breaking changes :warning: + +
+ +Details + + +| Package | Change | Current Version | New Version | Needed Version | Looking good? | +| :--- | :--- | ---: | ---: | ---: | ---: | +|package2|Non-Breaking|1.0.0|1.0.0|**1.1.0**
Got "1.0.0" expected >= "1.1.0" (non-breaking changes)|:warning:| + + +This check can be disabled by tagging the PR with `skip-breaking-check` +
+ diff --git a/pkgs/firehose/test_data/golden/comment_changelog_ignore_package.md b/pkgs/firehose/test_data/golden/comment_changelog_ignore_package.md new file mode 100644 index 00000000..d7b7d12f --- /dev/null +++ b/pkgs/firehose/test_data/golden/comment_changelog_ignore_package.md @@ -0,0 +1,17 @@ +### Changelog Entry :exclamation: + +
+ +Details + + +| Package | Changed Files | +| :--- | :--- | +| package:package2 | pkgs/package2/lib/anotherLib.dart | + +Changes to files need to be [accounted for](https://github.com/dart-lang/ecosystem/wiki/Changelog) in their respective changelogs. + + +This check can be disabled by tagging the PR with `skip-changelog-check` +
+ diff --git a/pkgs/firehose/test_data/golden/comment_coverage_ignore_package.md b/pkgs/firehose/test_data/golden/comment_coverage_ignore_package.md new file mode 100644 index 00000000..c6bdd11a --- /dev/null +++ b/pkgs/firehose/test_data/golden/comment_coverage_ignore_package.md @@ -0,0 +1,17 @@ +### Coverage :heavy_check_mark: + +
+ +Details + + +| File | Coverage | +| :--- | :--- | +|pkgs/package2/lib/anotherLib.dart| :green_heart: 100 % | + +This check for [test coverage](https://github.com/dart-lang/ecosystem/wiki/Test-Coverage) is informational (issues shown here will not fail the PR). + + + +
+ diff --git a/pkgs/firehose/test_data/golden/comment_do-not-submit_ignore_package.md b/pkgs/firehose/test_data/golden/comment_do-not-submit_ignore_package.md new file mode 100644 index 00000000..e69de29b diff --git a/pkgs/firehose/test_data/golden/comment_license_ignore_package.md b/pkgs/firehose/test_data/golden/comment_license_ignore_package.md new file mode 100644 index 00000000..59c637d8 --- /dev/null +++ b/pkgs/firehose/test_data/golden/comment_license_ignore_package.md @@ -0,0 +1,39 @@ +### License Headers :exclamation: + +
+ +Details + + +``` +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +``` + +| Files | +| :--- | +|pkgs/package2/lib/anotherLib.dart| + +All source files should start with a [license header](https://github.com/dart-lang/ecosystem/wiki/License-Header). + +
+ +Unrelated files missing license headers + + +| Files | +| :--- | +|pkgs/package2/lib/package2.dart| +|pkgs/package2/test/package2_test.dart| +|pkgs/package3/bin/package3.dart| +|pkgs/package3/lib/package3.dart| +|pkgs/package3/test/package3_test.dart| +
+ + + + +This check can be disabled by tagging the PR with `skip-license-check` +
+ diff --git a/pkgs/firehose/test_data/golden/comment_version_ignore_package.md b/pkgs/firehose/test_data/golden/comment_version_ignore_package.md new file mode 100644 index 00000000..17ab16e6 --- /dev/null +++ b/pkgs/firehose/test_data/golden/comment_version_ignore_package.md @@ -0,0 +1,18 @@ +### Package publish validation :exclamation: + +
+ +Details + + +| Package | Version | Status | +| :--- | ---: | :--- | +| package:package2 | 1.0.0 | (error) pub publish dry-run failed; add the `publish-ignore-warnings` label to ignore | +| package:package3 | 1.0.0 | (error) pub publish dry-run failed; add the `publish-ignore-warnings` label to ignore | + +Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. + + +This check can be disabled by tagging the PR with `skip-version-check` +
+ From aeff8e2e892ff08a574a5accdc9af25dfbc90abf Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 26 Jan 2024 08:40:04 +0100 Subject: [PATCH 27/34] Fix analyze issue --- pkgs/firehose/lib/src/health/health.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 0e929b3f..cf2e953d 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -297,8 +297,7 @@ Changes to files need to be [accounted for](https://github.com/dart-lang/ecosyst final body = await github.pullrequestBody(); final files = await github.listFilesForPR(directory, ignoredPackages); - print( - 'Checking for DO_NOT${'_'}SUBMIT strings with $ignoredPackages: $files'); + print('Checking for DO_NOT${'_'}SUBMIT strings: $files'); final filesWithDNS = files .where((file) => ![FileStatus.removed, FileStatus.unchanged].contains(file.status)) From 93efe49d018e64131567d9533c709e98ec6917f7 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 26 Jan 2024 09:17:59 +0100 Subject: [PATCH 28/34] Add args printing --- .github/workflows/health_internal.yaml | 1 + pkgs/firehose/lib/src/health/health.dart | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml index 5c2e970c..5f97f6bf 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -16,3 +16,4 @@ jobs: fail_on: version,changelog,do-not-submit warn_on: license,coverage,breaking ignore_license: 'pkgs/firehose/test_data/**' + ignore_coverage: 'pkgs/firehose/bin/**' diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index cf2e953d..779c8a21 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -90,7 +90,15 @@ class Health { if (!expectEnv(github.issueNumber?.toString(), 'ISSUE_NUMBER')) return; if (!expectEnv(github.sha, 'GITHUB_SHA')) return; - print('Start health check for the check $check'); + print('Start health check for the check $check with'); + print(' warnOn: $warnOn'); + print(' failOn: $failOn'); + print(' coverageweb: $coverageweb'); + print(' ignoredPackages: $ignoredPackages'); + print(' ignoredForLicense: $ignoredFilesForLicense'); + print(' ignoredForCoverage: $ignoredFilesForCoverage'); + print(' baseDirectory: $baseDirectory'); + print(' experiments: $experiments'); print('Checking for $check'); if (!github.prLabels.contains('skip-$check-check')) { final firstResult = await checkFor(check)(); From 45f962b5e53a621f3058ec6169628fb3cb1a6526 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 26 Jan 2024 09:32:37 +0100 Subject: [PATCH 29/34] Add defaults --- .github/workflows/health_base.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 603f4346..589eabd1 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -51,14 +51,17 @@ on: type: boolean ignore_license: description: Which files to ignore for the license check. + default: "\"\"" required: false type: string ignore_coverage: description: Which files to ignore for the coverage check. + default: "\"\"" required: false type: string ignore_packages: description: Which packages to ignore. + default: "\"\"" required: false type: string checkout_submodules: From ea82305ea0efa3594a06380fa3ace7a102c8e6c7 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 26 Jan 2024 09:36:12 +0100 Subject: [PATCH 30/34] Add more defaults --- .github/workflows/health.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index e3d6995c..3ec0f035 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -84,14 +84,17 @@ on: type: boolean ignore_license: description: Which files to ignore for the license check. + default: "\"\"" required: false type: string ignore_coverage: description: Which files to ignore for the coverage check. + default: "\"\"" required: false type: string ignore_packages: description: Which packages to ignore. + default: "\"\"" required: false type: string checkout_submodules: From e9f3663aa706fe47bf87d32d8f5a462be2c0c2f4 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 26 Jan 2024 09:39:28 +0100 Subject: [PATCH 31/34] Remove empty --- pkgs/firehose/bin/health.dart | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pkgs/firehose/bin/health.dart b/pkgs/firehose/bin/health.dart index 10e71734..5a36b213 100644 --- a/pkgs/firehose/bin/health.dart +++ b/pkgs/firehose/bin/health.dart @@ -48,17 +48,15 @@ void main(List arguments) async { 'coverage_web', help: 'Whether to run web tests for coverage', ); - var parsedArgs = argParser.parse(arguments); - var check = parsedArgs['check'] as String; - var warnOn = parsedArgs['warn_on'] as List; - var failOn = parsedArgs['fail_on'] as List; - var ignorePackages = parsedArgs['ignore_packages'] as List; - var ignoreLicense = parsedArgs['ignore_license'] as List; - var ignoreCoverage = parsedArgs['ignore_coverage'] as List; - var experiments = (parsedArgs['experiments'] as List) - .where((name) => name.isNotEmpty) - .toList(); - var coverageWeb = parsedArgs['coverage_web'] as bool; + final parsedArgs = argParser.parse(arguments); + final check = parsedArgs['check'] as String; + final warnOn = parsedArgs['warn_on'] as List; + final failOn = parsedArgs['fail_on'] as List; + final ignorePackages = _listNonEmpty(parsedArgs, 'ignore_packages'); + final ignoreLicense = _listNonEmpty(parsedArgs, 'ignore_license'); + final ignoreCoverage = _listNonEmpty(parsedArgs, 'ignore_coverage'); + final experiments = _listNonEmpty(parsedArgs, 'experiments'); + final coverageWeb = parsedArgs['coverage_web'] as bool; if (warnOn.toSet().intersection(failOn.toSet()).isNotEmpty) { throw ArgumentError('The checks for which warnings are displayed and the ' 'checks which lead to failure must be disjoint.'); @@ -76,3 +74,6 @@ void main(List arguments) async { GithubApi(), ).healthCheck(); } + +List _listNonEmpty(ArgResults parsedArgs, String key) => + (parsedArgs[key] as List).where((e) => e.isNotEmpty).toList(); From e948360e64c178adddc92e206ca5aebbfcec2288 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 26 Jan 2024 09:44:38 +0100 Subject: [PATCH 32/34] Match recursive --- .github/workflows/health_internal.yaml | 4 ++-- pkgs/firehose/lib/src/health/health.dart | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml index 5f97f6bf..270a0b8b 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -15,5 +15,5 @@ jobs: checks: version,changelog,license,coverage,breaking,do-not-submit fail_on: version,changelog,do-not-submit warn_on: license,coverage,breaking - ignore_license: 'pkgs/firehose/test_data/**' - ignore_coverage: 'pkgs/firehose/bin/**' + ignore_license: 'pkgs/firehose/test_data' + ignore_coverage: 'pkgs/firehose/bin' diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 779c8a21..47baf974 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -63,8 +63,12 @@ class Health { }) : ignoredPackages = ignoredPackages .map((pattern) => Glob(pattern, recursive: true)) .toList(), - ignoredFilesForCoverage = ignoredCoverage.map(Glob.new).toList(), - ignoredFilesForLicense = ignoredLicense.map(Glob.new).toList(), + ignoredFilesForCoverage = ignoredCoverage + .map((pattern) => Glob(pattern, recursive: true)) + .toList(), + ignoredFilesForLicense = ignoredLicense + .map((pattern) => Glob(pattern, recursive: true)) + .toList(), baseDirectory = base ?? Directory('../base_repo'), commentPath = comment ?? path.join( From d0a361e34fb64886bd1486980917f82e3be90765 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 29 Jan 2024 10:22:51 +0100 Subject: [PATCH 33/34] Add docs --- .github/workflows/health.yaml | 8 +++++++- pkgs/firehose/README.md | 24 +++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index 3ec0f035..ac1811d8 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -27,7 +27,13 @@ name: Health # coverage_web: false # upload_coverage: false # use-flutter: true - +# use-flutter: true +# use-flutter: true +# ignore_license: "**.g.dart" +# ignore_coverage: "**.mock.dart,**.g.dart" +# ignore_packages: "pkgs/helper_package" +# checkout_submodules: false +# experiments: "native-assets" on: workflow_call: diff --git a/pkgs/firehose/README.md b/pkgs/firehose/README.md index 51e53044..30d7abdf 100644 --- a/pkgs/firehose/README.md +++ b/pkgs/firehose/README.md @@ -160,10 +160,12 @@ This is a Github workflow to check PR health. When run from a PR, this tool will check a configurable subset of the following -* If the package versioning is correct and consistent, see `firehose` description above. -* If a changelog entry has been added. -* If all `.dart` files have a license header. +* The package versioning is correct and consistent, see `firehose` description above. +* A changelog entry has been added. +* All `.dart` files have a license header. * How the test coverage is affected by the PR. +* The package versioning takes into account any breaking changes in the PR. +* The PR contains `DO_NOT_SUBMIT` strings in the files or the description. This tool can work with either single package repos or with mono-repos (repos containing several packages). @@ -186,6 +188,22 @@ jobs: # checks: "version,changelog,license,coverage" ``` +### Options + +| Name | Type | Description | Example | +| ------------- | ------------- | ------------- | ------------- | +| checks | List of strings | What to check for in the PR health check | `"version,changelog,license,coverage,breaking,do-not-submit"` | +| fail_on | List of strings | Which checks should lead to failure | `"version,changelog,do-not-submit"` | +| warn_on | List of strings | Which checks should not fail, but only warn | `"license,coverage,breaking"` | +| upload_coverage | boolean | Whether to upload the coverage to [coveralls](https://coveralls.io/) | `true` | +| coverage_web | boolean | Whether to run `dart test -p chrome` for coverage | `false` | +| use-flutter | boolean | Whether to setup Flutter in this workflow | `false` | +| ignore_license | List of globs | | `"**.g.dart"` | +| ignore_coverage | List of globs | Which files to ignore for the license check | `"**.mock.dart,**.g.dart"` | +| ignore_packages | List of globs | Which packages to ignore | `"pkgs/helper_package"` | +| checkout_submodules | boolean | Whether to checkout submodules of git repositories | `false` | +| experiments | List of strings | Which experiments should be enabled for Dart | `"native-assets"` | + ### Workflow docs The description of the common workflow for repos using this tool can be found at From 214ab4b62494ee35c5884ca2dfeadabc2e93b2c7 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 29 Jan 2024 10:35:29 +0100 Subject: [PATCH 34/34] Add link to docs --- .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 ac1811d8..3e848b01 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -1,4 +1,4 @@ -# A CI configuration to check PR health. +# A CI configuration to check PR health. Check the docs at https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose#health. name: Health