Skip to content

Commit 5431dde

Browse files
committed
remove after section from yaml
1 parent b5fda8f commit 5431dde

File tree

14 files changed

+7
-262
lines changed

14 files changed

+7
-262
lines changed

core/src/main/java/com/flowci/core/flow/service/YmlServiceImpl.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,6 @@ private Optional<RuntimeException> verifyPlugins(FlowNode flowNode) {
153153
plugins.add(n.getPlugin());
154154
}
155155

156-
for (StepNode after : flowNode.getAfter()) {
157-
if (after.hasPlugin()) {
158-
plugins.add(after.getPlugin());
159-
}
160-
}
161-
162156
for (String plugin : plugins) {
163157
GetPluginEvent event = eventManager.publish(new GetPluginEvent(this, plugin));
164158
if (event.hasError()) {

core/src/main/java/com/flowci/core/job/service/JobActionServiceImpl.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.flowci.core.common.git.GitClient;
66
import com.flowci.core.common.manager.SpringEventManager;
77
import com.flowci.core.common.rabbit.RabbitOperations;
8-
import com.flowci.domain.Notification;
98
import com.flowci.core.job.dao.JobDao;
109
import com.flowci.core.job.domain.ExecutedCmd;
1110
import com.flowci.core.job.domain.Job;
@@ -749,23 +748,17 @@ private void updateJobStatusAndContext(Job job, StepNode node, ExecutedCmd cmd)
749748
context.put(Variables.Job.Steps, stepService.toVarString(job, node));
750749

751750
// after status not apart of job status
752-
if (!node.isAfter()) {
753-
job.setStatusToContext(StatusHelper.convert(cmd));
754-
job.setErrorToContext(cmd.getError());
755-
}
751+
job.setStatusToContext(StatusHelper.convert(cmd));
752+
job.setErrorToContext(cmd.getError());
756753
}
757754

758755
private Optional<StepNode> findNext(NodeTree tree, Node current, boolean isSuccess) {
759756
StepNode next = tree.next(current.getPath());
757+
760758
if (Objects.isNull(next)) {
761759
return Optional.empty();
762760
}
763761

764-
// find step from after
765-
if (!isSuccess && !next.isAfter()) {
766-
return findNext(tree, next, false);
767-
}
768-
769762
return Optional.of(next);
770763
}
771764

core/src/test/java/com/flowci/core/test/job/JobServiceTest.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -393,33 +393,6 @@ public void should_handle_cmd_callback_for_failure_status_but_allow_failure() th
393393
Assert.assertEquals("hello.timeout", job.getContext().get("HELLO_TIMEOUT"));
394394
}
395395

396-
@Test
397-
public void should_job_failure_with_after() throws Exception {
398-
yml = ymlService.saveYml(flow, StringHelper.toString(load("flow-failure-with-after.yml")));
399-
Agent agent = agentService.create("hello.agent.0", null, Optional.empty());
400-
Job job = prepareJobForRunningStatus(agent);
401-
402-
NodeTree tree = ymlManager.getTree(job);
403-
StepNode firstNode = tree.next(tree.getRoot().getPath());
404-
405-
// when: set first step as failure status
406-
ExecutedCmd firstStep = stepService.get(job.getId(), firstNode.getPathAsString());
407-
firstStep.setStatus(ExecutedCmd.Status.EXCEPTION);
408-
executedCmdDao.save(firstStep);
409-
jobEventService.handleCallback(firstStep);
410-
411-
// when: set final node as success status
412-
StepNode secondNode = tree.next(firstNode.getPath());
413-
ExecutedCmd secondStep = stepService.get(job.getId(), secondNode.getPathAsString());
414-
secondStep.setStatus(ExecutedCmd.Status.SUCCESS);
415-
executedCmdDao.save(secondStep);
416-
jobEventService.handleCallback(secondStep);
417-
418-
// then: job status should be failure since final node does not count to step
419-
job = jobDao.findById(job.getId()).get();
420-
Assert.assertEquals(Status.FAILURE, job.getStatus());
421-
}
422-
423396
@Test
424397
public void should_cancel_job_if_agent_offline() throws IOException, InterruptedException {
425398
// init:

core/src/test/resources/flow-failure-with-after.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,3 @@ steps:
88
FLOW_VERSION: "echo step version"
99
script: |
1010
echo hello
11-
12-
after:
13-
- name: step2
14-
allow_failure: true
15-
script: "echo 2"

tree/src/main/java/com/flowci/tree/FlowNode.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ public class FlowNode extends Node {
3535
*/
3636
private List<Notification> notifications = new LinkedList<>();
3737

38-
/**
39-
* The final step that will be executed anyway
40-
*/
41-
private List<StepNode> after = new LinkedList<>();
42-
4338
public FlowNode(String name) {
4439
super(name);
4540
}

tree/src/main/java/com/flowci/tree/NodeTree.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ public StepNode next(NodePath path) {
6565
}
6666

6767
StepNode step = get(path);
68-
if (step.isAfter()) {
69-
return findNext(step, after);
70-
}
71-
7268
StepNode next = findNext(step, steps);
7369
if (next != null) {
7470
return next;
@@ -126,16 +122,6 @@ private void buildCacheWithIndex() {
126122
* Reset node path and parent reference and put to cache
127123
*/
128124
private void buildTree(Node root) {
129-
if (root instanceof FlowNode) {
130-
FlowNode flow = (FlowNode) root;
131-
for (StepNode step : flow.getAfter()) {
132-
step.setPath(NodePath.create(root.getPath(), step.getName()));
133-
step.setParent(root);
134-
step.setAllowFailure(true);
135-
after.add(step);
136-
}
137-
}
138-
139125
for (StepNode step : root.getChildren()) {
140126
step.setPath(NodePath.create(root.getPath(), step.getName()));
141127
step.setParent(root);

tree/src/main/java/com/flowci/tree/StepNode.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ public class StepNode extends Node {
1717

1818
public final static boolean ALLOW_FAILURE_DEFAULT = false;
1919

20-
public enum Type {
21-
Step,
22-
23-
After
24-
}
25-
2620
private DockerOption docker;
2721

2822
/**
@@ -49,8 +43,6 @@ public enum Type {
4943
*/
5044
private boolean allowFailure = ALLOW_FAILURE_DEFAULT;
5145

52-
private Type type;
53-
5446
public StepNode(String name) {
5547
super(name);
5648
}
@@ -69,9 +61,4 @@ public boolean hasBefore() {
6961
public boolean hasDocker() {
7062
return docker != null;
7163
}
72-
73-
@JsonIgnore
74-
public boolean isAfter() {
75-
return type == Type.After;
76-
}
7764
}

tree/src/main/java/com/flowci/tree/YmlParser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public class YmlParser {
4141
.put("cron", 4)
4242
.put("notifications", 5)
4343
.put("steps", 6)
44-
.put("after", 7)
4544
.build();
4645

4746
/**

tree/src/main/java/com/flowci/tree/yml/FlowYml.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.flowci.tree.yml;
1818

19-
import com.flowci.domain.Notification;
2019
import com.flowci.exception.YmlException;
2120
import com.flowci.tree.*;
2221
import lombok.Getter;
@@ -48,9 +47,6 @@ public class FlowYml extends YmlBase<FlowNode> {
4847
@NonNull
4948
private List<StepYml> steps = new LinkedList<>();
5049

51-
@NonNull
52-
private List<StepYml> after = new LinkedList<>();
53-
5450
public FlowYml(FlowNode node) {
5551
setEnvs(node.getEnvironments());
5652

@@ -73,7 +69,6 @@ public FlowNode toNode() {
7369

7470
setupNotifications(node);
7571
setupSteps(node);
76-
setupAfter(node);
7772
return node;
7873
}
7974

@@ -92,23 +87,6 @@ private void setupNotifications(FlowNode node) {
9287
}
9388
}
9489

95-
private void setupAfter(FlowNode node) {
96-
if (Objects.isNull(after) || after.isEmpty()) {
97-
return;
98-
}
99-
100-
int index = 1;
101-
Set<String> uniqueName = new HashSet<>(after.size());
102-
103-
for (StepYml child : after) {
104-
StepNode step = child.toNode(index++, StepNode.Type.After);
105-
if (!uniqueName.add(step.getName())) {
106-
throw new YmlException("Duplicate name {0} in after", step.getName());
107-
}
108-
node.getAfter().add(step);
109-
}
110-
}
111-
11290
private void setupSteps(FlowNode node) {
11391
if (Objects.isNull(steps) || steps.isEmpty()) {
11492
throw new YmlException("The 'steps' must be defined");
@@ -118,7 +96,7 @@ private void setupSteps(FlowNode node) {
11896
Set<String> uniqueName = new HashSet<>(steps.size());
11997

12098
for (StepYml child : steps) {
121-
StepNode step = child.toNode(index++, StepNode.Type.Step);
99+
StepNode step = child.toNode(index++);
122100
if (!uniqueName.add(step.getName())) {
123101
throw new YmlException("Duplicate name {0} in step", step.getName());
124102
}

tree/src/main/java/com/flowci/tree/yml/StepYml.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public class StepYml extends YmlBase<StepNode> {
4040

4141
private final static String DefaultStepPrefix = "step-";
4242

43-
private final static String DefaultAfterPrefix = "after-";
44-
4543
private DockerYml docker;
4644

4745
private String before;
@@ -62,12 +60,11 @@ public class StepYml extends YmlBase<StepNode> {
6260
setAllow_failure(node.isAllowFailure());
6361
}
6462

65-
public StepNode toNode(int index, StepNode.Type t) {
66-
StepNode node = new StepNode(buildName(index, t));
63+
public StepNode toNode(int index) {
64+
StepNode node = new StepNode(buildName(index));
6765
node.setBefore(before);
6866
node.setScript(script);
6967
node.setPlugin(plugin);
70-
node.setType(t);
7168
node.setExports(Sets.newHashSet(exports));
7269
node.setAllowFailure(allow_failure);
7370
node.setEnvironments(getVariableMap());
@@ -81,15 +78,11 @@ public StepNode toNode(int index, StepNode.Type t) {
8178
return node;
8279
}
8380

84-
private String buildName(int index, StepNode.Type t) {
81+
private String buildName(int index) {
8582
if (StringHelper.hasValue(name)) {
8683
return name;
8784
}
8885

89-
if (t == StepNode.Type.After) {
90-
return DefaultAfterPrefix + index;
91-
}
92-
9386
return DefaultStepPrefix + index;
9487
}
9588
}

0 commit comments

Comments
 (0)