Skip to content

Commit

Permalink
Pass a parameter for Flutter firehose support (#158)
Browse files Browse the repository at this point in the history
* Actually pass a parameter for Flutter firehose support
* Switch to dash use for args
  • Loading branch information
mosuem authored Sep 1, 2023
1 parent 54d1628 commit 8743a9d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
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

0 comments on commit 8743a9d

Please sign in to comment.