-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
156 lines (133 loc) · 4.56 KB
/
index.html
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html>
<head>
<title>Inspektor Gadget CI Test Report</title>
<style>
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th {
border: 1px solid black;
padding: 10px; /* Increase padding */
text-align: left;
font-size: 1.5em; /* Increase font size */
font-weight: bold; /* Make text bold */
}
th a {
height: 100%;
width: 100%;
text-decoration: none;
color: inherit;
}
td {
border: 1px solid black;
}
#mainOnly {
margin-bottom: 20px;
}
.pass {
background-color: lightgreen;
}
.fail {
background-color: lightcoral;
}
.skip {
background-color: lightyellow;
}
a.success {
color: green;
}
a.failure {
color: red;
}
a.skipped {
color: yellow;
}
a.cancelled {
color: grey;
}
</style>
</head>
<body>
<h1>Inspektor Gadget CI Test Report</h1>
<button id="mainOnly">Show Main Only</button>
<script>
function renderTables(data) {
var body = document.querySelector("body");
// Clear existing tables
var existingTables = document.querySelectorAll('table');
existingTables.forEach(function(table) {
table.remove();
});
// Generate tables using data
Object.keys(data).forEach(function (workflowName) {
// Create a new table for each workflow
var table = document.createElement('table');
table.id = workflowName;
table.innerHTML = '<thead><tr><th>' + workflowName + '</th></tr></thead><tbody></tbody>';
body.appendChild(table);
var tableHead = table.querySelector("thead tr");
var tableBody = table.querySelector("tbody");
var testMap = {};
var lastTenJobs = data[workflowName].slice(-10);
lastTenJobs.forEach(function (job, index) {
// Add job ID header
var th = document.createElement('th');
var a = document.createElement('a');
var attempt = job.id.split('_')[1]
a.href = "https://github.com/inspektor-gadget/inspektor-gadget/actions/runs/" + job.run_id + "/attempts/" + attempt;
a.style.display = "block";
a.textContent = job.id;
a.className = job.summary.conclusion;
th.appendChild(a);
tableHead.appendChild(th);
['pass', 'fail', 'skip'].forEach(function (result) {
if (!job.summary[result]) {
return;
}
job.summary[result].forEach(function (testName) {
if (!testMap[testName]) {
testMap[testName] = {};
}
testMap[testName][index] = result;
});
});
});
Object.keys(testMap).forEach(function (testName) {
var row = tableBody.insertRow();
var cell = row.insertCell();
cell.textContent = testName;
for (var i = 0; i < lastTenJobs.length; i++) {
var cell = row.insertCell();
cell.textContent = testMap[testName][i] || '';
cell.className = testMap[testName][i] || '';
}
});
});
}
fetch('data/workflows.json')
.then(function (response) {
return response.json();
})
.then(function (jsonData) {
renderTables(jsonData);
var button = document.getElementById('mainOnly');
button.addEventListener('click', function() {
var filteredData = {};
Object.keys(jsonData).forEach(function (workflowName) {
var workflowData = jsonData[workflowName];
var filteredWorkflowData = workflowData.filter(function(job) {
return job.ref_name === 'main';
});
if (filteredWorkflowData.length > 0) {
filteredData[workflowName] = filteredWorkflowData;
}
});
renderTables(filteredData);
});
});
</script>
</body>
</html>