Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import yaml
|
3 |
+
import time
|
4 |
+
|
5 |
+
# Title
|
6 |
+
st.title("Azure DevOps Pipeline YAML Simulator")
|
7 |
+
|
8 |
+
# Input for YAML pipeline configuration
|
9 |
+
yaml_input = st.text_area("Paste your Azure DevOps pipeline YAML here:", height=300)
|
10 |
+
|
11 |
+
# Function to validate YAML syntax
|
12 |
+
def validate_yaml(yaml_text):
|
13 |
+
try:
|
14 |
+
parsed_yaml = yaml.safe_load(yaml_text)
|
15 |
+
return True, parsed_yaml
|
16 |
+
except yaml.YAMLError as e:
|
17 |
+
return False, str(e)
|
18 |
+
|
19 |
+
# Button to validate YAML
|
20 |
+
if st.button("Validate YAML"):
|
21 |
+
if yaml_input.strip():
|
22 |
+
is_valid, result = validate_yaml(yaml_input)
|
23 |
+
if is_valid:
|
24 |
+
st.success("YAML syntax is valid!")
|
25 |
+
else:
|
26 |
+
st.error(f"Invalid YAML syntax:\n{result}")
|
27 |
+
else:
|
28 |
+
st.warning("Please paste your YAML configuration.")
|
29 |
+
|
30 |
+
# Simulate pipeline execution
|
31 |
+
def execute_pipeline(parsed_yaml):
|
32 |
+
stages = parsed_yaml.get("stages", [])
|
33 |
+
if not stages:
|
34 |
+
st.warning("No stages found in the pipeline.")
|
35 |
+
return
|
36 |
+
|
37 |
+
for stage in stages:
|
38 |
+
stage_name = stage.get("stage", "Unnamed Stage")
|
39 |
+
st.write(f"Starting stage: {stage_name}...")
|
40 |
+
time.sleep(2) # Simulate execution time
|
41 |
+
|
42 |
+
jobs = stage.get("jobs", [])
|
43 |
+
for job in jobs:
|
44 |
+
job_name = job.get("job", "Unnamed Job")
|
45 |
+
st.write(f"Executing job: {job_name}...")
|
46 |
+
time.sleep(2) # Simulate execution time
|
47 |
+
|
48 |
+
steps = job.get("steps", [])
|
49 |
+
for step in steps:
|
50 |
+
step_display = step.get("displayName", "Unnamed Step")
|
51 |
+
st.write(f"Running step: {step_display}...")
|
52 |
+
time.sleep(2) # Simulate execution time
|
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:
|
66 |
+
st.warning("Please paste your YAML configuration.")
|
67 |
+
|
68 |
+
# Instructions for users
|
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.")
|