Skip to content

[firehose] don't fail publish validation if we see the pub pre-release warning #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.10.4

- Don't fail publish validations from Pub's pre-release package warning (see
https://github.com/dart-lang/pub/issues/3807).

## 0.10.3

- Fix dart_apitool invocation in pub workspaces.
Expand Down
21 changes: 13 additions & 8 deletions pkgs/firehose/lib/firehose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,17 @@ Saving existing comment id $existingCommentId to file ${idFile.path}''');
print(result);
results.addResult(result);
} else {
final code = await _runPublish(package, dryRun: true, force: false);
const preReleaseText =
'consider publishing the package as a pre-release instead';

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

if (code != 0 && !ignoreWarnings) {
exitCode = code;
final hasPreReleaseText = result.stdout.contains(preReleaseText);
final hasWarningsLabel = github.prLabels.contains(_ignoreWarningsLabel);
final ignoreWarnings = hasPreReleaseText || hasWarningsLabel;

if (result.code != 0 && !ignoreWarnings) {
exitCode = result.code;
var message =
'pub publish dry-run failed; add the `$_ignoreWarningsLabel` '
'label to ignore';
Expand Down Expand Up @@ -262,13 +267,13 @@ Saving existing comment id $existingCommentId to file ${idFile.path}''');
print('');

var result = await _runPublish(package, dryRun: false, force: true);
if (result != 0) {
exitCode = result;
if (result.code != 0) {
exitCode = result.code;
}
return result == 0;
return result.code == 0;
}

Future<int> _runPublish(
Future<CommandResult> _runPublish(
Package package, {
required bool dryRun,
required bool force,
Expand Down
27 changes: 22 additions & 5 deletions pkgs/firehose/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'dart:io';
///
/// This will also echo the command being run to stdout and indent the processes
/// output slightly.
Future<int> runCommand(
Future<CommandResult> runCommand(
String command, {
List<String> args = const [],
Directory? cwd,
Expand All @@ -23,20 +23,37 @@ Future<int> runCommand(
workingDirectory: cwd?.path,
);

final buffer = StringBuffer();

process.stdout
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((line) => stdout
..write(' ')
..writeln(line));
.listen((line) {
buffer.writeln(line);
stdout
..write(' ')
..writeln(line);
});
process.stderr
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((line) => stderr
..write(' ')
..writeln(line));

return process.exitCode;
final code = await process.exitCode;

return CommandResult(
code: code,
stdout: buffer.toString(),
);
}

class CommandResult {
final int code;
final String stdout;

CommandResult({required this.code, required this.stdout});
}

class Tag {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/firehose/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firehose
description: A tool to automate publishing of Pub packages from GitHub actions.
version: 0.10.3
version: 0.10.4
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

environment:
Expand Down