From 0c31c59b0ed4ba4b9e2aa8a0a5b9816e52f300c8 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 8 Jan 2024 16:08:08 +0100 Subject: [PATCH 01/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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/39] 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 b201f0b57dfa5ab6251fbfe8626e2de5e4859fef Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:01:53 +0100 Subject: [PATCH 18/39] Revert "Add defaults" This reverts commit 2bacc71e22beaffaf7fa8b2664f492f8a570788f. --- pkgs/firehose/bin/health.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkgs/firehose/bin/health.dart b/pkgs/firehose/bin/health.dart index 776cb87f..36b3eece 100644 --- a/pkgs/firehose/bin/health.dart +++ b/pkgs/firehose/bin/health.dart @@ -17,17 +17,14 @@ 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 1bfb9020e71af27262014816afc0c9cb36cd5e98 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:06:58 +0100 Subject: [PATCH 19/39] Remove ignores --- pkgs/firehose/bin/health.dart | 18 ------- pkgs/firehose/lib/src/health/changelog.dart | 4 +- pkgs/firehose/lib/src/health/coverage.dart | 17 ++----- pkgs/firehose/lib/src/health/health.dart | 54 ++++++--------------- pkgs/firehose/lib/src/health/license.dart | 11 ++--- pkgs/firehose/test/coverage_test.dart | 2 +- pkgs/firehose/test/health_test.dart | 3 -- pkgs/firehose/test/license_test.dart | 2 +- 8 files changed, 26 insertions(+), 85 deletions(-) diff --git a/pkgs/firehose/bin/health.dart b/pkgs/firehose/bin/health.dart index 36b3eece..a28cfbca 100644 --- a/pkgs/firehose/bin/health.dart +++ b/pkgs/firehose/bin/health.dart @@ -15,18 +15,6 @@ void main(List arguments) async { allowed: checkTypes, help: 'Check PR health.', ) - ..addMultiOption( - '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', allowed: checkTypes, @@ -45,9 +33,6 @@ 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 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 ' @@ -60,8 +45,5 @@ void main(List arguments) async { failOn, coverageWeb, GithubApi(), - ignorePackages, - ignoreLicense, - ignoreCoverage, ).healthCheck(); } diff --git a/pkgs/firehose/lib/src/health/changelog.dart b/pkgs/firehose/lib/src/health/changelog.dart index a5107706..34742622 100644 --- a/pkgs/firehose/lib/src/health/changelog.dart +++ b/pkgs/firehose/lib/src/health/changelog.dart @@ -4,7 +4,6 @@ import 'dart:io'; -import 'package:glob/glob.dart'; import 'package:path/path.dart' as path; import '../github.dart'; @@ -12,11 +11,10 @@ import '../repo.dart'; Future>> packagesWithoutChangelog( GithubApi github, - List ignoredPackages, Directory directory, ) async { final repo = Repository(directory); - final packages = repo.locatePackages(ignoredPackages); + final packages = repo.locatePackages(); final files = await github.listFilesForPR(directory); diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index abc64bf4..71f42c6c 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -5,7 +5,6 @@ import 'dart:io'; -import 'package:glob/glob.dart'; import 'package:path/path.dart' as path; import '../github.dart'; @@ -15,28 +14,20 @@ import 'lcov.dart'; class Coverage { final bool coverageWeb; - final List ignoredFiles; - - final List ignoredPackages; final Directory directory; - Coverage( - this.coverageWeb, - this.ignoredFiles, - this.ignoredPackages, - this.directory, - ); + Coverage(this.coverageWeb, this.directory); Future compareCoverages( GithubApi github, Directory base) async { - var files = await github.listFilesForPR(directory, ignoredFiles); + var files = await github.listFilesForPR(directory); return compareCoveragesFor(files, base); } CoverageResult compareCoveragesFor(List files, Directory base) { var repository = Repository(directory); - var packages = repository.locatePackages(ignoredPackages); + var packages = repository.locatePackages(); print('Found packages $packages at $directory'); var filesOfInterest = files @@ -48,7 +39,7 @@ class Coverage { print('The files of interest are $filesOfInterest'); var baseRepository = Repository(base); - var basePackages = baseRepository.locatePackages(ignoredFiles); + var basePackages = baseRepository.locatePackages(); 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 2a0f1691..4131a3c2 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -9,7 +9,6 @@ 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'; @@ -48,21 +47,15 @@ class Health { final String commentPath; Health( - this.directory, - this.check, - this.warnOn, - this.failOn, - this.coverageweb, - this.github, - List ignoredPackages, - List ignoredLicense, - List ignoredCoverage, - {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'), + this.directory, + this.check, + this.warnOn, + this.failOn, + this.coverageweb, + this.github, { + Directory? base, + String? comment, + }) : baseDirectory = base ?? Directory('../base_repo'), commentPath = comment ?? path.join( directory.path, @@ -75,9 +68,6 @@ class Health { final List warnOn; final List failOn; final bool coverageweb; - final List ignoredPackages; - final List ignoredFilesForLicense; - final List ignoredFilesForCoverage; final Directory baseDirectory; Future healthCheck() async { @@ -129,8 +119,7 @@ class Health { Future validateCheck() async { //TODO: Add Flutter support for PR health checks - var results = - await Firehose(directory, false).verify(github, ignoredPackages); + var results = await Firehose(directory, false).verify(github); var markdownTable = ''' | Package | Version | Status | @@ -220,11 +209,8 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} } Future licenseCheck() async { - var files = await github.listFilesForPR(directory, ignoredFilesForLicense); - var allFilePaths = await getFilesWithoutLicenses( - directory, - ignoredFilesForLicense, - ); + var files = await github.listFilesForPR(directory); + var allFilePaths = await getFilesWithoutLicenses(directory); var groupedPaths = allFilePaths.groupListsBy((filePath) { return files.any((f) => f.filename == filePath); @@ -267,11 +253,7 @@ ${unchangedFilesPaths.isNotEmpty ? unchangedMarkdown : ''} } Future changelogCheck() async { - var filePaths = await packagesWithoutChangelog( - github, - ignoredPackages, - directory, - ); + var filePaths = await packagesWithoutChangelog(github, directory); final markdownResult = ''' | Package | Changed Files | @@ -320,12 +302,8 @@ ${filesWithDNS.map((e) => e.filename).map((e) => '|$e|').join('\n')} } Future coverageCheck() async { - var coverage = await Coverage( - coverageweb, - ignoredFilesForCoverage, - ignoredPackages, - directory, - ).compareCoverages(github, baseDirectory); + var coverage = await Coverage(coverageweb, directory) + .compareCoverages(github, baseDirectory); var markdownResult = ''' | File | Coverage | @@ -383,7 +361,7 @@ ${isWorseThanInfo ? 'This check can be disabled by tagging the PR with `skip-${r var files = filesInPR.where((element) => element.status.isRelevant); final repo = Repository(directory); return repo - .locatePackages(ignoredPackages) + .locatePackages() .where((package) => files.any((file) => path.isWithin(package.directory.path, file.pathInRepository))) .toList(); diff --git a/pkgs/firehose/lib/src/health/license.dart b/pkgs/firehose/lib/src/health/license.dart index e37a077a..b6a9c485 100644 --- a/pkgs/firehose/lib/src/health/license.dart +++ b/pkgs/firehose/lib/src/health/license.dart @@ -4,8 +4,6 @@ import 'dart:io'; -import 'package:collection/collection.dart'; -import 'package:glob/glob.dart'; import 'package:path/path.dart' as path; final license = ''' @@ -13,8 +11,7 @@ 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, List ignoredFiles) async { +Future> getFilesWithoutLicenses(Directory repositoryDir) async { var dartFiles = await repositoryDir .list(recursive: true) .where((f) => f.path.endsWith('.dart')) @@ -26,10 +23,8 @@ Future> getFilesWithoutLicenses( var fileContainsCopyright = fileContents.contains('// Copyright (c)'); if (!fileContainsCopyright) { var relativePath = path.relative(file.path, from: repositoryDir.path); - if (ignoredFiles.none((regex) => regex.matches(relativePath))) { - print(relativePath); - return relativePath; - } + print(relativePath); + return relativePath; } }) .whereType() diff --git a/pkgs/firehose/test/coverage_test.dart b/pkgs/firehose/test/coverage_test.dart index 0119c733..39d35212 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, [], [], Directory.current); + 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 index 4596d78c..a9597739 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -49,9 +49,6 @@ Future checkFor( [], false, fakeGithubApi, - [], - [], - [], base: Directory(p.join('test', 'data', 'base_test_repo')), comment: comment, ).healthCheck(); diff --git a/pkgs/firehose/test/license_test.dart b/pkgs/firehose/test/license_test.dart index fa15bbe3..f269d73c 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 854a8c80872bda752d4ddc7b3cb26ee890d07fbc Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:10:08 +0100 Subject: [PATCH 20/39] Remove ignores from yamls --- .github/workflows/health.yaml | 20 -------------------- .github/workflows/health_base.yaml | 17 +---------------- .github/workflows/health_internal.yaml | 1 - 3 files changed, 1 insertion(+), 37 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index d6656678..6ee53f0d 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -82,18 +82,6 @@ on: default: false required: false type: boolean - 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 jobs: version: @@ -106,7 +94,6 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore_packages: ${{ inputs.ignore_packages }} changelog: if: ${{ contains(inputs.checks, 'changelog') }} @@ -118,7 +105,6 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore_packages: ${{ inputs.ignore_packages }} license: if: ${{ contains(inputs.checks, 'license') }} @@ -130,8 +116,6 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore_license: ${{ inputs.ignore_license }} - ignore_packages: ${{ inputs.ignore_packages }} coverage: if: ${{ contains(inputs.checks, 'coverage') }} @@ -145,8 +129,6 @@ jobs: coverage_web: ${{ inputs.coverage_web }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore_coverage: ${{ inputs.ignore_coverage }} - ignore_packages: ${{ inputs.ignore_packages }} breaking: if: ${{ contains(inputs.checks, 'breaking') }} @@ -158,7 +140,6 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - ignore_packages: ${{ inputs.ignore_packages }} do-not-submit: if: ${{ contains(inputs.checks, 'do-not-submit') }} @@ -170,7 +151,6 @@ jobs: warn_on: ${{ inputs.warn_on }} local_debug: ${{ inputs.local_debug }} use-flutter: ${{ inputs.use-flutter }} - 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 32bf8562..3e09c802 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -49,18 +49,6 @@ on: default: false required: false type: boolean - 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 jobs: health: @@ -123,10 +111,7 @@ jobs: --check ${{ inputs.check }} \ ${{ fromJSON('{"true":"--coverage_web","false":""}')[inputs.coverage_web] }} \ --fail_on ${{ inputs.fail_on }} \ - --warn_on ${{ inputs.warn_on }} \ - --ignore_license ${{ inputs.ignore_license }} \ - --ignore_coverage ${{ inputs.ignore_coverage }} \ - --ignore_packages ${{ inputs.ignore_packages }} + --warn_on ${{ inputs.warn_on }} - 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 f99c4d9d..a6339335 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -15,4 +15,3 @@ 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' From 554e975fcc7749601e817afb980d72abef4c1b2f Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:11:45 +0100 Subject: [PATCH 21/39] Remove from firehose --- pkgs/firehose/lib/firehose.dart | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkgs/firehose/lib/firehose.dart b/pkgs/firehose/lib/firehose.dart index 3f4ce73e..f5b5c0d2 100644 --- a/pkgs/firehose/lib/firehose.dart +++ b/pkgs/firehose/lib/firehose.dart @@ -7,8 +7,6 @@ import 'dart:io'; import 'dart:math'; -import 'package:glob/glob.dart'; - import 'src/github.dart'; import 'src/pub.dart'; import 'src/repo.dart'; @@ -92,12 +90,9 @@ Saving existing comment id $existingCommentId to file ${idFile.path}'''); github.close(); } - Future verify( - GithubApi github, [ - List ignoredPackages = const [], - ]) async { + Future verify(GithubApi github) async { var repo = Repository(directory); - var packages = repo.locatePackages(ignoredPackages); + var packages = repo.locatePackages(); var pub = Pub(); From f9f760d3c1b017d024b33b53ddb8e4a160c943f2 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:12:38 +0100 Subject: [PATCH 22/39] Remove from github --- pkgs/firehose/lib/src/github.dart | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index a13781f5..3f6f0c1b 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart @@ -7,7 +7,6 @@ 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; @@ -109,10 +108,7 @@ class GithubApi { return matchingComment?.id; } - Future> listFilesForPR( - Directory directory, [ - List ignoredFiles = const [], - ]) async => + Future> listFilesForPR(Directory directory) async => await _github.pullRequests .listFiles(repoSlug!, issueNumber!) .map((prFile) => GitFile( @@ -120,8 +116,6 @@ 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. From ab836e88dbd19ad999382ff168b95556d9079a76 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:15:21 +0100 Subject: [PATCH 23/39] Remove from repo --- pkgs/firehose/lib/src/repo.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkgs/firehose/lib/src/repo.dart b/pkgs/firehose/lib/src/repo.dart index 2342ecae..8b29aa42 100644 --- a/pkgs/firehose/lib/src/repo.dart +++ b/pkgs/firehose/lib/src/repo.dart @@ -4,7 +4,6 @@ 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'; @@ -40,11 +39,9 @@ class Repository { /// `publish_to: none` key. /// /// Once we find a package, we don't look for packages in sub-directories. - List locatePackages([List ignore = const []]) { + List locatePackages() { 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; } From 2ec6d848b1f79166df6ea30fd1a3bd61f70e414c Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:21:37 +0100 Subject: [PATCH 24/39] Add changelog --- pkgs/firehose/CHANGELOG.md | 4 ++++ pkgs/firehose/pubspec.yaml | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/firehose/CHANGELOG.md b/pkgs/firehose/CHANGELOG.md index d54df277..31f7ff04 100644 --- a/pkgs/firehose/CHANGELOG.md +++ b/pkgs/firehose/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.0 + +- Make the health workflow testable with golden tests. + ## 0.5.2 - Also run health workflows on bot PRs. diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml index 05f67eb4..6c8d36cc 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.5.2 +version: 0.6.0 repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose environment: @@ -14,7 +14,6 @@ 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 From 464d11b5af89617c0ad6842c7eb0c87b556c4b9e Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:29:21 +0100 Subject: [PATCH 25/39] Move goldens --- pkgs/firehose/analysis_options.yaml | 4 ++++ pkgs/firehose/lib/src/github.dart | 1 - pkgs/firehose/test/{data => }/golden/comment_breaking.md | 0 pkgs/firehose/test/{data => }/golden/comment_changelog.md | 0 pkgs/firehose/test/{data => }/golden/comment_coverage.md | 0 pkgs/firehose/test/{data => }/golden/comment_do-not-submit.md | 0 pkgs/firehose/test/{data => }/golden/comment_license.md | 0 pkgs/firehose/test/{data => }/golden/comment_version.md | 0 8 files changed, 4 insertions(+), 1 deletion(-) rename pkgs/firehose/test/{data => }/golden/comment_breaking.md (100%) rename pkgs/firehose/test/{data => }/golden/comment_changelog.md (100%) rename pkgs/firehose/test/{data => }/golden/comment_coverage.md (100%) rename pkgs/firehose/test/{data => }/golden/comment_do-not-submit.md (100%) rename pkgs/firehose/test/{data => }/golden/comment_license.md (100%) rename pkgs/firehose/test/{data => }/golden/comment_version.md (100%) diff --git a/pkgs/firehose/analysis_options.yaml b/pkgs/firehose/analysis_options.yaml index d978f811..b1be6193 100644 --- a/pkgs/firehose/analysis_options.yaml +++ b/pkgs/firehose/analysis_options.yaml @@ -1 +1,5 @@ include: package:dart_flutter_team_lints/analysis_options.yaml + +analyzer: + exclude: + - test/data/* diff --git a/pkgs/firehose/lib/src/github.dart b/pkgs/firehose/lib/src/github.dart index 3f6f0c1b..e3e07b82 100644 --- a/pkgs/firehose/lib/src/github.dart +++ b/pkgs/firehose/lib/src/github.dart @@ -5,7 +5,6 @@ import 'dart:io'; -import 'package:collection/collection.dart'; import 'package:github/github.dart'; import 'package:http/http.dart' as http; import 'package:path/path.dart' as path; diff --git a/pkgs/firehose/test/data/golden/comment_breaking.md b/pkgs/firehose/test/golden/comment_breaking.md similarity index 100% rename from pkgs/firehose/test/data/golden/comment_breaking.md rename to pkgs/firehose/test/golden/comment_breaking.md diff --git a/pkgs/firehose/test/data/golden/comment_changelog.md b/pkgs/firehose/test/golden/comment_changelog.md similarity index 100% rename from pkgs/firehose/test/data/golden/comment_changelog.md rename to pkgs/firehose/test/golden/comment_changelog.md diff --git a/pkgs/firehose/test/data/golden/comment_coverage.md b/pkgs/firehose/test/golden/comment_coverage.md similarity index 100% rename from pkgs/firehose/test/data/golden/comment_coverage.md rename to pkgs/firehose/test/golden/comment_coverage.md diff --git a/pkgs/firehose/test/data/golden/comment_do-not-submit.md b/pkgs/firehose/test/golden/comment_do-not-submit.md similarity index 100% rename from pkgs/firehose/test/data/golden/comment_do-not-submit.md rename to pkgs/firehose/test/golden/comment_do-not-submit.md diff --git a/pkgs/firehose/test/data/golden/comment_license.md b/pkgs/firehose/test/golden/comment_license.md similarity index 100% rename from pkgs/firehose/test/data/golden/comment_license.md rename to pkgs/firehose/test/golden/comment_license.md diff --git a/pkgs/firehose/test/data/golden/comment_version.md b/pkgs/firehose/test/golden/comment_version.md similarity index 100% rename from pkgs/firehose/test/data/golden/comment_version.md rename to pkgs/firehose/test/golden/comment_version.md From dfcb177b349de896a9a37450dee79122efa76ddd Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:40:32 +0100 Subject: [PATCH 26/39] Fix glob issue --- pkgs/firehose/test/health_test.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index a9597739..cd4883ca 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -3,7 +3,6 @@ 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'; @@ -90,8 +89,7 @@ class FakeGithubApi implements GithubApi { int? get issueNumber => 1; @override - Future> listFilesForPR(Directory directory, - [List ignoredFiles = const []]) async { + Future> listFilesForPR(Directory directory) async { return files; } From 285edbdf1ba3aee9aa8c1fbff3ea61106322e335 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:47:47 +0100 Subject: [PATCH 27/39] Add test data to pubignore --- pkgs/firehose/.pubignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 pkgs/firehose/.pubignore diff --git a/pkgs/firehose/.pubignore b/pkgs/firehose/.pubignore new file mode 100644 index 00000000..14fa3340 --- /dev/null +++ b/pkgs/firehose/.pubignore @@ -0,0 +1 @@ +test/data/ \ No newline at end of file From 95f2a622ad365dc1a45de66256ae1b0195878223 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 13:50:46 +0100 Subject: [PATCH 28/39] Switch SDK version --- .../test/data/base_test_repo/pkgs/package1/pubspec.yaml | 2 +- .../test/data/base_test_repo/pkgs/package2/pubspec.yaml | 2 +- .../test/data/base_test_repo/pkgs/package3/pubspec.yaml | 2 +- pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml | 2 +- pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml | 2 +- pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) 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 index e4663470..fe566c25 100644 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 # repository: https://github.com/my_org/my_repo environment: - sdk: ^3.4.0-4.0.dev + sdk: ^3.0.0 # Add regular dependencies here. dependencies: 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 index 7a037494..4f148c60 100644 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 # repository: https://github.com/my_org/my_repo environment: - sdk: ^3.4.0-4.0.dev + sdk: ^3.0.0 # Add regular dependencies here. dependencies: 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 index e6ad38ab..2454f72c 100644 --- a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml +++ b/pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 # repository: https://github.com/my_org/my_repo environment: - sdk: ^3.4.0-4.0.dev + sdk: ^3.0.0 # Add regular dependencies here. dependencies: diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml index e4663470..fe566c25 100644 --- a/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml +++ b/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 # repository: https://github.com/my_org/my_repo environment: - sdk: ^3.4.0-4.0.dev + sdk: ^3.0.0 # Add regular dependencies here. dependencies: diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml index 7a037494..4f148c60 100644 --- a/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml +++ b/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 # repository: https://github.com/my_org/my_repo environment: - sdk: ^3.4.0-4.0.dev + sdk: ^3.0.0 # Add regular dependencies here. dependencies: diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml b/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml index e6ad38ab..2454f72c 100644 --- a/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml +++ b/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 # repository: https://github.com/my_org/my_repo environment: - sdk: ^3.4.0-4.0.dev + sdk: ^3.0.0 # Add regular dependencies here. dependencies: From e9b34652bd351bf37bc4baf2608126c86f03f7b2 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 14:08:13 +0100 Subject: [PATCH 29/39] Move stuff around --- pkgs/firehose/.pubignore | 2 +- pkgs/firehose/analysis_options.yaml | 2 +- pkgs/firehose/test/health_test.dart | 11 +++++++---- pkgs/firehose/test/license_test.dart | 8 +++++--- .../base_test_repo/pkgs/package1/.gitignore | 0 .../base_test_repo/pkgs/package1/CHANGELOG.md | 0 .../base_test_repo/pkgs/package1/README.md | 0 .../pkgs/package1/analysis_options.yaml | 0 .../base_test_repo/pkgs/package1/bin/package1.dart | 0 .../base_test_repo/pkgs/package1/lib/package1.dart | 0 .../base_test_repo/pkgs/package1/pubspec.yaml | 0 .../pkgs/package1/test/package1_test.dart | 0 .../base_test_repo/pkgs/package2/.gitignore | 0 .../base_test_repo/pkgs/package2/CHANGELOG.md | 0 .../base_test_repo/pkgs/package2/README.md | 0 .../pkgs/package2/analysis_options.yaml | 0 .../base_test_repo/pkgs/package2/bin/package2.dart | 0 .../base_test_repo/pkgs/package2/lib/package2.dart | 0 .../base_test_repo/pkgs/package2/pubspec.yaml | 0 .../pkgs/package2/test/package2_test.dart | 0 .../base_test_repo/pkgs/package3/.gitignore | 0 .../base_test_repo/pkgs/package3/CHANGELOG.md | 0 .../base_test_repo/pkgs/package3/README.md | 0 .../pkgs/package3/analysis_options.yaml | 0 .../base_test_repo/pkgs/package3/bin/package3.dart | 0 .../base_test_repo/pkgs/package3/lib/package3.dart | 0 .../base_test_repo/pkgs/package3/pubspec.yaml | 0 .../pkgs/package3/test/package3_test.dart | 0 .../{test => test_data}/golden/comment_breaking.md | 0 .../{test => test_data}/golden/comment_changelog.md | 0 .../{test => test_data}/golden/comment_coverage.md | 0 .../golden/comment_do-not-submit.md | 0 .../{test => test_data}/golden/comment_license.md | 0 .../{test => test_data}/golden/comment_version.md | 0 .../test_repo/pkgs/package1/.gitignore | 0 .../test_repo/pkgs/package1/CHANGELOG.md | 0 .../test_repo/pkgs/package1/README.md | 0 .../test_repo/pkgs/package1/analysis_options.yaml | 0 .../test_repo/pkgs/package1/bin/package1.dart | 0 .../test_repo/pkgs/package1/lib/package1.dart | 0 .../test_repo/pkgs/package1/pubspec.yaml | 0 .../test_repo/pkgs/package1/test/package1_test.dart | 0 .../test_repo/pkgs/package2/.gitignore | 0 .../test_repo/pkgs/package2/CHANGELOG.md | 0 .../test_repo/pkgs/package2/README.md | 0 .../test_repo/pkgs/package2/analysis_options.yaml | 0 .../test_repo/pkgs/package2/bin/package2.dart | 0 .../test_repo/pkgs/package2/lib/anotherLib.dart | 0 .../test_repo/pkgs/package2/lib/package2.dart | 0 .../test_repo/pkgs/package2/pubspec.yaml | 0 .../test_repo/pkgs/package2/test/package2_test.dart | 0 .../test_repo/pkgs/package3/.gitignore | 0 .../test_repo/pkgs/package3/CHANGELOG.md | 0 .../test_repo/pkgs/package3/README.md | 0 .../test_repo/pkgs/package3/analysis_options.yaml | 0 .../test_repo/pkgs/package3/bin/package3.dart | 0 .../test_repo/pkgs/package3/lib/package3.dart | 0 .../test_repo/pkgs/package3/pubspec.yaml | 0 .../test_repo/pkgs/package3/test/package3_test.dart | 0 59 files changed, 14 insertions(+), 9 deletions(-) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package1/.gitignore (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package1/CHANGELOG.md (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package1/README.md (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package1/analysis_options.yaml (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package1/bin/package1.dart (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package1/lib/package1.dart (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package1/pubspec.yaml (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package1/test/package1_test.dart (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package2/.gitignore (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package2/CHANGELOG.md (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package2/README.md (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package2/analysis_options.yaml (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package2/bin/package2.dart (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package2/lib/package2.dart (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package2/pubspec.yaml (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package2/test/package2_test.dart (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package3/.gitignore (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package3/CHANGELOG.md (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package3/README.md (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package3/analysis_options.yaml (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package3/bin/package3.dart (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package3/lib/package3.dart (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package3/pubspec.yaml (100%) rename pkgs/firehose/{test/data => test_data}/base_test_repo/pkgs/package3/test/package3_test.dart (100%) rename pkgs/firehose/{test => test_data}/golden/comment_breaking.md (100%) rename pkgs/firehose/{test => test_data}/golden/comment_changelog.md (100%) rename pkgs/firehose/{test => test_data}/golden/comment_coverage.md (100%) rename pkgs/firehose/{test => test_data}/golden/comment_do-not-submit.md (100%) rename pkgs/firehose/{test => test_data}/golden/comment_license.md (100%) rename pkgs/firehose/{test => test_data}/golden/comment_version.md (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package1/.gitignore (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package1/CHANGELOG.md (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package1/README.md (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package1/analysis_options.yaml (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package1/bin/package1.dart (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package1/lib/package1.dart (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package1/pubspec.yaml (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package1/test/package1_test.dart (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package2/.gitignore (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package2/CHANGELOG.md (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package2/README.md (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package2/analysis_options.yaml (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package2/bin/package2.dart (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package2/lib/anotherLib.dart (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package2/lib/package2.dart (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package2/pubspec.yaml (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package2/test/package2_test.dart (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package3/.gitignore (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package3/CHANGELOG.md (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package3/README.md (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package3/analysis_options.yaml (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package3/bin/package3.dart (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package3/lib/package3.dart (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package3/pubspec.yaml (100%) rename pkgs/firehose/{test/data => test_data}/test_repo/pkgs/package3/test/package3_test.dart (100%) diff --git a/pkgs/firehose/.pubignore b/pkgs/firehose/.pubignore index 14fa3340..61d5a15b 100644 --- a/pkgs/firehose/.pubignore +++ b/pkgs/firehose/.pubignore @@ -1 +1 @@ -test/data/ \ No newline at end of file +test_data/ \ No newline at end of file diff --git a/pkgs/firehose/analysis_options.yaml b/pkgs/firehose/analysis_options.yaml index b1be6193..f0283158 100644 --- a/pkgs/firehose/analysis_options.yaml +++ b/pkgs/firehose/analysis_options.yaml @@ -2,4 +2,4 @@ include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: exclude: - - test/data/* + - test_data/* diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index cd4883ca..ba6bde35 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.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 'dart:io'; import 'package:firehose/src/github.dart'; @@ -8,7 +12,7 @@ import 'package:test/test.dart'; void main() { test('test name', () async { - final directory = Directory(p.join('test', 'data', 'test_repo')); + final directory = Directory(p.join('test_data', 'test_repo')); var fakeGithubApi = FakeGithubApi(prLabels: [], files: [ GitFile( 'pkgs/package1/bin/package1.dart', @@ -23,8 +27,7 @@ void main() { ]); for (var check in checkTypes) { var comment = await checkFor(check, fakeGithubApi, directory); - var goldenFile = - File(p.join('test', 'data', 'golden', 'comment_$check.md')); + var goldenFile = File(p.join('test_data', 'golden', 'comment_$check.md')); var goldenComment = goldenFile.readAsStringSync(); if (Platform.environment.containsKey('RESET_GOLDEN')) { goldenFile.writeAsStringSync(comment); @@ -48,7 +51,7 @@ Future checkFor( [], false, fakeGithubApi, - base: Directory(p.join('test', 'data', 'base_test_repo')), + base: Directory(p.join('test_data', 'base_test_repo')), comment: comment, ).healthCheck(); return await File(comment).readAsString(); diff --git a/pkgs/firehose/test/license_test.dart b/pkgs/firehose/test/license_test.dart index f269d73c..cc08ef4e 100644 --- a/pkgs/firehose/test/license_test.dart +++ b/pkgs/firehose/test/license_test.dart @@ -9,6 +9,7 @@ import 'dart:io'; import 'package:firehose/src/health/license.dart'; import 'package:test/test.dart'; +import 'package:path/path.dart' as path; void main() { var fileWithLicense = File('test/fileWithLicense.dart'); @@ -20,9 +21,10 @@ void main() { }); test('Check for licenses', () async { - var filesWithoutLicenses = - await getFilesWithoutLicenses(Directory('test/')); - expect(filesWithoutLicenses, [fileWithoutLicense.path]); + var directory = Directory('test/'); + var filesWithoutLicenses = await getFilesWithoutLicenses(directory); + expect(filesWithoutLicenses, + [path.relative(fileWithoutLicense.path, from: directory.path)]); }); tearDown(() async { diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package1/.gitignore b/pkgs/firehose/test_data/base_test_repo/pkgs/package1/.gitignore similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package1/.gitignore rename to pkgs/firehose/test_data/base_test_repo/pkgs/package1/.gitignore 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package1/CHANGELOG.md rename to pkgs/firehose/test_data/base_test_repo/pkgs/package1/CHANGELOG.md 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package1/README.md rename to pkgs/firehose/test_data/base_test_repo/pkgs/package1/README.md 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package1/analysis_options.yaml rename to pkgs/firehose/test_data/base_test_repo/pkgs/package1/analysis_options.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package1/bin/package1.dart rename to pkgs/firehose/test_data/base_test_repo/pkgs/package1/bin/package1.dart 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package1/lib/package1.dart rename to pkgs/firehose/test_data/base_test_repo/pkgs/package1/lib/package1.dart 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package1/pubspec.yaml rename to pkgs/firehose/test_data/base_test_repo/pkgs/package1/pubspec.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package1/test/package1_test.dart rename to pkgs/firehose/test_data/base_test_repo/pkgs/package1/test/package1_test.dart diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package2/.gitignore b/pkgs/firehose/test_data/base_test_repo/pkgs/package2/.gitignore similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package2/.gitignore rename to pkgs/firehose/test_data/base_test_repo/pkgs/package2/.gitignore 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package2/CHANGELOG.md rename to pkgs/firehose/test_data/base_test_repo/pkgs/package2/CHANGELOG.md 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package2/README.md rename to pkgs/firehose/test_data/base_test_repo/pkgs/package2/README.md 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package2/analysis_options.yaml rename to pkgs/firehose/test_data/base_test_repo/pkgs/package2/analysis_options.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package2/bin/package2.dart rename to pkgs/firehose/test_data/base_test_repo/pkgs/package2/bin/package2.dart 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package2/lib/package2.dart rename to pkgs/firehose/test_data/base_test_repo/pkgs/package2/lib/package2.dart 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package2/pubspec.yaml rename to pkgs/firehose/test_data/base_test_repo/pkgs/package2/pubspec.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package2/test/package2_test.dart rename to pkgs/firehose/test_data/base_test_repo/pkgs/package2/test/package2_test.dart diff --git a/pkgs/firehose/test/data/base_test_repo/pkgs/package3/.gitignore b/pkgs/firehose/test_data/base_test_repo/pkgs/package3/.gitignore similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package3/.gitignore rename to pkgs/firehose/test_data/base_test_repo/pkgs/package3/.gitignore 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package3/CHANGELOG.md rename to pkgs/firehose/test_data/base_test_repo/pkgs/package3/CHANGELOG.md 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package3/README.md rename to pkgs/firehose/test_data/base_test_repo/pkgs/package3/README.md 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package3/analysis_options.yaml rename to pkgs/firehose/test_data/base_test_repo/pkgs/package3/analysis_options.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package3/bin/package3.dart rename to pkgs/firehose/test_data/base_test_repo/pkgs/package3/bin/package3.dart 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package3/lib/package3.dart rename to pkgs/firehose/test_data/base_test_repo/pkgs/package3/lib/package3.dart 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package3/pubspec.yaml rename to pkgs/firehose/test_data/base_test_repo/pkgs/package3/pubspec.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/base_test_repo/pkgs/package3/test/package3_test.dart rename to pkgs/firehose/test_data/base_test_repo/pkgs/package3/test/package3_test.dart diff --git a/pkgs/firehose/test/golden/comment_breaking.md b/pkgs/firehose/test_data/golden/comment_breaking.md similarity index 100% rename from pkgs/firehose/test/golden/comment_breaking.md rename to pkgs/firehose/test_data/golden/comment_breaking.md diff --git a/pkgs/firehose/test/golden/comment_changelog.md b/pkgs/firehose/test_data/golden/comment_changelog.md similarity index 100% rename from pkgs/firehose/test/golden/comment_changelog.md rename to pkgs/firehose/test_data/golden/comment_changelog.md diff --git a/pkgs/firehose/test/golden/comment_coverage.md b/pkgs/firehose/test_data/golden/comment_coverage.md similarity index 100% rename from pkgs/firehose/test/golden/comment_coverage.md rename to pkgs/firehose/test_data/golden/comment_coverage.md diff --git a/pkgs/firehose/test/golden/comment_do-not-submit.md b/pkgs/firehose/test_data/golden/comment_do-not-submit.md similarity index 100% rename from pkgs/firehose/test/golden/comment_do-not-submit.md rename to pkgs/firehose/test_data/golden/comment_do-not-submit.md diff --git a/pkgs/firehose/test/golden/comment_license.md b/pkgs/firehose/test_data/golden/comment_license.md similarity index 100% rename from pkgs/firehose/test/golden/comment_license.md rename to pkgs/firehose/test_data/golden/comment_license.md diff --git a/pkgs/firehose/test/golden/comment_version.md b/pkgs/firehose/test_data/golden/comment_version.md similarity index 100% rename from pkgs/firehose/test/golden/comment_version.md rename to pkgs/firehose/test_data/golden/comment_version.md diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/.gitignore b/pkgs/firehose/test_data/test_repo/pkgs/package1/.gitignore similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package1/.gitignore rename to pkgs/firehose/test_data/test_repo/pkgs/package1/.gitignore diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/CHANGELOG.md b/pkgs/firehose/test_data/test_repo/pkgs/package1/CHANGELOG.md similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package1/CHANGELOG.md rename to pkgs/firehose/test_data/test_repo/pkgs/package1/CHANGELOG.md diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/README.md b/pkgs/firehose/test_data/test_repo/pkgs/package1/README.md similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package1/README.md rename to pkgs/firehose/test_data/test_repo/pkgs/package1/README.md 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package1/analysis_options.yaml rename to pkgs/firehose/test_data/test_repo/pkgs/package1/analysis_options.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package1/bin/package1.dart rename to pkgs/firehose/test_data/test_repo/pkgs/package1/bin/package1.dart 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package1/lib/package1.dart rename to pkgs/firehose/test_data/test_repo/pkgs/package1/lib/package1.dart diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml b/pkgs/firehose/test_data/test_repo/pkgs/package1/pubspec.yaml similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package1/pubspec.yaml rename to pkgs/firehose/test_data/test_repo/pkgs/package1/pubspec.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package1/test/package1_test.dart rename to pkgs/firehose/test_data/test_repo/pkgs/package1/test/package1_test.dart diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/.gitignore b/pkgs/firehose/test_data/test_repo/pkgs/package2/.gitignore similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package2/.gitignore rename to pkgs/firehose/test_data/test_repo/pkgs/package2/.gitignore diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/CHANGELOG.md b/pkgs/firehose/test_data/test_repo/pkgs/package2/CHANGELOG.md similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package2/CHANGELOG.md rename to pkgs/firehose/test_data/test_repo/pkgs/package2/CHANGELOG.md diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/README.md b/pkgs/firehose/test_data/test_repo/pkgs/package2/README.md similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package2/README.md rename to pkgs/firehose/test_data/test_repo/pkgs/package2/README.md 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package2/analysis_options.yaml rename to pkgs/firehose/test_data/test_repo/pkgs/package2/analysis_options.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package2/bin/package2.dart rename to pkgs/firehose/test_data/test_repo/pkgs/package2/bin/package2.dart 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package2/lib/anotherLib.dart rename to pkgs/firehose/test_data/test_repo/pkgs/package2/lib/anotherLib.dart 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package2/lib/package2.dart rename to pkgs/firehose/test_data/test_repo/pkgs/package2/lib/package2.dart diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml b/pkgs/firehose/test_data/test_repo/pkgs/package2/pubspec.yaml similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package2/pubspec.yaml rename to pkgs/firehose/test_data/test_repo/pkgs/package2/pubspec.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package2/test/package2_test.dart rename to pkgs/firehose/test_data/test_repo/pkgs/package2/test/package2_test.dart diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/.gitignore b/pkgs/firehose/test_data/test_repo/pkgs/package3/.gitignore similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package3/.gitignore rename to pkgs/firehose/test_data/test_repo/pkgs/package3/.gitignore diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/CHANGELOG.md b/pkgs/firehose/test_data/test_repo/pkgs/package3/CHANGELOG.md similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package3/CHANGELOG.md rename to pkgs/firehose/test_data/test_repo/pkgs/package3/CHANGELOG.md diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/README.md b/pkgs/firehose/test_data/test_repo/pkgs/package3/README.md similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package3/README.md rename to pkgs/firehose/test_data/test_repo/pkgs/package3/README.md 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package3/analysis_options.yaml rename to pkgs/firehose/test_data/test_repo/pkgs/package3/analysis_options.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package3/bin/package3.dart rename to pkgs/firehose/test_data/test_repo/pkgs/package3/bin/package3.dart 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package3/lib/package3.dart rename to pkgs/firehose/test_data/test_repo/pkgs/package3/lib/package3.dart diff --git a/pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml b/pkgs/firehose/test_data/test_repo/pkgs/package3/pubspec.yaml similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package3/pubspec.yaml rename to pkgs/firehose/test_data/test_repo/pkgs/package3/pubspec.yaml 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 similarity index 100% rename from pkgs/firehose/test/data/test_repo/pkgs/package3/test/package3_test.dart rename to pkgs/firehose/test_data/test_repo/pkgs/package3/test/package3_test.dart From 27e5f2ae07e7e95b30fb54b31cb41a798a73d647 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 14:08:27 +0100 Subject: [PATCH 30/39] Fix imports --- pkgs/firehose/test/license_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/firehose/test/license_test.dart b/pkgs/firehose/test/license_test.dart index cc08ef4e..b8af03f3 100644 --- a/pkgs/firehose/test/license_test.dart +++ b/pkgs/firehose/test/license_test.dart @@ -8,8 +8,8 @@ library; import 'dart:io'; import 'package:firehose/src/health/license.dart'; -import 'package:test/test.dart'; import 'package:path/path.dart' as path; +import 'package:test/test.dart'; void main() { var fileWithLicense = File('test/fileWithLicense.dart'); From 5ccd5a587891015e8abfe87c1e929c45196e7311 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 14:08:58 +0100 Subject: [PATCH 31/39] Give test a name --- pkgs/firehose/test/health_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index ba6bde35..a9c1f904 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -11,7 +11,7 @@ import 'package:path/path.dart' as p; import 'package:test/test.dart'; void main() { - test('test name', () async { + test('Check health workflow against golden files', () async { final directory = Directory(p.join('test_data', 'test_repo')); var fakeGithubApi = FakeGithubApi(prLabels: [], files: [ GitFile( From ae6bac740b08d2cb6b82f875e7cf9f681691997f Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 14:14:36 +0100 Subject: [PATCH 32/39] Sort license files --- pkgs/firehose/lib/src/health/license.dart | 2 ++ pkgs/firehose/test_data/golden/comment_license.md | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkgs/firehose/lib/src/health/license.dart b/pkgs/firehose/lib/src/health/license.dart index b6a9c485..21796720 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 = ''' @@ -28,6 +29,7 @@ Future> getFilesWithoutLicenses(Directory repositoryDir) async { } }) .whereType() + .sorted((a, b) => a.compareTo(b)) .toList(); print(''' Done, found ${filesWithoutLicenses.length} files without license headers'''); diff --git a/pkgs/firehose/test_data/golden/comment_license.md b/pkgs/firehose/test_data/golden/comment_license.md index f24025eb..a53ef1cb 100644 --- a/pkgs/firehose/test_data/golden/comment_license.md +++ b/pkgs/firehose/test_data/golden/comment_license.md @@ -13,8 +13,8 @@ Details | Files | | :--- | -|pkgs/package2/lib/anotherLib.dart| |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). @@ -25,13 +25,13 @@ 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/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 b46ff6757b7dcd3b534cf57345d766e911f8f5a7 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 14:25:39 +0100 Subject: [PATCH 33/39] Switch debug messages --- pkgs/firehose/lib/src/health/coverage.dart | 22 +++++++++++-------- pkgs/firehose/lib/src/health/license.dart | 2 +- .../pkgs/package2/test/package2_test.dart | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index 71f42c6c..6c5c6c72 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:collection/collection.dart'; import 'package:path/path.dart' as path; import '../github.dart'; @@ -45,6 +46,7 @@ class Coverage { var changedPackages = packages .where((package) => filesOfInterest.any((file) => file.isInPackage(package))) + .sortedBy((package) => package.name) .toList(); print('The packages of interest are $changedPackages'); @@ -57,14 +59,15 @@ class Coverage { .where((element) => element.name == package.name) .firstOrNull; final oldCoverages = getCoverage(basePackage); - var filePaths = filesOfInterest + var filenames = filesOfInterest .where((file) => file.isInPackage(package)) - .map((file) => file.filename); - for (var filePath in filePaths) { - var oldCoverage = oldCoverages[filePath]; - var newCoverage = newCoverages[filePath]; - print('Compage coverage for $filePath: $oldCoverage vs $newCoverage'); - coverageResult[filePath] = Change( + .map((file) => file.filename) + .sortedBy((filename) => filename); + for (var filename in filenames) { + var oldCoverage = oldCoverages[filename]; + var newCoverage = newCoverages[filename]; + print('Compage coverage for $filename: $oldCoverage vs $newCoverage'); + coverageResult[filename] = Change( oldCoverage: oldCoverage, newCoverage: newCoverage, ); @@ -98,7 +101,7 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path workingDirectory: package.directory.path, ); if (coverageWeb) { - print('Get test coverage for web'); + print('Run tests with coverage for web'); var resultChrome = Process.runSync( 'dart', ['test', '-p', 'chrome', '--coverage=coverage'], @@ -107,7 +110,7 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path print(resultChrome.stdout); print(resultChrome.stderr); } - print('Get test coverage for vm'); + print('Run tests with coverage for vm'); var resultVm = Process.runSync( 'dart', ['test', '--coverage=coverage'], @@ -115,6 +118,7 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path ); print(resultVm.stdout); print(resultVm.stderr); + print('Compute coverage from runs'); var resultLcov = Process.runSync( 'dart', [ diff --git a/pkgs/firehose/lib/src/health/license.dart b/pkgs/firehose/lib/src/health/license.dart index 21796720..b7bec935 100644 --- a/pkgs/firehose/lib/src/health/license.dart +++ b/pkgs/firehose/lib/src/health/license.dart @@ -29,7 +29,7 @@ Future> getFilesWithoutLicenses(Directory repositoryDir) async { } }) .whereType() - .sorted((a, b) => a.compareTo(b)) + .sortedBy((fileName) => fileName) .toList(); print(''' Done, found ${filesWithoutLicenses.length} files without license headers'''); 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 cbf30f4f..cfe57f0c 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 @@ -6,7 +6,7 @@ void main() { test('calculate', () { expect(p2.calculate(), 42); }); - test('calculate', () { + test('calculate anotherlib', () { expect(anotherLib.calculateUnused(), 42); }); } From 47ea57e7872862efbfbb182c4a50517f843e4c26 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 14:34:26 +0100 Subject: [PATCH 34/39] Add debug string --- pkgs/firehose/lib/src/health/coverage.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index 6c5c6c72..eb110d2f 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -116,6 +116,7 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path ['test', '--coverage=coverage'], workingDirectory: package.directory.path, ); + print(directory.listSync(recursive: true)); print(resultVm.stdout); print(resultVm.stderr); print('Compute coverage from runs'); From 75551e9ecbf1072071ce6db44d8ec5c0c6ce896a Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 14:41:10 +0100 Subject: [PATCH 35/39] Add debug --- pkgs/firehose/lib/src/health/coverage.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index eb110d2f..c958c7b3 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -116,9 +116,8 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path ['test', '--coverage=coverage'], workingDirectory: package.directory.path, ); - print(directory.listSync(recursive: true)); - print(resultVm.stdout); - print(resultVm.stderr); + print('dart test stdout: ${resultVm.stdout}'); + print('dart test stderr: ${resultVm.stderr}'); print('Compute coverage from runs'); var resultLcov = Process.runSync( 'dart', @@ -137,8 +136,9 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path ], workingDirectory: package.directory.path, ); - print(resultLcov.stdout); - print(resultLcov.stderr); + print(directory.listSync(recursive: true)); //DO_NOT_SUBMIT + print('dart coverage stdout: ${resultLcov.stdout}'); + print('dart coverage stderr: ${resultLcov.stderr}'); return parseLCOV( path.join(package.directory.path, 'coverage/lcov.info'), relativeTo: package.repository.baseDirectory.path, From 0ef7cb351d0da0042b98e402b2798edc5464e143 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 14:59:05 +0100 Subject: [PATCH 36/39] Add activate global --- pkgs/firehose/test/health_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index a9c1f904..c892f3a6 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -25,6 +25,8 @@ void main() { directory, ), ]); + await Process.run('dart', ['pub', 'global', 'activate', 'dart_apitool']); + await Process.run('dart', ['pub', 'global', 'activate', 'coverage']); for (var check in checkTypes) { var comment = await checkFor(check, fakeGithubApi, directory); var goldenFile = File(p.join('test_data', 'golden', 'comment_$check.md')); From 5916e77bf025e5fc5d1a72c113c6083f05b9951c Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 16:38:09 +0100 Subject: [PATCH 37/39] Remove debugging --- pkgs/firehose/.pubignore | 2 +- pkgs/firehose/lib/src/health/coverage.dart | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/firehose/.pubignore b/pkgs/firehose/.pubignore index 61d5a15b..74c3f9fc 100644 --- a/pkgs/firehose/.pubignore +++ b/pkgs/firehose/.pubignore @@ -1 +1 @@ -test_data/ \ No newline at end of file +test_data/ diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index c958c7b3..caa46239 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -136,7 +136,6 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path ], workingDirectory: package.directory.path, ); - print(directory.listSync(recursive: true)); //DO_NOT_SUBMIT print('dart coverage stdout: ${resultLcov.stdout}'); print('dart coverage stderr: ${resultLcov.stderr}'); return parseLCOV( From b8e0c886e398997ef9f7a20d0b8c748463ca55d1 Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 15 Jan 2024 16:46:45 +0100 Subject: [PATCH 38/39] Fix coverage upload --- .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 3e09c802..f5b81f85 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -117,7 +117,7 @@ jobs: if: ${{ '$action_state' == 1 }} - name: Upload coverage to Coveralls - if: ${{ inputs.upload_coverage }} + if: ${{ inputs.upload_coverage && inputs.check == 'coverage' }} uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 with: format: lcov From 6bad5892bb6df3171a578b39da7ad734b3b9a422 Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 16 Jan 2024 13:27:09 +0100 Subject: [PATCH 39/39] fix erros --- pkgs/firehose/lib/src/health/health.dart | 9 ++++----- pkgs/firehose/test/health_test.dart | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 232d37b8..94ab8d03 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -281,9 +281,9 @@ 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).existsSync()) - .where( - (file) => File(file.relativePath).readAsStringSync().contains(dns)) + .where((file) => File(file.pathInRepository).existsSync()) + .where((file) => + File(file.pathInRepository).readAsStringSync().contains(dns)) .toList(); print('Found files with $dns: $filesWithDNS'); @@ -306,8 +306,7 @@ ${filesWithDNS.map((e) => e.filename).map((e) => '|$e|').join('\n')} } Future coverageCheck() async { - var coverage = - await Coverage(coverageweb, directory, experiments) + var coverage = await Coverage(coverageweb, directory, experiments) .compareCoverages(github, baseDirectory); var markdownResult = ''' diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index c892f3a6..a0e7b136 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -52,6 +52,7 @@ Future checkFor( [], [], false, + [], fakeGithubApi, base: Directory(p.join('test_data', 'base_test_repo')), comment: comment,