Skip to content

Commit 2fc2ce6

Browse files
author
Dillon Nys
committed
Rename action to github_action
1 parent 292c59d commit 2fc2ce6

File tree

5 files changed

+49
-41
lines changed

5 files changed

+49
-41
lines changed

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -273,39 +273,41 @@ extension on CIJobEntry {
273273
for (var package in packages) {
274274
final pubStepId = '${package.replaceAll('/', '_')}_'
275275
'pub_${rootConfig.monoConfig.pubAction}';
276-
commandEntries.add(GitHubActionConfig(
277-
name: '$package; $pubCommand',
278-
run: pubCommand,
279-
id: pubStepId,
280-
// Run this regardless of the success of other steps other than the
281-
// pub step.
282-
ifCondition: "always() && steps.checkout.conclusion == 'success'",
283-
workingDirectory: package,
284-
));
276+
commandEntries.add(
277+
GitHubActionConfig(
278+
name: '$package; $pubCommand',
279+
run: pubCommand,
280+
id: pubStepId,
281+
// Run this regardless of the success of other steps other than the
282+
// pub step.
283+
ifCondition: "always() && steps.checkout.conclusion == 'success'",
284+
workingDirectory: package,
285+
),
286+
);
285287
for (var i = 0; i < commands.length; i++) {
286288
final task = job.tasks[i];
287-
var action = task.action;
289+
var githubAction = task.githubAction;
288290

289291
// If the task specifies a full action, update the job-specific
290292
// properties with the current context.
291-
if (action != null) {
292-
var workingDirectory = action.workingDirectory;
293+
if (githubAction != null) {
294+
var workingDirectory = githubAction.workingDirectory;
293295
if (workingDirectory != null) {
294296
workingDirectory = posix.normalize(
295297
posix.join(package, workingDirectory),
296298
);
297299
}
298-
var ifCondition = action.ifCondition;
300+
var ifCondition = githubAction.ifCondition;
299301
if (ifCondition != null) {
300302
ifCondition += " && steps.$pubStepId.conclusion == 'success'";
301303
}
302-
action = action.copyWith(
304+
githubAction = githubAction.copyWith(
303305
workingDirectory: workingDirectory,
304306
ifCondition: ifCondition,
305307
);
306308
}
307309
commandEntries.add(
308-
action ??
310+
githubAction ??
309311
GitHubActionConfig(
310312
name: '$package; ${task.command}',
311313
run: _commandForOs(task.command),

mono_repo/lib/src/package_config.dart

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,13 @@ class Task {
344344
'dartfmt': 'format',
345345
'dartanalyzer': 'analyze',
346346
};
347-
static const _tasks = {'format', 'analyze', 'test', 'command', 'action'};
347+
static const _tasks = {
348+
'format',
349+
'analyze',
350+
'test',
351+
'command',
352+
'github_action'
353+
};
348354
static final _allowedTaskNames = UnmodifiableSetView({
349355
..._oldToNewTaskNames.keys,
350356
..._tasks,
@@ -360,11 +366,11 @@ class Task {
360366

361367
final String command;
362368

363-
final GitHubActionConfig? action;
369+
final GitHubActionConfig? githubAction;
364370

365-
Task(this.flavor, this.name, {this.args, this.action})
366-
: command = action != null
367-
? action.command
371+
Task(this.flavor, this.name, {this.args, this.githubAction})
372+
: command = githubAction != null
373+
? githubAction.command
368374
: _commandValue(flavor, name, args).join(' ');
369375

370376
/// Parses an individual item under `stages`, which might be a `group` or an
@@ -427,18 +433,18 @@ class Task {
427433
}
428434
final taskName = _normalizeTaskName(taskNames.single);
429435

430-
if (taskName == 'action') {
431-
final actionYaml = yamlValue['action'] as Object?;
432-
if (actionYaml is! Map) {
436+
if (taskName == 'github_action') {
437+
final githubActionYaml = yamlValue['github_action'] as Object?;
438+
if (githubActionYaml is! Map) {
433439
throw CheckedFromJsonException(
434440
yamlValue,
435-
'action',
436-
'Task',
441+
'github_action',
442+
'GitHubActionConfig',
437443
'Must be a map',
438444
);
439445
}
440-
final action = GitHubActionConfig.fromJson(actionYaml);
441-
return Task(flavor, 'action', action: action);
446+
final githubAction = GitHubActionConfig.fromJson(githubActionYaml);
447+
return Task(flavor, 'github_action', githubAction: githubAction);
442448
}
443449

444450
String? args;

mono_repo/lib/src/package_config.g.dart

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mono_repo/test/generate_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ sdk:
11781178
11791179
stages:
11801180
- custom_step:
1181-
- action:
1181+
- github_action:
11821182
id: custom-scripts
11831183
run: |
11841184
./script_a
@@ -1242,7 +1242,7 @@ sdk:
12421242
12431243
stages:
12441244
- custom_step:
1245-
- action:
1245+
- github_action:
12461246
id: custom-script
12471247
if: always()
12481248
run: ./script
@@ -1276,7 +1276,7 @@ sdk:
12761276
12771277
stages:
12781278
- custom_step:
1279-
- action:
1279+
- github_action:
12801280
run: ./script
12811281
some-key: some-value
12821282
''')

mono_repo/test/mono_config_test.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ line 4, column 12: Unsupported value for "group". expected a list of tasks
210210
_expectParseThrows(
211211
monoYaml,
212212
r'''
213-
line 9, column 6: Must have one key of `format`, `analyze`, `test`, `command`, `action`.
213+
line 9, column 6: Must have one key of `format`, `analyze`, `test`, `command`, `github_action`.
214214
215215
9 │ "weird": "thing"
216216
│ ^^^^^^^
@@ -233,7 +233,7 @@ line 9, column 6: Must have one key of `format`, `analyze`, `test`, `command`, `
233233
_expectParseThrows(
234234
monoYaml,
235235
r'''
236-
line 10, column 6: Must have one and only one key of `format`, `analyze`, `test`, `command`, `action`.
236+
line 10, column 6: Must have one and only one key of `format`, `analyze`, `test`, `command`, `github_action`.
237237
238238
10 │ "command": "other thing"
239239
│ ^^^^^^^^^
@@ -415,7 +415,7 @@ stages:
415415
- test: --preset travis --total-shards 5 --shard-index 1
416416
- test #no args
417417
- group:
418-
- action:
418+
- github_action:
419419
run: npm run build
420420
uses: actions/setup-node@v3
421421
with:
@@ -623,8 +623,8 @@ List get _testConfig1expectedOutput => [
623623
'tasks': [
624624
{
625625
'flavor': 'dart',
626-
'name': 'action',
627-
'action': {
626+
'name': 'github_action',
627+
'githubAction': {
628628
'run': 'npm run build',
629629
'uses': 'actions/setup-node@v3',
630630
'with': {'node-version': '16'},
@@ -647,8 +647,8 @@ List get _testConfig1expectedOutput => [
647647
'tasks': [
648648
{
649649
'flavor': 'dart',
650-
'name': 'action',
651-
'action': {
650+
'name': 'github_action',
651+
'githubAction': {
652652
'run': 'npm run build',
653653
'uses': 'actions/setup-node@v3',
654654
'with': {'node-version': '16'},
@@ -671,8 +671,8 @@ List get _testConfig1expectedOutput => [
671671
'tasks': [
672672
{
673673
'flavor': 'dart',
674-
'name': 'action',
675-
'action': {
674+
'name': 'github_action',
675+
'githubAction': {
676676
'run': 'npm run build',
677677
'uses': 'actions/setup-node@v3',
678678
'with': {'node-version': '16'},

0 commit comments

Comments
 (0)