Skip to content

Instantly share code, notes, and snippets.

@dibyom
Last active January 29, 2020 17:36
Show Gist options
  • Save dibyom/92dfd6ea20f13f5c769a21389df53977 to your computer and use it in GitHub Desktop.
Save dibyom/92dfd6ea20f13f5c769a21389df53977 to your computer and use it in GitHub Desktop.
----
# 1. change execution graph i.e. onSuccess do something onFailure do something else:
- name: task1
taskRef: { name: "my-task" }
- name: runIfTask1Fails
runAfter: ["task1"]
runOn: ["failure"]
- name: runIfTask1Succeeds
runAfter: task1
runOn: ["success"]
---
# 1. change execution graph i.e. onSuccess do something onFailure do something else:
- name: task1
conditions:
conditionRef: "condition-that-sometime-fails"
taskRef: { name: "my-task" }
- name: runIfTask1Fails
runAfter: task1
runOn: ["failure"]
- name: runIfTask1Succeeds
runAfter: task1
runOn: ["success"]
- name: runIfTask1IsSkipped
runAfter: task1
runOn: ["skip"]
---
# shorthand for "success", "failure", "skip"
- name: integration-tests
- name: cleanup
runAfter: ["integration-tests"]
runOn: ["always"] # can also be runOn: ["success", "failure"]
---
# multiple tasks - e.g. results for sharded tests
- name: integration-tests-1
- name: integration-tests-2
- name: publish-test-results
runAfter: ["integration-tests-1", "integration-tests-2"]
runOn: ["always"] # can also be runOn: ["success", "failure"]
---
# multiple tasks - combination of success or skip
- name: conditional-task-1
- name: conditional-task-2
- name: task-3
runAfter: ["conditional-task-1", "conditional-task-2"]
runOn: ["success", "skip"] # task-3 is run if 1 and 2 are success but is not run if either of them is failure
---
# always do something - publish results, task level updates, cleanup etc.
- name: task1
- name: task2
runAfter: task1
runOn: ["always"]
--
# I only want this task to run if some complex conditions are true
- name: task1
- name: task2
- name: task-3
conditions:
conditionRef: "my-complex-condition" # e.g. if task1 fails but task2 does not. or if task1, task2 succeed and the moon is blue
runAfter: ["task-1", "task-2"]
runOn: ["always"]
@pritidesai
Copy link

Yeah, the question is around what is the state of to task-2 if task-1 fails? It has a runOn: ["success"]. So, it is not run. Does it mean its state is skip? I guess another way of putting the question would be -- should tasks that are not run due to a condition failure as well as tasks that are not run due to other reasons (e.g. a parent's condition failed or a parent task outright failed) have the same skip state or is it worth differentiating between them?

I think such tasks should be classified as having "skip" state and dont see any reason to differentiate them. When a task is not run due to condition failure should be marked as skipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment