Skip to content

Commit 5576a85

Browse files
authored
Support use-flutter option in groundskeeper workflow (dart-lang#444)
1 parent 16dca7a commit 5576a85

3 files changed

Lines changed: 40 additions & 14 deletions

File tree

‎.github/workflows/groundskeeper.yml‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ on:
55
workflow_call:
66
inputs:
77
sdk:
8-
description: 'Dart SDK version'
8+
description: 'Dart SDK version or Flutter channel'
99
required: false
1010
type: string
1111
default: 'dev'
12+
use-flutter:
13+
description: 'Whether to use Flutter for this package'
14+
required: false
15+
type: boolean
16+
default: false
1217
directory:
1318
description: 'The directory to tidy'
1419
required: false
@@ -63,19 +68,30 @@ jobs:
6368
with:
6469
client-id: ${{ vars.ECOSYSTEM_BOT_CLIENT_ID }}
6570
private-key: ${{ secrets.ECOSYSTEM_BOT_PRIVATE_KEY }}
71+
permission-contents: write
72+
permission-pull-requests: write
6673

6774
- name: Checkout caller repo
6875
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
6976
with:
7077
token: ${{ steps.generate-token.outputs.token }}
78+
persist-credentials: false
7179

7280
- name: Checkout ecosystem (for tidy script)
7381
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
7482
with:
7583
repository: dart-lang/ecosystem
7684
path: .github/ecosystem-helper
85+
persist-credentials: false
86+
87+
- uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2
88+
if: ${{ inputs.use-flutter }}
89+
with:
90+
channel: ${{ inputs.sdk == 'dev' && 'master' || inputs.sdk }}
91+
cache: true
7792

7893
- uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260
94+
if: ${{ !inputs.use-flutter }}
7995
with:
8096
sdk: ${{ inputs.sdk }}
8197

@@ -85,10 +101,15 @@ jobs:
85101

86102
- name: Run Tidy Script
87103
working-directory: ${{ inputs.directory }}
104+
env:
105+
RUN_FORMAT: ${{ inputs.run-format }}
106+
RUN_FIX: ${{ inputs.run-fix }}
107+
USE_FLUTTER: ${{ inputs.use-flutter }}
88108
run: |
89109
dart $GITHUB_WORKSPACE/.github/ecosystem-helper/pkgs/firehose/bin/groundskeeper.dart \
90-
--format=${{ inputs.run-format }} \
91-
--fix=${{ inputs.run-fix }}
110+
--format="$RUN_FORMAT" \
111+
--fix="$RUN_FIX" \
112+
--use-flutter="$USE_FLUTTER"
92113
93114
- name: Check for changes
94115
id: check_changes
@@ -103,9 +124,12 @@ jobs:
103124
- name: Update changelog
104125
if: ${{ inputs.update-changelog && steps.check_changes.outputs.changed == 'true' }}
105126
working-directory: .github/ecosystem-helper/pkgs/repo_manage
127+
env:
128+
DIRECTORY: ${{ inputs.directory }}
129+
CHANGELOG_MESSAGE: ${{ inputs.changelog-message }}
106130
run: |
107131
dart pub get
108-
dart run bin/report.dart changelog --changelog "../../../../${{ inputs.directory }}/CHANGELOG.md" "${{ inputs.changelog-message }}"
132+
dart run bin/report.dart changelog --changelog "../../../../$DIRECTORY/CHANGELOG.md" "$CHANGELOG_MESSAGE"
109133
110134
- name: Clean up helper
111135
run: rm -rf .github/ecosystem-helper

‎pkgs/firehose/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 0.13.2-wip
22

3+
- Support `use-flutter` option in `groundskeeper` workflow to allow tidying Flutter packages.
34
- Log full `dart_apitool` failure output to the workflow log instead of dumping
45
multi-line stack traces into the PR health comment Markdown table.
56
- Document Zizmor compatibility and ignore syntax for `post_summaries.yaml`.

‎pkgs/firehose/bin/groundskeeper.dart‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,30 @@
44

55
import 'dart:io';
66
import 'package:args/args.dart';
7-
import 'package:firehose/firehose.dart';
87
import 'package:path/path.dart' as path;
98

109
void main(List<String> args) async {
1110
final parser = ArgParser()
1211
..addOption('format', defaultsTo: 'true', allowed: ['true', 'false'])
13-
..addOption('fix', defaultsTo: 'true', allowed: ['true', 'false']);
12+
..addOption('fix', defaultsTo: 'true', allowed: ['true', 'false'])
13+
..addOption(
14+
'use-flutter',
15+
defaultsTo: 'false',
16+
allowed: ['true', 'false'],
17+
);
1418

1519
final argResults = parser.parse(args);
1620

1721
final targetDirectory = Directory.current;
1822
final pkgPath = targetDirectory.path;
1923
final runFormat = argResults['format'] != 'false';
2024
final runFix = argResults['fix'] != 'false';
25+
final useFlutter = argResults['use-flutter'] == 'true';
2126

2227
print('Target Directory: ${targetDirectory.absolute.path}');
2328
print('Run format: $runFormat');
2429
print('Run fix: $runFix');
30+
print('Use Flutter: $useFlutter');
2531

2632
final pubspecFile = File(path.join(targetDirectory.path, 'pubspec.yaml'));
2733
final isPackage = pubspecFile.existsSync();
@@ -33,15 +39,10 @@ Error: Run fix is enabled, but no pubspec.yaml found in ${targetDirectory.path}'
3339
}
3440

3541
if (isPackage) {
36-
final repo = Repository(targetDirectory);
37-
final pkg = Package(targetDirectory, repo);
38-
39-
// Detect if it is a Flutter package
40-
final isFlutter = pkg.pubspec.dependencies.containsKey('flutter') ||
41-
pkg.pubspec.devDependencies.containsKey('flutter');
42-
final tool = isFlutter ? 'flutter' : 'dart';
42+
final tool = useFlutter ? 'flutter' : 'dart';
4343

44-
print('Tidying package in $pkgPath (${isFlutter ? 'Flutter' : 'Dart'})...');
44+
print(
45+
'Tidying package in $pkgPath (${useFlutter ? 'Flutter' : 'Dart'})...');
4546

4647
print(' Running $tool pub get...');
4748
final pubGetResult =

0 commit comments

Comments
 (0)