eaglelandsonce commited on
Commit
4708682
·
verified ·
1 Parent(s): 952edf3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -6
app.py CHANGED
@@ -53,13 +53,65 @@ def execute_pipeline(parsed_yaml):
53
 
54
  st.success(f"Stage {stage_name} completed successfully.")
55
 
56
- # Button to run the pipeline
57
- if st.button("Run Pipeline"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  if yaml_input.strip():
59
  is_valid, result = validate_yaml(yaml_input)
60
  if is_valid:
61
- st.info("Executing pipeline...")
62
- execute_pipeline(result)
63
  else:
64
  st.error("Invalid YAML. Cannot execute pipeline.")
65
  else:
@@ -69,5 +121,5 @@ if st.button("Run Pipeline"):
69
  st.sidebar.title("Instructions")
70
  st.sidebar.write("1. Paste your Azure DevOps YAML pipeline configuration into the text area.")
71
  st.sidebar.write("2. Click 'Validate YAML' to check for syntax errors.")
72
- st.sidebar.write("3. Click 'Run Pipeline' to simulate the pipeline execution.")
73
- st.sidebar.write("4. View the progress of each stage, job, and step in real-time.")
 
53
 
54
  st.success(f"Stage {stage_name} completed successfully.")
55
 
56
+ # Enhanced simulation of pipeline stages with dependencies and conditions
57
+ def enhanced_execute_pipeline(parsed_yaml):
58
+ stages = parsed_yaml.get("stages", [])
59
+ if not stages:
60
+ st.warning("No stages found in the pipeline.")
61
+ return
62
+
63
+ stage_results = {}
64
+
65
+ for stage in stages:
66
+ stage_name = stage.get("stage", "Unnamed Stage")
67
+ depends_on = stage.get("dependsOn", [])
68
+ condition = stage.get("condition", None)
69
+
70
+ # Check dependencies
71
+ if depends_on:
72
+ for dependency in depends_on:
73
+ if stage_results.get(dependency) != "success":
74
+ st.write(f"Skipping stage {stage_name} due to failed dependency: {dependency}.")
75
+ stage_results[stage_name] = "skipped"
76
+ break
77
+ else:
78
+ pass # All dependencies are successful
79
+
80
+ # Check conditions
81
+ if condition and "failed" in condition:
82
+ dependent_stage = condition.split("(")[1].split(")")[0]
83
+ if stage_results.get(dependent_stage) != "failed":
84
+ st.write(f"Skipping stage {stage_name} due to condition: {condition}.")
85
+ stage_results[stage_name] = "skipped"
86
+ continue
87
+
88
+ if stage_results.get(stage_name) == "skipped":
89
+ continue
90
+
91
+ # Execute the stage
92
+ st.write(f"Starting stage: {stage_name}...")
93
+ time.sleep(2) # Simulate execution time
94
+ jobs = stage.get("jobs", [])
95
+ for job in jobs:
96
+ job_name = job.get("job", "Unnamed Job")
97
+ st.write(f"Executing job: {job_name}...")
98
+ time.sleep(2) # Simulate execution time
99
+ steps = job.get("steps", [])
100
+ for step in steps:
101
+ step_display = step.get("displayName", "Unnamed Step")
102
+ st.write(f"Running step: {step_display}...")
103
+ time.sleep(2) # Simulate execution time
104
+
105
+ st.success(f"Stage {stage_name} completed successfully.")
106
+ stage_results[stage_name] = "success"
107
+
108
+ # Button to run the enhanced pipeline
109
+ if st.button("Run Enhanced Pipeline"):
110
  if yaml_input.strip():
111
  is_valid, result = validate_yaml(yaml_input)
112
  if is_valid:
113
+ st.info("Executing enhanced pipeline...")
114
+ enhanced_execute_pipeline(result)
115
  else:
116
  st.error("Invalid YAML. Cannot execute pipeline.")
117
  else:
 
121
  st.sidebar.title("Instructions")
122
  st.sidebar.write("1. Paste your Azure DevOps YAML pipeline configuration into the text area.")
123
  st.sidebar.write("2. Click 'Validate YAML' to check for syntax errors.")
124
+ st.sidebar.write("3. Click 'Run Enhanced Pipeline' to simulate the pipeline execution with dependencies and conditions.")
125
+ st.sidebar.write("4. View the progress of each stage, job, and step in real-time, including skipped stages due to dependencies or conditions.")