Skip to content

Pass a parameter for Flutter firehose support #158

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 2 commits into from
Sep 1, 2023
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
12 changes: 6 additions & 6 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ name: Publish
# with:
# sdk: beta

# When using this package to publish Flutter packages, the `use_flutter`
# When using this package to publish Flutter packages, the `use-flutter`
# parameter should be set. The `sdk` parameter is then used to specify
# the Flutter SDK.
#
# jobs:
# publish:
# uses: dart-lang/ecosystem/.github/workflows/publish.yml@main
# with:
# use_flutter: true
# use-flutter: true

on:
workflow_call:
Expand All @@ -56,7 +56,7 @@ on:
default: "stable"
required: false
type: string
use_flutter:
use-flutter:
description: >-
Whether to setup Flutter in this workflow.
default: false
Expand Down Expand Up @@ -105,17 +105,17 @@ jobs:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9

- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa
if: ${{ inputs.use_flutter }}
if: ${{ inputs.use-flutter }}
with:
channel: ${{ inputs.sdk }}

- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
if: ${{ !inputs.use_flutter }}
if: ${{ !inputs.use-flutter }}
with:
sdk: ${{ inputs.sdk }}

- name: Install firehose
run: dart pub global activate firehose

- name: Publish packages
run: dart pub global run firehose --publish
run: dart pub global run firehose --publish --use-flutter ${{ inputs.use-flutter }}
20 changes: 15 additions & 5 deletions pkgs/firehose/bin/firehose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import 'package:args/args.dart';
import 'package:firehose/firehose.dart';
import 'package:firehose/src/github.dart';

const validateOption = 'validate';
const publishOption = 'publish';
const useFlutterOption = 'use-flutter';

void main(List<String> arguments) async {
var argParser = _createArgs();
try {
Expand All @@ -18,8 +22,9 @@ void main(List<String> arguments) async {
exit(0);
}

var validate = argResults['validate'] == true;
var publish = argResults['publish'] == true;
var validate = argResults[validateOption] == true;
var publish = argResults[publishOption] == true;
var useFlutter = argResults[useFlutterOption] == true;

if (!validate && !publish) {
_usage(argParser,
Expand All @@ -35,7 +40,7 @@ void main(List<String> arguments) async {
exit(1);
}

var firehose = Firehose(Directory.current);
var firehose = Firehose(Directory.current, useFlutter);

if (validate) {
await firehose.validate();
Expand Down Expand Up @@ -68,14 +73,19 @@ ArgParser _createArgs() {
help: 'Print tool help.',
)
..addFlag(
'validate',
validateOption,
negatable: false,
help: 'Validate packages and indicate whether --publish would publish '
'anything.',
)
..addFlag(
'publish',
publishOption,
negatable: false,
help: 'Publish any changed packages.',
)
..addFlag(
useFlutterOption,
negatable: true,
help: 'Whether this is a Flutter project.',
);
}
5 changes: 3 additions & 2 deletions pkgs/firehose/lib/firehose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ const String _ignoreWarningsLabel = 'publish-ignore-warnings';

class Firehose {
final Directory directory;
final bool useFlutter;

Firehose(this.directory);
Firehose(this.directory, this.useFlutter);

/// Validate the packages in the repository.
///
Expand Down Expand Up @@ -279,7 +280,7 @@ Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automati
required bool force,
}) async {
String command;
if (package.pubspec.dependencies.containsKey('flutter')) {
if (useFlutter) {
command = 'flutter';
} else {
command = 'dart';
Expand Down
3 changes: 2 additions & 1 deletion pkgs/firehose/lib/src/health/health.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class Health {
}

Future<HealthCheckResult> validateCheck(Github github) async {
var results = await Firehose(directory).verify(github);
//TODO: Add Flutter support for PR health checks
var results = await Firehose(directory, false).verify(github);

var markdownTable = '''
| Package | Version | Status |
Expand Down