-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.js
More file actions
54 lines (47 loc) · 1.68 KB
/
report.js
File metadata and controls
54 lines (47 loc) · 1.68 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
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const glob = require('fast-glob').sync;
const semver = require('semver');
const tags_path = './jobs/tags.json';
const jobs_glob = './jobs/status/*.json';
// check for status/tag base file
if(!fs.existsSync(path.resolve(tags_path))) {
process.exit(1);
}
let tags = require(path.resolve(tags_path));
// {success: $status, run: $run, image: $image, nodegit: $nodegit}
const jobs = glob(jobs_glob).map(f => require(path.resolve(f)));
// gather status info
let report = jobs.reduce((acc, job) => {
acc[job.image] || (acc[job.image] = {});
acc[job.image][job.nodegit] = Object.assign(
{},
job,
{
tags: tags[job.image][job.nodegit],
// link: `https://github.com/bitmeal/nodegit-alpine/runs/${job['run']}`,
icon: job['success'] ? '✔' : '❌',
state: job['success'] ? 'success' : 'failure'
}
);
return acc;
}, {});
// print output
let max_image_len = Object.keys(report).map(image => image.length).sort((a,b) => b-a)[0];
[
'alpine',
'lts-alpine',
...Object.keys(report)
.filter(i => i.match(/\d+-alpine/))
.sort((a,b) => b.match(/^\d+/)[0] - a.match(/^\d+/)[0])
].forEach((image) => {
Object.keys(report[image])
.sort(semver.rcompare)
.forEach((ng) => {
let job = report[image][ng];
let padding = ' '.repeat(max_image_len - job.image.length);
console.log('*', job.icon, `[FROM node:**${job.image}** ${padding}| nodegit@**${job.nodegit}**]`, job.tags.map(t => ('`'+t+'`')).join(', '));
});
}
);