Skip to content
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

Add $stopAllOnAnyFailure flag to \Robo\Task\Base\ParallelExec #882

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

Slamdunk
Copy link

@Slamdunk Slamdunk commented Jul 17, 2019

Overview

This pull request:

  • Fixes a bug
  • Adds a feature
  • Breaks backwards compatibility
  • Has tests that cover changes

Summary

ParallelExec is useful on CI to parallelize steps, but CI bill the time consumed, so it turns out that if one parallel process fails we can save money by stopping other parallel process too

foreach ($running as $otherRunningProcess) {
$otherRunningProcess->stop();
}
$queue = [];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't touch $running array because it feel safer to me to let it handle by the main while cycle.

@@ -172,6 +188,12 @@ public function run()
}
}
unset($running[$k]);
if ($this->stopOnFail && $process->getExitCode() !== 0) {
foreach ($running as $otherRunningProcess) {
$otherRunningProcess->stop();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I am ambivalent about this. Would it be possible to use posix_setpgid as described in the PHP bug report to fix things for those who have the posix commands?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try

@Slamdunk Slamdunk closed this Jul 25, 2019
@Slamdunk Slamdunk deleted the parallel_stop_on_fail branch July 25, 2019 06:50
@Slamdunk Slamdunk restored the parallel_stop_on_fail branch January 24, 2020 06:38
@Slamdunk Slamdunk reopened this Jan 24, 2020
Copy link
Member

@greg-1-anderson greg-1-anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on the functionality provided here; however, this does not operate the same way that "stopOnFail" does elsewhere in Robo (which is good; I don't really like stopOnFail).

Could we therefore name this something else? TerminateAllOnAnyFailure()? That's a bit wordy; perhaps something shorter would be better, if it was still clear.

In any event, documentation is needed here, especially the explanation on the need for exec to do process replacement if the posix function is not available (or if using it here does not work).

$I->amInPath(codecept_data_dir('sandbox'));
}

public function parallelProcessesGetStoppedIfStopOnFailIsSet(CliGuy $I)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice test. If posix_setpgid works, make a second test just like this one that does not use exec, and markTestSkipped if the posix commands are not available.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I just realized I've never read you change request: can you explain me what you are asking for? I don't get it 😕

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a summary of the requested changes. LMK if anything remains unclear.

Copy link
Member

@greg-1-anderson greg-1-anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a very useful enhancement.

  1. The requirement for using exec might not be clear to new users. Try using posix_setpgid and see if you can stop the other processes even if exec is not used.
  2. This feature needs documentation. The requirement for exec should be explained even if posix_setpgid works, because the code should operate even if the posix commands are not available. In this instance, users will need to employ exec
  3. Rename stopOnFail to something else, as this feature behaves differently than the global stopOnFail flag.
  4. The Codeception tests are no longer maintained in Robo. Please convert the test to phpunit (see the tests/integration directory)
  5. There should be two tests, one that uses exec (like the existing test), and another that does not. The second test should be skipped if the posix commands are not available.

@Slamdunk Slamdunk changed the base branch from 1.x to 2.x September 10, 2020 06:30
@Slamdunk
Copy link
Author

Slamdunk commented Sep 10, 2020

  1. The requirement for using exec might not be clear to new users. Try using posix_setpgid and see if you can stop the other processes even if exec is not used.
  2. This feature needs documentation. The requirement for exec should be explained even if posix_setpgid works, because the code should operate even if the posix commands are not available. In this instance, users will need to employ exec
  3. There should be two tests, one that uses exec (like the existing test), and another that does not. The second test should be skipped if the posix commands are not available.

Since v3.3.0 Symfony\Process already does the work, so exec here is no longer needed:

symfony/process@4ad0b86#diff-9a01fc0e340da4c3f1e4a16029a63977R296-R299

  1. Rename stopOnFail to something else, as this feature behaves differently than the global stopOnFail flag.
  2. The Codeception tests are no longer maintained in Robo. Please convert the test to phpunit (see the tests/integration directory)

Done. I've also rebased the PR against 2.x branch.

@Slamdunk Slamdunk changed the title Add $stopOnFail flag to \Robo\Task\Base\ParallelExec Add $stopAllOnAnyFailure flag to \Robo\Task\Base\ParallelExec Sep 10, 2020
Copy link
Member

@greg-1-anderson greg-1-anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but PRs need to go into the default branch (3.x) first. Looks like this will probably rebase against 3.x without any trouble.

@Slamdunk
Copy link
Author

Looks good, but PRs need to go into the default branch (3.x) first. Looks like this will probably rebase against 3.x without any trouble.

If you are going to backport it into 2.x after the merge, that's a branching model new to me; I've always seen the contrary: everything BC compatible into stable branches, forward ported after merge, see https://github.com/laminas/automatic-releases/blob/1.9.x/docs/branching-model.svg

If you are not going to backport it into 2.x after the merge, may I ask you why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants