Skip to content

Commit 6484ebb

Browse files
authored
ActionInfo: add a name value that can be overwritten (#406)
Simplifies usage. No behavior change
1 parent ce1dc6e commit 6484ebb

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

mono_repo/lib/src/commands/github/action_info.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@ import 'step.dart';
33

44
enum ActionInfo implements Comparable<ActionInfo> {
55
checkout(
6+
name: 'Checkout repository',
67
repo: 'actions/checkout',
78
version: 'd0651293c4a5a52e711f25b41b05b2212f385d28', // v3
89
),
910
cache(
11+
name: 'Cache Pub hosted dependencies',
1012
repo: 'actions/cache',
1113
version: '4504faf7e9bcf8f3ed0bc863c4e1d21499ab8ef8', // v3
1214
),
1315
setupDart(
16+
name: 'Setup Dart SDK',
1417
repo: 'dart-lang/setup-dart',
1518
version: '6a218f2413a3e78e9087f638a238f6b40893203d', // v1.3
1619
),
1720
setupFlutter(
21+
name: 'Setup Flutter SDK',
1822
repo: 'subosito/flutter-action',
1923
version: '2fb73e25c9488eb544b9b14b2ce00c4c2baf789e', // v2.4.0
2024
),
2125

2226
/// See https://github.com/marketplace/actions/coveralls-github-action
2327
coveralls(
28+
name: 'Upload coverage to Coveralls',
2429
repo: 'coverallsapp/github-action',
2530
version: 'master',
2631
completionJobFactory: _coverageCompletionJob,
@@ -29,18 +34,21 @@ enum ActionInfo implements Comparable<ActionInfo> {
2934
const ActionInfo({
3035
required this.repo,
3136
required this.version,
37+
required this.name,
3238
this.completionJobFactory,
3339
});
3440

3541
final String repo;
3642
final String version;
43+
final String name;
3744
final Job Function()? completionJobFactory;
3845

3946
Step usage({
40-
required String name,
47+
String? name,
4148
String? id,
4249
Map<String, dynamic>? withContent,
4350
}) {
51+
name ??= this.name;
4452
final step = Step.uses(
4553
uses: '$repo@$version',
4654
id: id,

mono_repo/lib/src/commands/github/github_yaml.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ Job _githubJob(
393393
packageFlavor.setupStep(sdkVersion),
394394
..._beforeSteps(runCommands.whereType<_CommandEntry>()),
395395
ActionInfo.checkout.usage(
396-
name: 'Checkout repository',
397396
id: 'checkout',
398397
),
399398
for (var command in runCommands) ...command.runContent,
@@ -477,7 +476,6 @@ Step _cacheEntries(
477476
const pubCacheHosted = '~/.pub-cache/hosted';
478477

479478
return ActionInfo.cache.usage(
480-
name: 'Cache Pub hosted dependencies',
481479
withContent: {
482480
'path': pubCacheHosted,
483481
'key': restoreKeys.first,
@@ -533,13 +531,11 @@ extension on PackageFlavor {
533531
switch (this) {
534532
case PackageFlavor.dart:
535533
return ActionInfo.setupDart.usage(
536-
name: 'Setup Dart SDK',
537534
withContent: {'sdk': sdkVersion},
538535
);
539536

540537
case PackageFlavor.flutter:
541538
return ActionInfo.setupFlutter.usage(
542-
name: 'Setup Flutter SDK',
543539
withContent: {'channel': sdkVersion},
544540
);
545541
}

mono_repo/lib/src/task_type.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ class _TestWithCoverageTask extends TaskType {
144144
final countString = (_count++).toString().padLeft(2, '0');
145145
return [
146146
ActionInfo.coveralls.usage(
147-
name: 'Upload coverage to Coveralls',
148147
withContent: {
149148
// https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
150149
'github-token': r'${{ secrets.GITHUB_TOKEN }}',

0 commit comments

Comments
 (0)