CP-3183 Create dart_dev task to allow for tasks to run con-currently#199
CP-3183 Create dart_dev task to allow for tasks to run con-currently#199maxwellpeterson-wf merged 7 commits intomasterfrom
Conversation
maxwellpeterson-wf
left a comment
There was a problem hiding this comment.
This looks awesome!
Just a few small nits. I can't wait to use this.
lib/src/tasks/task_runner/api.dart
Outdated
| Future<TaskRunner> runTasks({List<String> tasksToRun}) async { | ||
| var taskGroup = new TaskGroup(tasksToRun); | ||
| await taskGroup.startTaskGroup(); | ||
| taskGroup.taskGroupOutput(); |
There was a problem hiding this comment.
Consider renaming this method to output() to reduce redundancy in the name
lib/src/tasks/task_runner/api.dart
Outdated
| bool successful; | ||
|
|
||
| TaskRunner(int exitCode, String this.stdout, String this.stderr) { | ||
| exitCode == 0 ? this.successful = true : this.successful = false; |
There was a problem hiding this comment.
This can be simplified to:
this.successful = exitCode == 0;
lib/src/tasks/task_runner/api.dart
Outdated
| } | ||
|
|
||
| /// Begin each subtask and wait for completion | ||
| startTaskGroup() async { |
There was a problem hiding this comment.
Consider renaming this method to start
|
|
||
| const List<String> defaultTasks = const [ | ||
| 'pub run dart_dev format --check', | ||
| 'pub run dart_dev analyze' |
There was a problem hiding this comment.
Should we add test to the default list?
53edd93 to
e867d66
Compare
README.md
Outdated
| - **Applying a License to Source Files:** copies a LICENSE file to all applicable files. | ||
| - **Generate a test runner file:** that allows for faster test execution. | ||
| - **Running dart unit tests on Sauce Labs** compiles dart unit tests that can be run in the browser and executes them on various platforms using Sauce Labs. | ||
| - **Running concurrent dart commands** allows for continuous integration systems to run concurrently rather then serially. |
There was a problem hiding this comment.
"allows continuous integration..."
| ddev format | ||
| ddev gen-test-runner | ||
| ddev saucelabs | ||
| ddev task-runner |
There was a problem hiding this comment.
#nit the other task names are imperative, "format", "test". Obviously there are exceptions ("saucelabs"). I prefer the former. Could we change the name to "run-task" or "run-async" or something?
There was a problem hiding this comment.
Given the description above it might actually be nice to name the command something to do with CI. Liked run-ci or something, to make it clear that this isn't meant to be used interactively.
There was a problem hiding this comment.
I think I could go either way on this update. I'll let the other reviewers weigh in since it could theoretically be used outside of CI (even though I agree that is the most common use case)
lib/src/tasks/task_runner/api.dart
Outdated
|
|
||
| TaskProcess taskProcess; | ||
|
|
||
| SubTask(String task) { |
There was a problem hiding this comment.
SubTask(this.command);
lib/src/tasks/task_runner/api.dart
Outdated
|
|
||
| class SubTask { | ||
| /// Process to be executed | ||
| String command; |
There was a problem hiding this comment.
I think you can mark this final.
Current coverage is 23.56% (diff: 100%)@@ master #199 diff @@
==========================================
Files 7 7
Lines 157 157
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 37 37
Misses 120 120
Partials 0 0
|
|
+1 |
bencampbell-wf
left a comment
There was a problem hiding this comment.
I had a few questions and some nits.
README.md
Outdated
| - **Applying a License to Source Files:** copies a LICENSE file to all applicable files. | ||
| - **Generate a test runner file:** that allows for faster test execution. | ||
| - **Running dart unit tests on Sauce Labs** compiles dart unit tests that can be run in the browser and executes them on various platforms using Sauce Labs. | ||
| - **Running concurrent dart commands** allows continuous integration systems to run concurrently rather then serially. |
There was a problem hiding this comment.
🌵 The upper elements in the use a colon, the bottom two do not.
| } | ||
| }); | ||
|
|
||
| await process.done; |
There was a problem hiding this comment.
❓ Can you explain the necessity of this line? This appears to the be only consumer of the final Future value on TaskRunner Class .
There was a problem hiding this comment.
that is waiting for the TaskProcess that is checking for the task that is executing the task runner https://github.com/Workiva/dart_dev/pull/199/files#diff-f47564d08708b67413d675e327f15302R34
lib/src/tasks/task_runner/api.dart
Outdated
| /// TaskGroup stderr | ||
| String taskGroupStderr = ''; | ||
|
|
||
| TaskGroup(List<String> this.subTaskCommands) { |
There was a problem hiding this comment.
I don't think you need the type here if you are referring to the class member subTaskCommands.
lib/src/tasks/task_runner/api.dart
Outdated
|
|
||
| class TaskGroup { | ||
| /// List of the individual subtasks executed | ||
| List<String> subTaskCommands = []; |
There was a problem hiding this comment.
🌵 List<String> subTaskCommands = <String>[];
lib/src/tasks/task_runner/api.dart
Outdated
| List<String> subTaskCommands = []; | ||
|
|
||
| /// List of the subtasks making up the TaskGroup | ||
| List<SubTask> subTasks = []; |
There was a problem hiding this comment.
🌵 List<SubTask> subTasks = <SubTask>[];
lib/src/tasks/task_runner/api.dart
Outdated
| } | ||
|
|
||
| /// Begin each subtask and wait for completion | ||
| start() async { |
There was a problem hiding this comment.
🌵 `void start() async {
There was a problem hiding this comment.
Future start() async ;)
| /// Determine if subtasks completed successfully | ||
| Future<int> checkExitCodes() async { | ||
| for (SubTask task in subTasks) { | ||
| if (await task.taskProcess.exitCode != 0) { |
There was a problem hiding this comment.
🔮 Is it good practice to include awaits in a if statement?
There was a problem hiding this comment.
IMO I don't see a problem with it ¯_(ツ)_/¯
There was a problem hiding this comment.
I've always kind of avoided the practice and rarely see it done elsewhere. Its no biggie, I thought I would just ask.
| var args = ['run', 'dart_dev', 'task-runner']; | ||
| TaskProcess process = | ||
| new TaskProcess('pub', args, workingDirectory: projectPath); | ||
| List<String> failedTasks = []; |
There was a problem hiding this comment.
🌵 List<String> failedTasks = <String>[];
| TaskProcess process = | ||
| new TaskProcess('pub', args, workingDirectory: projectPath); | ||
| List<String> failedTasks = []; | ||
| List<String> successfulTasks = []; |
There was a problem hiding this comment.
🌵 List<String> successfulTasks = <String>[];
|
|
||
| TaskRunner task = await runTasks(tasksToRun: tasksToRun); | ||
|
|
||
| reporter.logGroup('Tasks run: \'${tasksToRun.join('\', \'')}\'', |
There was a problem hiding this comment.
😄 So much escaping!
|
+1 |
README.md
Outdated
| <tr> | ||
| <td><code>tasksToRun</code></td> | ||
| <td><code>List<String></code></td> | ||
| <td><code>['pub run dart_dev format --check','pub run dart_dev analyze']</code></td> |
There was a problem hiding this comment.
Any reason not to default it to run the unit tests too?
|
+1 |
lib/src/tasks/task_runner/api.dart
Outdated
|
|
||
| import 'package:dart_dev/src/tasks/task.dart'; | ||
|
|
||
| Future<TaskRunner> runTasks({List<String> tasksToRun}) async { |
There was a problem hiding this comment.
This param shouldn't be optional since you're not defaulting it to anything in that scenario.
README.md
Outdated
| ddev format | ||
| ddev gen-test-runner | ||
| ddev saucelabs | ||
| ddev run-ci |
There was a problem hiding this comment.
The command is task-runner
README.md
Outdated
| pub run dart_dev format | ||
| pub run dart_dev gen-test-runner | ||
| pub run dart_dev saucelabs | ||
| pub run dart_dev run-ci |
| <tr> | ||
| <td><code>tasksToRun</code></td> | ||
| <td><code>List<String></code></td> | ||
| <td><code>['pub run dart_dev format --check','pub run dart_dev analyze','pub run dart_dev test']</code></td> |
There was a problem hiding this comment.
you might want to include examples of running other things besides dart_dev (if it indeed supports that, which it looks like it does)
| final String command; | ||
|
|
||
| /// A string consisting of all the subtask's output | ||
| String taskOutput = ''; |
There was a problem hiding this comment.
does buffering the output in a string mean we can't display output from subtasks as it happens but instead all at once once it succeeds or fails? No change requested here, just wondering.
There was a problem hiding this comment.
yeah, it comes all at once
| List longList = [ | ||
| 'one', | ||
| 'two', | ||
| 'three', 'four', |
There was a problem hiding this comment.
total #nit why is four not on its own line?
There was a problem hiding this comment.
this is to cause the task to fail to verify that a failed task ran fails the parent task
|
+1 with a question and an optional nit. FWIW I'm ok with the name task-runner. |
|
+1 |
|
+1 |
1 similar comment
|
+1 |
|
+10
|
|
QA +1
Merging into master. |
Issue
Changes
Source:
Tests:
Areas of Regression
Testing
Code Review
@Workiva/web-platform-pp