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

fix: report failure when at least one of the target is failing #638

Merged
merged 15 commits into from
Apr 17, 2022

Conversation

lemeurherve
Copy link
Member

fix: report failure when at least one of the target is failing

Closes #632

Test

To test this pull request, you can run the following commands:

cp <to_package_directory>
go test

Additional Information

Tradeoff

Potential improvement

@lemeurherve lemeurherve added bug Something isn't working target Related to updatecli target labels Apr 12, 2022
Copy link
Contributor

@dduportal dduportal left a comment

Choose a reason for hiding this comment

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

LGTM but I defer to @olblak because it might break some use cases that we did not htink about.

Co-authored-by: Olivier Vernin <olivier@vernin.me>
@lemeurherve lemeurherve requested a review from olblak April 13, 2022 09:05
@olblak
Copy link
Member

olblak commented Apr 13, 2022

LGTM but I defer to @olblak because it might break some use cases that we did not htink about.

If I remember correctly, the motivation to fail early after one failing target was to save some time (api call) but I think your suggestion improves the user experience as we see immediately what target is succeeding and those failing.

@dduportal
Copy link
Contributor

Correct ! Thanks for the memory. If I'm not mistaken, it was beforr you reworked the scm to have pullrequest/scm as top level: the proposal here makes sense now (while it was hard to implement before the rework).

lemeurherve and others added 2 commits April 13, 2022 13:11
Co-authored-by: Olivier Vernin <olivier@vernin.me>
dduportal
dduportal previously approved these changes Apr 14, 2022
Copy link
Contributor

@dduportal dduportal left a comment

Choose a reason for hiding this comment

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

LGTM (under the assumption that manual testing has to be done)

@olblak
Copy link
Member

olblak commented Apr 14, 2022

LGTM (under the assumption that manual testing has to be done)

I'll do some test at the end of the day

Copy link
Member

@olblak olblak left a comment

Choose a reason for hiding this comment

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

There is something fishy/
I tested this PR using

targets:
  1:  
    kind: shell
    spec:
      command: "true"

  2:  
    kind: shell
    spec:
      command: "false"

  3:  
    kind: shell
    spec:
      command: "false"

  4:  
    kind: shell
    spec:
      command: "false"

and I got

REPORTS:


✗ TEST.YAML:
	Sources:
	Target:
		✔ [1]  (kind: shell)
		- [2]  (kind: shell)
		- [3]  (kind: shell)
		- [4]  (kind: shell)

where it stopped after one target failure

@olblak
Copy link
Member

olblak commented Apr 14, 2022

@lemeurherve I am opening a pullrequest on this one with a suggestion

Signed-off-by: Olblak <me@olblak.com>
@olblak
Copy link
Member

olblak commented Apr 14, 2022

Oops sorry I pushed directly to your branch :/, feel free to review my commit

@olblak
Copy link
Member

olblak commented Apr 14, 2022

With the manifest that I mention earlier, I get the following output

+++++++++++
+ PREPARE +
+++++++++++

Loading Pipeline "/tmp/test.yaml"

SCM repository retrieved: 0


++++++++++++
+ PIPELINE +
++++++++++++



#############
# TEST.YAML #
#############


TARGETS
========

4
-

**Dry Run enabled**

The shell 🐚 command "false" exited on error (exit code 1) with the following output:
----
----

command stderr output was:
----
----

3
-

**Dry Run enabled**

The shell 🐚 command "false" exited on error (exit code 1) with the following output:
----
----

command stderr output was:
----
----

2
-

**Dry Run enabled**

The shell 🐚 command "false" exited on error (exit code 1) with the following output:
----
----

command stderr output was:
----
----

1
-

**Dry Run enabled**

The shell 🐚 command "true" ran successfully with the following output:
----
----
No change detected

ERROR: something went wrong in target "4" : "Shell command exited on error."
ERROR: something went wrong in target "3" : "Shell command exited on error."
ERROR: something went wrong in target "2" : "Shell command exited on error."

Pipeline "TEST.YAML" failed
Skipping due to:
	"targets stage:\t\"something went wrong during target execution\""
targets stage:	"something went wrong during target execution"

=============================

REPORTS:


✗ TEST.YAML:
	Sources:
	Target:
		✔ [1]  (kind: shell)
		✗ [2]  (kind: shell)
		✗ [3]  (kind: shell)
		✗ [4]  (kind: shell)



Run Summary
===========
Pipeline(s) run:
  * Changed:	0
  * Failed:	1
  * Skipped:	0
  * Succeeded:	0
  * Total:	1
ERROR: ✗ 1 over 1 pipeline failed
ERROR: command failed

Signed-off-by: Olblak <me@olblak.com>
@lemeurherve
Copy link
Member Author

Reviewing your commits, thanks @olblak!

@lemeurherve
Copy link
Member Author

@olblak LGTM 😃

olblak
olblak previously approved these changes Apr 14, 2022
Copy link
Member

@olblak olblak left a comment

Choose a reason for hiding this comment

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

I took the opportunity to fix minor issue

  1. Always run all target no matter if an issue occur or not
  2. fix small output issue

@olblak
Copy link
Member

olblak commented Apr 14, 2022

Please note that we don't handle the case where a target depends on another target which already failed
I am wondering if it's something we want like for source

@olblak
Copy link
Member

olblak commented Apr 14, 2022

Please note that we don't handle the case where a target depends on another target which already failed
I am wondering if it's something we want like for source

I am planning to implement the missing depends on ccheck

@olblak
Copy link
Member

olblak commented Apr 14, 2022

title: Test Various target scenario

targets:
  1:  
    name: Should be succeeding
    kind: shell
    spec:
      command: "true"

  2:  
    name: Should be failling
    kind: shell
    spec:
      command: "false"

  3:  
    name: Should be failling
    kind: shell
    spec:
      command: "false"

  4:  
    name: Should be skipped
    depends_on:
      - 2 
    kind: shell
    spec:
      command: "false"

  5:  
    name: Should be succeeding
    kind: shell
    depends_on:
      - 1 
    spec:
      command: "true"

output

+++++++++++
+ PREPARE +
+++++++++++

Loading Pipeline "e2e/updatecli.d/command.yaml"

SCM repository retrieved: 0


++++++++++++
+ PIPELINE +
++++++++++++



################################
# TEST VARIOUS TARGET SCENARIO #
################################


TARGETS
========

2
-

**Dry Run enabled**

The shell 🐚 command "false" exited on error (exit code 1) with the following output:
----
----

command stderr output was:
----
----

1
-

**Dry Run enabled**

The shell 🐚 command "true" ran successfully with the following output:
----
----
No change detected

4
-
WARNING: Parent target["2"] did not succeed. Skipping execution of the target["4"]

3
-

**Dry Run enabled**

The shell 🐚 command "false" exited on error (exit code 1) with the following output:
----
----

command stderr output was:
----
----

5
-

**Dry Run enabled**

The shell 🐚 command "true" ran successfully with the following output:
----
----
No change detected

ERROR: something went wrong in target "2" : "Shell command exited on error."
ERROR: something went wrong in target "3" : "Shell command exited on error."

Pipeline "Test Various target scenario" failed
Skipping due to:
	targets stage:	"something went wrong during target execution"

=============================

REPORTS:


✗ COMMAND.YAML:
	Sources:
	Target:
		✔ [1] Should be succeeding (kind: shell)
		✗ [2] Should be failling (kind: shell)
		✗ [3] Should be failling (kind: shell)
		- [4] Should be skipped (kind: shell)
		✔ [5] Should be succeeding (kind: shell)



Run Summary
===========
Pipeline(s) run:
  * Changed:	0
  * Failed:	1
  * Skipped:	0
  * Succeeded:	0
  * Total:	1
ERROR: ✗ 1 over 1 pipeline failed
ERROR: command failed
[1]    18856 exit 1     ./bin/updatecli diff --config e2e/updatecli.d/command.yaml

olblak
olblak previously approved these changes Apr 15, 2022
Signed-off-by: Olblak <me@olblak.com>
@olblak
Copy link
Member

olblak commented Apr 15, 2022

I am waiting for a final approval before merging this PR

@olblak
Copy link
Member

olblak commented Apr 17, 2022

After some test, I didn't catch any regression

@olblak
Copy link
Member

olblak commented Apr 17, 2022

Thanks @lemeurherve

@olblak olblak merged commit bc3500a into updatecli:main Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working target Related to updatecli target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[updatecli 0.23.x] failing to open pull request + no error reported globally
4 participants