Skip to content

Commit e67425d

Browse files
committed
feat: [CI-4540]: Added step group support in CI
1 parent 34a7043 commit e67425d

26 files changed

Lines changed: 1103 additions & 97 deletions

File tree

125-cd-nextgen/src/test/resources/schema/DeploymentStage/all.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6946,6 +6946,7 @@
69466946
"type": "object",
69476947
"required": [
69486948
"identifier",
6949+
"name",
69496950
"steps"
69506951
],
69516952
"properties": {

310-ci-manager/src/main/java/io/harness/app/impl/CIYamlSchemaServiceImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ private void removeUnwantedNodes(JsonNode definitions) {
208208
while (elements.hasNext()) {
209209
JsonNode jsonNode = elements.next();
210210
yamlSchemaGenerator.removeUnwantedNodes(jsonNode, YAMLFieldNameConstants.ROLLBACK_STEPS);
211-
yamlSchemaGenerator.removeUnwantedNodes(jsonNode, YAMLFieldNameConstants.STEP_GROUP);
212211
}
213212
}
214213
}

320-ci-execution/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ test_deps = [
424424
"@maven//:org_assertj_assertj_core",
425425
"@maven//:org_mockito_mockito_core",
426426
"@maven//:org_mockito_mockito_inline",
427+
"@maven//:org_powermock_powermock_reflect",
427428
"@maven//:org_mongodb_morphia_morphia",
428429
]
429430

320-ci-execution/src/main/java/io/harness/ci/integrationstage/IntegrationStageUtils.java

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
import io.harness.plancreator.stages.stage.StageElementConfig;
8383
import io.harness.plancreator.steps.ParallelStepElementConfig;
8484
import io.harness.plancreator.steps.StepElementConfig;
85+
import io.harness.plancreator.steps.StepGroupElementConfig;
8586
import io.harness.pms.contracts.plan.ExecutionTriggerInfo;
8687
import io.harness.pms.contracts.plan.PlanCreationContextValue;
8788
import io.harness.pms.contracts.plan.TriggerType;
@@ -136,6 +137,14 @@ public StepElementConfig getStepElementConfig(ExecutionWrapperConfig executionWr
136137
}
137138
}
138139

140+
public StepGroupElementConfig getStepGroupElementConfig(ExecutionWrapperConfig executionWrapperConfig) {
141+
try {
142+
return YamlUtils.read(executionWrapperConfig.getStepGroup().toString(), StepGroupElementConfig.class);
143+
} catch (Exception ex) {
144+
throw new CIStageExecutionException("Failed to deserialize ExecutionWrapperConfig step node", ex);
145+
}
146+
}
147+
139148
public CodeBase getCiCodeBase(YamlNode ciCodeBase) {
140149
try {
141150
return YamlUtils.read(ciCodeBase.toString(), CodeBase.class);
@@ -388,12 +397,16 @@ public static List<StepElementConfig> getAllSteps(List<ExecutionWrapperConfig> e
388397
continue;
389398
}
390399

391-
if (executionWrapper.getStep() != null) {
400+
if (executionWrapper.getStep() != null && !executionWrapper.getStep().isNull()) {
392401
stepElementConfigs.add(getStepElementConfig(executionWrapper));
393-
} else if (executionWrapper.getParallel() != null) {
402+
} else if (executionWrapper.getParallel() != null && !executionWrapper.getParallel().isNull()) {
394403
ParallelStepElementConfig parallelStepElementConfig = getParallelStepElementConfig(executionWrapper);
395404
List<StepElementConfig> fromParallel = getAllSteps(parallelStepElementConfig.getSections());
396405
stepElementConfigs.addAll(fromParallel);
406+
} else if (executionWrapper.getStepGroup() != null && !executionWrapper.getStepGroup().isNull()) {
407+
StepGroupElementConfig stepGroupElementConfig = getStepGroupElementConfig(executionWrapper);
408+
List<StepElementConfig> fromStepGroup = getAllSteps(stepGroupElementConfig.getSteps());
409+
stepElementConfigs.addAll(fromStepGroup);
397410
}
398411
}
399412
return stepElementConfigs;
@@ -546,9 +559,9 @@ public OSType getK8OS(Infrastructure infrastructure) {
546559
return resolveOSType(k8sDirectInfraYaml.getSpec().getOs());
547560
}
548561

549-
public List<String> getStageConnectorRefs(IntegrationStageConfig integrationStageConfig) {
562+
public ArrayList<String> populateConnectorIdentifiers(List<ExecutionWrapperConfig> wrappers) {
550563
ArrayList<String> connectorIdentifiers = new ArrayList<>();
551-
for (ExecutionWrapperConfig executionWrapper : integrationStageConfig.getExecution().getSteps()) {
564+
for (ExecutionWrapperConfig executionWrapper : wrappers) {
552565
if (executionWrapper.getStep() != null && !executionWrapper.getStep().isNull()) {
553566
StepElementConfig stepElementConfig = IntegrationStageUtils.getStepElementConfig(executionWrapper);
554567
String identifier = getConnectorIdentifier(stepElementConfig);
@@ -559,20 +572,30 @@ public List<String> getStageConnectorRefs(IntegrationStageConfig integrationStag
559572
ParallelStepElementConfig parallelStepElementConfig =
560573
IntegrationStageUtils.getParallelStepElementConfig(executionWrapper);
561574
if (isNotEmpty(parallelStepElementConfig.getSections())) {
562-
for (ExecutionWrapperConfig executionWrapperInParallel : parallelStepElementConfig.getSections()) {
563-
if (executionWrapperInParallel.getStep() == null || executionWrapperInParallel.getStep().isNull()) {
564-
continue;
565-
}
566-
StepElementConfig stepElementConfig =
567-
IntegrationStageUtils.getStepElementConfig(executionWrapperInParallel);
568-
String identifier = getConnectorIdentifier(stepElementConfig);
569-
if (identifier != null) {
570-
connectorIdentifiers.add(identifier);
571-
}
575+
ArrayList<String> connectorIdentifiersForParallel =
576+
populateConnectorIdentifiers(parallelStepElementConfig.getSections());
577+
if (connectorIdentifiersForParallel != null && connectorIdentifiersForParallel.size() > 0) {
578+
connectorIdentifiers.addAll(connectorIdentifiersForParallel);
579+
}
580+
}
581+
} else {
582+
StepGroupElementConfig stepGroupElementConfig =
583+
IntegrationStageUtils.getStepGroupElementConfig(executionWrapper);
584+
if (isNotEmpty(stepGroupElementConfig.getSteps())) {
585+
ArrayList<String> connectorIdentifiersForStepGroup =
586+
populateConnectorIdentifiers(stepGroupElementConfig.getSteps());
587+
if (connectorIdentifiersForStepGroup != null && connectorIdentifiersForStepGroup.size() > 0) {
588+
connectorIdentifiers.addAll(connectorIdentifiersForStepGroup);
572589
}
573590
}
574591
}
575592
}
593+
return connectorIdentifiers;
594+
}
595+
596+
public List<String> getStageConnectorRefs(IntegrationStageConfig integrationStageConfig) {
597+
ArrayList<String> connectorIdentifiers = new ArrayList<>();
598+
connectorIdentifiers = populateConnectorIdentifiers(integrationStageConfig.getExecution().getSteps());
576599

577600
if (integrationStageConfig.getServiceDependencies() == null
578601
|| isEmpty(integrationStageConfig.getServiceDependencies().getValue())) {

0 commit comments

Comments
 (0)