Skip to content

Allow configuration to fail when a hook execution fails, fixes #2536#2652

Merged
rfay merged 8 commits into
ddev:masterfrom
majamee:fail-on-hook-fail
Dec 28, 2020
Merged

Allow configuration to fail when a hook execution fails, fixes #2536#2652
rfay merged 8 commits into
ddev:masterfrom
majamee:fail-on-hook-fail

Conversation

@majamee

@majamee majamee commented Nov 20, 2020

Copy link
Copy Markdown
Contributor

The Problem/Issue/Bug:

#2536

How this PR Solves The Problem:

Introduction of a new option (global & local): fail-on-hook-fail

Manual Testing Instructions:

Easiest way to test is probably by using:
ddev config global --fail-on-hook-fail=true
After that, just include a pre-start hook with an exit code (!=0) for instance use the following script saved as test.sh in the config.yaml of your project like this for example:

  pre-start:
  - exec-host: bash ./test.sh

The contents of the example test.sh can be found here (place in root folder of your project)

#!/bin/bash
exit 1

After you have done all that make sure, you are using the self-build version of ddev either from my branch or from the PR, run ddev poweroff to ensure, that there are no side-effects from other versions and start your project as usual by calling ddev start

Automated Testing Overview:

make staticrequired finished without errors and without warnings.
Manual testing was successful.
Tested:

  • inclusion of new option for all projects via ddev config global --fail-on-hook-fail=true
  • inclusion of new option for specific project via adding fail_on_hook_fail: true to projects .ddev/config.yaml

Release/Deployment notes:

Nothing else should be affected, even though this was my first project using "Go" 🙂

@rfay

rfay commented Nov 20, 2020

Copy link
Copy Markdown
Member

Look at you go!

@rfay

rfay commented Nov 20, 2020

Copy link
Copy Markdown
Member

Please improve this PR description with full manual testing instructions, including example hooks, and please confirm that you've tested it manually.

I'm sure this will need a test as well. We can cross that bridge a little farther down the road.

@majamee

majamee commented Nov 20, 2020

Copy link
Copy Markdown
Contributor Author

Please improve this PR description with full manual testing instructions, including example hooks, and please confirm that you've tested it manually.

I'm sure this will need a test as well. We can cross that bridge a little farther down the road.

Done 👍

@rfay rfay changed the title Fail on hook fail Allow configuration to fail when a hook execution fails, fixes #2536 Nov 20, 2020
@rfay rfay linked an issue Nov 20, 2020 that may be closed by this pull request
@rfay rfay force-pushed the fail-on-hook-fail branch from c9f70ce to 6c4c124 Compare December 28, 2020 16:13

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work on this!

I did these things you may want to review:

  • Added test coverage for this case
  • Prohibit exec and composer tasks in pre-start. This was a fail I discovered in testing this and had nothing to do with the PR.
  • Fixed a panic where non-string values were used as the value of an exec, like exec: false. This again was a panic I discovered in testing and had nothing to do with this PR.

Would love it if you could give a look and a test and make sure you're good with it.

Thanks for the nice work on this!

@majamee

majamee commented Dec 28, 2020

Copy link
Copy Markdown
Contributor Author

@rfay I tested on 6c4c124 and everything is looking fine plus working as expected. Thank you :)

@rfay rfay merged commit 5d17f0e into ddev:master Dec 28, 2020
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.

Add config.yaml option to fail an action when hooks fail

2 participants