Skip to content

Commit ca333e9

Browse files
committed
Add CI graph to the documentation
1 parent f1d983a commit ca333e9

File tree

5 files changed

+311
-0
lines changed

5 files changed

+311
-0
lines changed

docs/_static/.gitkeep

Whitespace-only changes.

docs/_static/ci_graph.svg

Lines changed: 252 additions & 0 deletions
Loading

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Below is the table of contents for the Parallel Programming Course documentation
1111
user_guide/download
1212
user_guide/environment
1313
user_guide/submit_work
14+
user_guide/ci

docs/user_guide/ci.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Continuous Integration (CI)
2+
============================
3+
4+
Students need to pass all the checks in the CI pipeline before their work can be considered for submission.
5+
This includes successful code checkout, build ans testing stages.
6+
Each integration is verified by an automated build and automated tests.
7+
8+
CI Pipeline
9+
------------
10+
11+
The CI pipeline for this project is illustrated in the following diagram:
12+
13+
.. image:: ../_static/ci_graph.svg
14+
:alt: CI Pipeline Diagram
15+
:align: center

scripts/jobs_graph.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import os
2+
3+
try:
4+
import yaml
5+
except ImportError:
6+
print("Please install pyyaml: pip install pyyaml")
7+
exit(1)
8+
9+
try:
10+
import graphviz
11+
except ImportError:
12+
print("Please install graphviz: pip install graphviz")
13+
exit(1)
14+
15+
16+
def parse_gha_yml(file_path):
17+
with open(file_path, "r") as file:
18+
gha_data = yaml.safe_load(file)
19+
return gha_data
20+
21+
def build_jobs_graph(gha_data):
22+
jobs = gha_data.get("jobs", {})
23+
dot = graphviz.Digraph()
24+
25+
for job_name, job_data in jobs.items():
26+
dot.node(job_name)
27+
needs = job_data.get("needs", [])
28+
if isinstance(needs, str):
29+
needs = [needs]
30+
for dependency in needs:
31+
dot.edge(dependency, job_name)
32+
33+
return dot
34+
35+
def save_graph(dot, filename, file_format):
36+
dot.render(filename, format=file_format, cleanup=True)
37+
38+
if __name__ == "__main__":
39+
gha_file_path = os.path.join(".github", "workflows", "main.yml")
40+
svg_path = os.path.join("docs", "_static", "ci_graph")
41+
gha_data = parse_gha_yml(gha_file_path)
42+
jobs_graph = build_jobs_graph(gha_data)
43+
save_graph(jobs_graph, svg_path, "svg")

0 commit comments

Comments
 (0)