77import 'dart:io' ;
88import 'dart:math' ;
99
10+ import 'package:collection/collection.dart' ;
1011import 'package:firehose/firehose.dart' ;
1112
1213import '../github.dart' ;
@@ -34,7 +35,7 @@ class Health {
3435
3536 Health (this .directory);
3637
37- Future <void > healthCheck (List args) async {
38+ Future <void > healthCheck (List args, bool coverageweb ) async {
3839 var github = Github ();
3940
4041 // Do basic validation of our expected env var.
@@ -55,13 +56,13 @@ class Health {
5556 validateCheck,
5657 if (args.contains ('license' ) &&
5758 ! github.prLabels.contains ('skip-license-check' ))
58- ( Github _) => licenseCheck () ,
59+ licenseCheck,
5960 if (args.contains ('changelog' ) &&
6061 ! github.prLabels.contains ('skip-changelog-check' ))
6162 changelogCheck,
6263 if (args.contains ('coverage' ) &&
6364 ! github.prLabels.contains ('skip-coverage-check' ))
64- coverageCheck,
65+ ( Github github) => coverageCheck (github, coverageweb) ,
6566 ];
6667
6768 var checked =
@@ -90,25 +91,46 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati
9091 );
9192 }
9293
93- Future <HealthCheckResult > licenseCheck () async {
94- var filePaths = await getFilesWithoutLicenses (Directory .current);
94+ Future <HealthCheckResult > licenseCheck (Github github) async {
95+ var files = await Github ().listFilesForPR ();
96+ var allFilePaths = await getFilesWithoutLicenses (Directory .current);
9597
98+ var groupedPaths = allFilePaths
99+ .groupListsBy ((path) => files.any ((f) => f.relativePath == path));
100+
101+ var unchangedFilesPaths = groupedPaths[false ] ?? [];
102+ var unchangedMarkdown = '''
103+ <details>
104+ <summary>
105+ Unrelated files missing license headers
106+ </summary>
107+
108+ | Files |
109+ | :--- |
110+ ${unchangedFilesPaths .map ((e ) => '|$e |' ).join ('\n ' )}
111+ </details>
112+ ''' ;
113+
114+ var changedFilesPaths = groupedPaths[true ] ?? [];
96115 var markdownResult = '''
97116```
98117$license
99118```
100119
101120| Files |
102121| :--- |
103- ${filePaths .isNotEmpty ? filePaths .map ((e ) => '|$e |' ).join ('\n ' ) : '| _no missing headers_ |' }
122+ ${changedFilesPaths .isNotEmpty ? changedFilesPaths .map ((e ) => '|$e |' ).join ('\n ' ) : '| _no missing headers_ |' }
104123
105124All source files should start with a [license header](https://github.com/dart-lang/ecosystem/wiki/License-Header).
125+
126+ ${unchangedFilesPaths .isNotEmpty ? unchangedMarkdown : '' }
127+
106128''' ;
107129
108130 return HealthCheckResult (
109131 'license' ,
110132 _licenseBotTag,
111- filePaths .isNotEmpty ? Severity .error : Severity .success,
133+ changedFilesPaths .isNotEmpty ? Severity .error : Severity .success,
112134 markdownResult,
113135 );
114136 }
@@ -132,8 +154,11 @@ Changes to files need to be [accounted for](https://github.com/dart-lang/ecosyst
132154 );
133155 }
134156
135- Future <HealthCheckResult > coverageCheck (Github github) async {
136- var coverage = await Coverage ().compareCoverages ();
157+ Future <HealthCheckResult > coverageCheck (
158+ Github github,
159+ bool coverageWeb,
160+ ) async {
161+ var coverage = await Coverage (coverageWeb).compareCoverages ();
137162
138163 var markdownResult = '''
139164| File | Coverage |
0 commit comments