Skip to content

Commit 5266ea7

Browse files
committed
ci: mermaids with colors
1 parent ca9fff7 commit 5266ea7

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

tools/dockerfile-deps.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,50 @@ def compare_with_facit(self, facit_path: Path) -> Tuple[bool, List[str]]:
212212
return len(errors) == 0, errors
213213

214214
def generate_mermaid(self) -> str:
215-
"""Generate Mermaid flowchart from dependencies"""
215+
"""Generate Mermaid flowchart from dependencies with color coding"""
216216
lines = ["graph TD"]
217217

218+
# Define color classes for different stage types
219+
lines.append(" classDef base fill:#3b82f6,stroke:#1e40af,color:#fff")
220+
lines.append(" classDef deps fill:#06b6d4,stroke:#0891b2,color:#fff")
221+
lines.append(" classDef test fill:#10b981,stroke:#059669,color:#fff")
222+
lines.append(" classDef lint fill:#f97316,stroke:#ea580c,color:#fff")
223+
lines.append(" classDef build fill:#8b5cf6,stroke:#7c3aed,color:#fff")
224+
lines.append(" classDef artifact fill:#ec4899,stroke:#db2777,color:#fff")
225+
lines.append(" classDef publish fill:#ef4444,stroke:#dc2626,color:#fff")
226+
lines.append(" classDef validate fill:#eab308,stroke:#ca8a04,color:#000")
227+
lines.append("")
228+
229+
def get_stage_class(stage: str) -> str:
230+
"""Determine the CSS class for a stage based on its name"""
231+
if stage.endswith("-base") or stage == "rust-base":
232+
return "base"
233+
elif stage.endswith("-deps"):
234+
return "deps"
235+
elif ".test" in stage:
236+
return "test"
237+
elif ".lint" in stage:
238+
return "lint"
239+
elif ".build" in stage:
240+
return "build"
241+
elif ".artifact" in stage:
242+
return "artifact"
243+
elif ".publish" in stage:
244+
return "publish"
245+
elif "validate" in stage:
246+
return "validate"
247+
return "base" # default
248+
218249
# Add nodes (exclude "all" stage as it's just a collection target)
219250
for stage in self.stages:
220251
if stage == "all":
221252
continue
222253
# Sanitize stage names for Mermaid
223254
node_id = stage.replace("-", "_").replace(".", "_")
224-
lines.append(f" {node_id}[\"{stage}\"]")
255+
stage_class = get_stage_class(stage)
256+
lines.append(f" {node_id}[\"{stage}\"]:::{stage_class}")
257+
258+
lines.append("")
225259

226260
# Add edges (dependencies) - skip anything involving "all"
227261
for stage, deps in self.dependencies.items():

0 commit comments

Comments
 (0)