Skip to content

Commit 815d4ba

Browse files
authored
[firehose] don't fail publish validation if we see the pub pre-release warning (#357)
1 parent e7bae16 commit 815d4ba

File tree

4 files changed

+41
-14
lines changed

4 files changed

+41
-14
lines changed

pkgs/firehose/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.10.4
2+
3+
- Don't fail publish validations from Pub's pre-release package warning (see
4+
https://github.com/dart-lang/pub/issues/3807).
5+
16
## 0.10.3
27

38
- Fix dart_apitool invocation in pub workspaces.

pkgs/firehose/lib/firehose.dart

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,17 @@ Saving existing comment id $existingCommentId to file ${idFile.path}''');
149149
print(result);
150150
results.addResult(result);
151151
} else {
152-
final code = await _runPublish(package, dryRun: true, force: false);
152+
const preReleaseText =
153+
'consider publishing the package as a pre-release instead';
153154

154-
final ignoreWarnings = github.prLabels.contains(_ignoreWarningsLabel);
155+
final result = await _runPublish(package, dryRun: true, force: false);
155156

156-
if (code != 0 && !ignoreWarnings) {
157-
exitCode = code;
157+
final hasPreReleaseText = result.stdout.contains(preReleaseText);
158+
final hasWarningsLabel = github.prLabels.contains(_ignoreWarningsLabel);
159+
final ignoreWarnings = hasPreReleaseText || hasWarningsLabel;
160+
161+
if (result.code != 0 && !ignoreWarnings) {
162+
exitCode = result.code;
158163
var message =
159164
'pub publish dry-run failed; add the `$_ignoreWarningsLabel` '
160165
'label to ignore';
@@ -262,13 +267,13 @@ Saving existing comment id $existingCommentId to file ${idFile.path}''');
262267
print('');
263268

264269
var result = await _runPublish(package, dryRun: false, force: true);
265-
if (result != 0) {
266-
exitCode = result;
270+
if (result.code != 0) {
271+
exitCode = result.code;
267272
}
268-
return result == 0;
273+
return result.code == 0;
269274
}
270275

271-
Future<int> _runPublish(
276+
Future<CommandResult> _runPublish(
272277
Package package, {
273278
required bool dryRun,
274279
required bool force,

pkgs/firehose/lib/src/utils.dart

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'dart:io';
1010
///
1111
/// This will also echo the command being run to stdout and indent the processes
1212
/// output slightly.
13-
Future<int> runCommand(
13+
Future<CommandResult> runCommand(
1414
String command, {
1515
List<String> args = const [],
1616
Directory? cwd,
@@ -23,20 +23,37 @@ Future<int> runCommand(
2323
workingDirectory: cwd?.path,
2424
);
2525

26+
final buffer = StringBuffer();
27+
2628
process.stdout
2729
.transform(utf8.decoder)
2830
.transform(const LineSplitter())
29-
.listen((line) => stdout
30-
..write(' ')
31-
..writeln(line));
31+
.listen((line) {
32+
buffer.writeln(line);
33+
stdout
34+
..write(' ')
35+
..writeln(line);
36+
});
3237
process.stderr
3338
.transform(utf8.decoder)
3439
.transform(const LineSplitter())
3540
.listen((line) => stderr
3641
..write(' ')
3742
..writeln(line));
3843

39-
return process.exitCode;
44+
final code = await process.exitCode;
45+
46+
return CommandResult(
47+
code: code,
48+
stdout: buffer.toString(),
49+
);
50+
}
51+
52+
class CommandResult {
53+
final int code;
54+
final String stdout;
55+
56+
CommandResult({required this.code, required this.stdout});
4057
}
4158

4259
class Tag {

pkgs/firehose/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: firehose
22
description: A tool to automate publishing of Pub packages from GitHub actions.
3-
version: 0.10.3
3+
version: 0.10.4
44
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose
55

66
environment:

0 commit comments

Comments
 (0)