-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
76 lines (57 loc) · 2.5 KB
/
main.py
File metadata and controls
76 lines (57 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import pandas as pd
import os
from data.graph_config import GraphConfig, NetworkGraphConfig
from config import target_repositories
from functions.graph import plot_piechart, plot_network
from services.github import GitHubService
import functions.workflow as workflow
from functions.utility import cleanup
from functions.report import generate_report
if __name__ == "__main__":
github_token = os.environ.get("GITHUB_TOKEN")
if not github_token:
raise Exception("GITHUB_TOKEN environment variable is not set")
github_service = GitHubService(github_token)
repositories = target_repositories
clone_dir = "cloned_repos"
actions_all_repositories = []
for repo in repositories:
repo_path = github_service.clone_repo(repo, clone_dir)
workflow_files = workflow.find_workflow_files(repo_path)
actions_all_workflows = []
for wf_file in workflow_files:
workflow_actions = workflow.parse_workflow(repo_path.rstrip("/").split("/")[-1], wf_file, github_service)
actions_all_repositories += workflow_actions
cleanup(repo_path)
cleanup(clone_dir)
print("Latest actions table:")
print(github_service.latest_actions_table)
actions_df = pd.DataFrame(actions_all_repositories)
print("Database:")
print(actions_df)
actions_of_interest = ["actions/checkout", "ruby/setup-ruby", "aws-actions/configure-aws-credentials"]
for action in actions_of_interest:
plot_piechart(
f"select latest, version, count(*) as count from df where name = '{action}' group by name, version;",
GraphConfig(
source = actions_df,
x = "version",
y = "count",
title = f"Occurrences of different versions of {action} across repositories",
output_path = f"graphs/pie_charts/{action.replace("/", "_").replace("-", "_")}_pie_chart.png",
color_separation_variable="latest"
)
)
plot_network(
f"select repository, latest, name || '@' || version AS name_version from df;",
NetworkGraphConfig(
source = actions_df,
root_node = "Organisation",
layer_1 = "repository",
layer_2 = "name_version",
color_separation_variable = "latest",
title = "GitHub Actions versions across repositories",
output_path = "graphs/network_graph.png"
)
)
generate_report("graphs", "github_actions_report.md")