-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CP-3183 Create dart_dev task to allow for tasks to run con-currently #199
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome!
Just a few small nits. I can't wait to use this.
Future<TaskRunner> runTasks({List<String> tasksToRun}) async { | ||
var taskGroup = new TaskGroup(tasksToRun); | ||
await taskGroup.startTaskGroup(); | ||
taskGroup.taskGroupOutput(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming this method to output()
to reduce redundancy in the name
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified to:
this.successful = exitCode == 0;
} | ||
|
||
/// Begin each subtask and wait for completion | ||
startTaskGroup() async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add test
to the default list?
53edd93
to
e867d66
Compare
@@ -96,6 +96,7 @@ local tasks. | |||
- **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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"allows continuous integration..."
@@ -251,6 +252,7 @@ ddev examples | |||
ddev format | |||
ddev gen-test-runner | |||
ddev saucelabs | |||
ddev task-runner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
|
||
TaskProcess taskProcess; | ||
|
||
SubTask(String task) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SubTask(this.command);
|
||
class SubTask { | ||
/// Process to be executed | ||
String command; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a few questions and some nits.
@@ -96,6 +96,7 @@ local tasks. | |||
- **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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌵 The upper elements in the use a colon, the bottom two do not.
} | ||
}); | ||
|
||
await process.done; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
/// TaskGroup stderr | ||
String taskGroupStderr = ''; | ||
|
||
TaskGroup(List<String> this.subTaskCommands) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need the type here if you are referring to the class member subTaskCommands
.
|
||
class TaskGroup { | ||
/// List of the individual subtasks executed | ||
List<String> subTaskCommands = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌵 List<String> subTaskCommands = <String>[];
List<String> subTaskCommands = []; | ||
|
||
/// List of the subtasks making up the TaskGroup | ||
List<SubTask> subTasks = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌵 List<SubTask> subTasks = <SubTask>[];
} | ||
|
||
/// Begin each subtask and wait for completion | ||
start() async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌵 `void start() async {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔮 Is it good practice to include await
s in a if
statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO I don't see a problem with it ¯_(ツ)_/¯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌵 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌵 List<String> successfulTasks = <String>[];
|
||
TaskRunner task = await runTasks(tasksToRun: tasksToRun); | ||
|
||
reporter.logGroup('Tasks run: \'${tasksToRun.join('\', \'')}\'', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 So much escaping!
+1 |
<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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to default it to run the unit tests too?
+1 |
|
||
import 'package:dart_dev/src/tasks/task.dart'; | ||
|
||
Future<TaskRunner> runTasks({List<String> tasksToRun}) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This param shouldn't be optional since you're not defaulting it to anything in that scenario.
@@ -251,6 +252,7 @@ ddev examples | |||
ddev format | |||
ddev gen-test-runner | |||
ddev saucelabs | |||
ddev run-ci |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command is task-runner
@@ -262,6 +264,7 @@ pub run dart_dev examples | |||
pub run dart_dev format | |||
pub run dart_dev gen-test-runner | |||
pub run dart_dev saucelabs | |||
pub run dart_dev run-ci |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
<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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it comes all at once
List longList = [ | ||
'one', | ||
'two', | ||
'three', 'four', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
total #nit why is four not on its own line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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