Skip to content

Commit 12d45bc

Browse files
committed
add build time chart
1 parent 59f5562 commit 12d45bc

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

builds.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Build Data</title>
5+
</head>
6+
<body>
7+
<h1>Build Data</h1>
8+
<div id="view">Loading...</div>
9+
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
10+
<script src="https://cdn.jsdelivr.net/npm/vega-lite@3"></script>
11+
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
12+
<script src="src/builds.mjs" type="module"></script>
13+
</body>
14+
</html>

src/builds.mjs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* global vegaEmbed */
2+
3+
function getBuilds(repo, href = `/repo/${encodeURIComponent(repo)}/builds?limit=100`, builds = []) {
4+
return fetch(`https://api.travis-ci.com${href}`, {
5+
headers: { 'Travis-API-Version': '3' },
6+
})
7+
.then((r) => r.json())
8+
.then((data) => {
9+
const newBuilds = builds.concat(data.builds);
10+
if (data['@pagination'].next) {
11+
return getBuilds(repo, data['@pagination'].next['@href'], newBuilds);
12+
}
13+
return newBuilds;
14+
});
15+
}
16+
17+
const schema = {
18+
'$schema': 'https://vega.github.io/schema/vega-lite/v3.json',
19+
'width': 1000,
20+
'height': 400,
21+
'mark': 'point',
22+
'data': {
23+
'name': 'table',
24+
'values': null,
25+
},
26+
'selection': {
27+
'grid': {
28+
'type': 'interval',
29+
'bind': 'scales',
30+
},
31+
},
32+
'encoding': {
33+
'y': {
34+
'field': 'duration',
35+
'type': 'quantitative',
36+
'axis': {
37+
'title': 'Duration (minutes)',
38+
},
39+
},
40+
'x': {
41+
'field': 'finished_at',
42+
'timeUnit': 'yearmonthdatehoursminutes',
43+
'type': 'temporal',
44+
'scale': {
45+
'nice': 'week',
46+
},
47+
'axis': {
48+
'title': 'Date',
49+
},
50+
},
51+
'color': {
52+
'field': 'state',
53+
'type': 'nominal',
54+
'scale': {
55+
'domain': ['failed', 'errored', 'canceled', 'passed'],
56+
'range': ['#d62728', '#ff7f0e', '#1f77b4', '#5ab43c'],
57+
},
58+
},
59+
},
60+
};
61+
62+
getBuilds('engine262/engine262')
63+
.then((builds) => {
64+
schema.data.values = builds.map((b) => ({
65+
state: b.state,
66+
finished_at: b.finished_at,
67+
duration: b.duration / 60,
68+
}));
69+
vegaEmbed('#view', schema);
70+
});

0 commit comments

Comments
 (0)