-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcores.html
More file actions
285 lines (250 loc) · 11.8 KB
/
cores.html
File metadata and controls
285 lines (250 loc) · 11.8 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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>libretro buildbot core status</title>
<style>
body { font-family: sans-serif; margin: 20px; }
table { border-collapse: collapse; }
th, td { padding: 4px 8px; vertical-align: middle; border-bottom: 1px solid #eee; }
th { position: sticky; top: 0; background: white; text-align: left; }
td:first-child { font-family: monospace; }
img { vertical-align: middle; }
.y { color: #2a2; text-align: center; }
.n { color: #c66; text-align: center; }
.u { color: #ccc; text-align: center; }
.refresh-btn { cursor: pointer; background: none; border: none; color: #999; padding: 0 2px; font-size: 14px; }
.refresh-btn:hover { color: #333; }
#refresh-all { cursor: pointer; }
#status { margin-bottom: 10px; color: #666; }
#filter { margin-bottom: 10px; padding: 4px; width: 300px; }
</style>
</head>
<body>
<h1>libretro buildbot core status</h1>
<div id="status">Loading...</div>
<input type="text" id="filter" placeholder="Filter cores..." />
<label><input type="checkbox" id="hideOk" onchange="saveAndApplyFilters()"> Hide all-OK rows</label>
<label><input type="checkbox" id="hideUnknown" onchange="saveAndApplyFilters()"> Hide unknown pipelines</label>
<button id="refresh-all" onclick="refreshAll()" title="Refresh all cores">↻ Refresh All</button>
<table>
<thead>
<tr>
<th>Core</th>
<th>Pipeline</th>
<th>win-x64</th>
<th>linux-x64</th>
<th>osx-x64</th>
<th>osx-arm64</th>
<th>ios-arm64</th>
<th>tvos-arm64</th>
<th>android-arm64-v8a</th>
</tr>
</thead>
<tbody id="cores"></tbody>
</table>
<script>
const GITLAB_URL = 'https://git.libretro.com';
const GROUP = 'libretro';
const PLATFORMS = ['windows-x64', 'linux-x64', 'osx-x64', 'osx-arm64', 'ios-arm64', 'tvos-arm64', 'android-arm64'];
const PLATFORMS_REQUIRED = PLATFORMS.filter(p => p !== 'android-arm64');
// Projects to skip (superseded or deprecated)
const SKIP_PROJECTS = ['flycast', 'uae4arm-libretro'];
// Platform patterns to look for in job names
const PLATFORM_JOB_PATTERNS = {
'windows-x64': ['libretro-build-windows-x64', 'build-retroarch-windows-x64', 'windows-x64'],
'linux-x64': ['libretro-build-linux-x64', 'build-retroarch-linux-x64', 'linux-x64'],
'android-arm64': ['android-arm64-v8a', 'android-arm64', 'build-retroarch-android-aarch64'],
'osx-x64': ['libretro-build-osx-x64', 'build-retroarch-osx-x64', 'build-retroarch-osx-universal-metal', 'build-retroarch-osx-opengl-x64', 'osx-x64'],
'osx-arm64': ['libretro-build-osx-arm64', 'build-retroarch-osx-arm64', 'build-retroarch-osx-universal-metal', 'osx-arm64'],
'ios-arm64': ['libretro-build-ios-arm64', 'build-retroarch-ios-arm64', 'ios-arm64'],
'tvos-arm64': ['libretro-build-tvos-arm64', 'build-retroarch-tvos-arm64', 'tvos-arm64'],
};
// Fetch a file from a project
async function fetchFile(projectId, filePath, ref) {
const url = `${GITLAB_URL}/api/v4/projects/${projectId}/repository/files/${encodeURIComponent(filePath)}?ref=${encodeURIComponent(ref)}`;
const response = await fetch(url);
if (!response.ok) return null;
const data = await response.json();
return atob(data.content);
}
// Fetch project info from .gitlab-ci.yml (including local includes)
async function fetchProjectInfo(project) {
const info = { coreName: null, pipelineStatus: null, platforms: {} };
try {
let content = await fetchFile(project.id, '.gitlab-ci.yml', project.default_branch);
if (!content) return info;
// Check for local file includes and fetch them
const localIncludes = content.match(/^\s*-\s*['"]([^'"]+\.yml)['"]$/gm) || [];
for (const inc of localIncludes) {
const pathMatch = inc.match(/['"]([^'"]+)['"]/);
if (pathMatch) {
const includedContent = await fetchFile(project.id, pathMatch[1], project.default_branch);
if (includedContent) {
content += '\n' + includedContent;
}
}
}
// Extract CORENAME
const match = content.match(/CORENAME:\s*["']?([^"'\s\n]+)["']?/i);
info.coreName = match ? match[1].toLowerCase() : null;
// Find job definitions (lines starting with word characters, ending with colon)
// Filter out dummy jobs per get_artifacts.py logic
const jobMatches = content.match(/^[\w][\w\-]*:/gm) || [];
const jobs = jobMatches
.map(j => j.replace(':', '').toLowerCase())
.filter(j => !j.includes('dummy'));
// Check which platforms have jobs defined
for (const platform of PLATFORMS) {
const patterns = PLATFORM_JOB_PATTERNS[platform] || [];
info.platforms[platform] = jobs.some(job =>
patterns.some(pattern => job.includes(pattern.toLowerCase()))
);
}
// Fetch latest pipeline status
const pipeUrl = `${GITLAB_URL}/api/v4/projects/${project.id}/pipelines?per_page=1&ref=${encodeURIComponent(project.default_branch)}`;
const pipeResponse = await fetch(pipeUrl);
if (pipeResponse.ok) {
const pipelines = await pipeResponse.json();
info.pipelineStatus = pipelines[0]?.status || null;
}
} catch (e) {
// ignore errors
}
return info;
}
function updateRowCells(row, platformCells, info) {
const isUnknown = !info.pipelineStatus || info.pipelineStatus === 'skipped' || info.pipelineStatus === 'manual';
const isPassed = info.pipelineStatus === 'success';
let allAvailable = true;
for (let i = 0; i < PLATFORMS.length; i++) {
const available = info.platforms[PLATFORMS[i]] || false;
if (!available && PLATFORMS_REQUIRED.includes(PLATFORMS[i])) allAvailable = false;
platformCells[i].textContent = available ? '✓' : (isUnknown ? '—' : '✗');
platformCells[i].className = available ? 'y' : (isUnknown ? 'u' : 'n');
}
row.dataset.ok = (isPassed && allAvailable) ? 'true' : 'false';
row.dataset.unknown = isUnknown ? 'true' : 'false';
applyFilters();
}
function refreshAll() {
for (const row of document.querySelectorAll('#cores tr')) {
if (row._project) refreshProject(row);
}
}
async function refreshProject(row) {
const cells = row._platformCells;
for (const cell of cells) { cell.textContent = '…'; cell.className = 'u'; }
const info = await fetchProjectInfo(row._project);
updateRowCells(row, cells, info);
const p = row._project;
row._badgeImg.src = `${p.web_url}/badges/${p.default_branch}/pipeline.svg?t=${Date.now()}`;
}
function appendProjects(projects) {
const table = document.getElementById('cores');
const filterQuery = document.getElementById('filter').value.toLowerCase();
for (const project of projects) {
if (!project.default_branch) continue;
if (SKIP_PROJECTS.includes(project.name.toLowerCase())) continue;
const row = document.createElement('tr');
row.dataset.name = project.name.toLowerCase();
if (filterQuery && !row.dataset.name.includes(filterQuery)) {
row.style.display = 'none';
}
// Name cell
const nameCell = document.createElement('td');
nameCell.textContent = project.name;
const refreshBtn = document.createElement('button');
refreshBtn.className = 'refresh-btn';
refreshBtn.textContent = ' ↻';
refreshBtn.title = 'Refresh this core';
refreshBtn.onclick = () => refreshProject(row);
nameCell.appendChild(refreshBtn);
row.appendChild(nameCell);
// Pipeline badge cell
const badgeCell = document.createElement('td');
const link = document.createElement('a');
link.href = `${project.web_url}/-/pipelines`;
link.target = '_blank';
const img = document.createElement('img');
img.alt = 'pipeline status';
img.src = `${project.web_url}/badges/${project.default_branch}/pipeline.svg`;
img.loading = 'lazy';
link.appendChild(img);
badgeCell.appendChild(link);
row.appendChild(badgeCell);
// Platform availability cells (initially show loading state)
const platformCells = [];
for (const platform of PLATFORMS) {
const cell = document.createElement('td');
cell.textContent = '·';
cell.className = 'n';
row.appendChild(cell);
platformCells.push(cell);
}
row._project = project;
row._platformCells = platformCells;
row._badgeImg = img;
table.appendChild(row);
// Fetch CORENAME, pipeline status, and platform availability, then update cells
fetchProjectInfo(project).then(info => updateRowCells(row, platformCells, info));
}
}
function saveAndApplyFilters() {
localStorage.setItem('cores_hideOk', document.getElementById('hideOk').checked);
localStorage.setItem('cores_hideUnknown', document.getElementById('hideUnknown').checked);
applyFilters();
}
function applyFilters() {
const query = document.getElementById('filter').value.toLowerCase();
const hideOk = document.getElementById('hideOk').checked;
const hideUnknown = document.getElementById('hideUnknown').checked;
const rows = document.querySelectorAll('#cores tr');
for (const row of rows) {
const matchesQuery = row.dataset.name.includes(query);
const isOk = row.dataset.ok === 'true';
const isUnknown = row.dataset.unknown === 'true';
const hidden = (hideOk && isOk) || (hideUnknown && isUnknown);
row.style.display = (matchesQuery && !hidden) ? '' : 'none';
}
}
function setupFilter() {
const savedHideOk = localStorage.getItem('cores_hideOk');
const savedHideUnknown = localStorage.getItem('cores_hideUnknown');
document.getElementById('hideOk').checked = savedHideOk === 'true';
document.getElementById('hideUnknown').checked = savedHideUnknown !== null ? savedHideUnknown === 'true' : true;
document.getElementById('filter').addEventListener('input', applyFilters);
}
async function main() {
const status = document.getElementById('status');
setupFilter();
let loaded = 0;
let total = null;
let page = 1;
const perPage = 25;
try {
while (true) {
const url = `${GITLAB_URL}/api/v4/groups/${GROUP}/projects?per_page=${perPage}&page=${page}&order_by=name&sort=asc`;
const response = await fetch(url);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
if (total === null) {
total = parseInt(response.headers.get('x-total'), 10) || '?';
}
const data = await response.json();
if (data.length === 0) break;
appendProjects(data);
loaded += data.length;
status.textContent = `Loading... (${loaded}/${total})`;
if (data.length < perPage) break;
page++;
}
status.textContent = `${loaded} projects`;
} catch (err) {
status.textContent = `Error: ${err.message} (${loaded}/${total} loaded)`;
console.error(err);
}
}
main();
</script>
</body>
</html>