This repository has been archived by the owner on Nov 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathprint-report.js
231 lines (223 loc) · 8.37 KB
/
print-report.js
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
'use strict';
var debug = require('debug')(__filename.slice(__dirname.length + 1));
var reports = require('./reports');
var util = require('./crater-util');
var dist = require('./rust-dist');
var crateIndex = require('./crate-index');
var db = require('./crater-db');
var fs = require('fs');
function main() {
var reportSpec = getReportSpecFromArgs();
if (!reportSpec) {
console.log("can't parse report spec");
process.exit(1);
}
var config = util.loadDefaultConfig();
crateIndex.updateCaches(config).then(function() {
printReport(config, reportSpec);
});
}
function printReport(config, reportSpec) {
if (reportSpec.type == "current") {
var date = reportSpec.date;
reports.createCurrentReport(date, config).then(function(report) {
console.log("# Current Report");
console.log();
console.log("* current stable is " + report.stable);
console.log("* current beta is " + report.beta);
console.log("* current nightly is " + report.nightly);
}).done();
} else if (reportSpec.type == "weekly") {
var date = reportSpec.date;
db.connect(config).then(function(dbctx) {
var p = reports.createWeeklyReport(date, dbctx, config);
return p.then(function(report) {
console.log("# Weekly Report");
console.log();
console.log("Date: " + report.date);
console.log();
console.log("## Current releases");
console.log();
console.log("* The most recent stable release is " + report.currentReport.stable + ".");
console.log("* The most recent beta release is " + report.currentReport.beta + ".");
console.log("* The most recent nightly release is " + report.currentReport.nightly + ".");
console.log();
console.log("## Coverage");
console.log();
console.log("From stable to beta:");
console.log("* " + report.beta.statuses.length + " crates tested: " +
report.beta.statusSummary.working + " working / " +
report.beta.statusSummary.notWorking + " not working / " +
report.beta.statusSummary.regressed + " regressed / " +
report.beta.statusSummary.fixed + " fixed / " +
report.beta.statusSummary.unknown + " unknown.");
console.log();
console.log("From beta to nightly:");
console.log("* " + report.nightly.statuses.length + " crates tested: " +
report.nightly.statusSummary.working + " working / " +
report.nightly.statusSummary.broken + " broken / " +
report.nightly.statusSummary.fixed + " fixed / " +
report.nightly.statusSummary.unknown + " unknown.");
console.log();
console.log("## Regressions");
console.log();
console.log("* There are currently " + report.beta.rootRegressions.length +
" root regressions from stable to beta.");
console.log("* There are currently " + report.nightly.rootRegressions.length +
" root regressions from beta to nightly.");
console.log("* There are currently " + report.beta.regressions.length +
" regressions from stable to beta.");
console.log("* There are currently " + report.nightly.regressions.length +
" regressions from beta to nightly.");
console.log();
console.log("## Beta root regressions, sorted by rank:");
printCrateList(report.beta.rootRegressions);
console.log("## Nightly root regressions, sorted by rank:");
printCrateList(report.nightly.rootRegressions);
console.log("## Beta non-root regressions, sorted by rank:");
printCrateList(report.beta.regressions);
console.log("## Nightly non-root regressions, sorted by rank:");
printCrateList(report.nightly.regressions);
console.log("## Beta broken, sorted by rank:");
printCrateList(report.beta.broken);
console.log("## Nightly broken, sorted by rank:");
printCrateList(report.nightly.broken);
console.log("## Beta fixed, sorted by rank:");
printCrateList(report.beta.fixed);
console.log("## Nightly fixed, sorted by rank:");
printCrateList(report.nightly.fixed);
}).then(function() {
return db.disconnect(dbctx);
});
}).done();
} else if (reportSpec.type == "comparison") {
var date = reportSpec.date;
db.connect(config).then(function(dbctx) {
var p = reports.createComparisonReport(reportSpec.fromToolchain, reportSpec.toToolchain,
dbctx, config);
return p.then(function(report) {
var from = util.toolchainToString(report.fromToolchain);
var to = util.toolchainToString(report.toToolchain);
console.log("# Regression report " + from + " vs. " + to);;
console.log();
console.log("* From: " + from);
console.log("* To: " + to);
console.log();
console.log("## Coverage");
console.log();
console.log("* " + report.statuses.length + " crates tested: " +
report.statusSummary.working + " working / " +
report.statusSummary.broken + " broken / " +
report.statusSummary.regressed + " regressed / " +
report.statusSummary.fixed + " fixed / " +
report.statusSummary.unknown + " unknown.");
console.log();
console.log("## Regressions");
console.log();
console.log("* There are " + report.rootRegressions.length + " root regressions");
console.log("* There are " + report.regressions.length + " regressions");
console.log();
console.log("## Root regressions, sorted by rank:");
printCrateList(report.rootRegressions);
console.log("## Non-root regressions, sorted by rank:");
printCrateList(report.nonRootRegressions);
console.log("## Broken, sorted by rank:");
printCrateList(report.broken);
console.log("## Fixed, sorted by rank:");
printCrateList(report.fixed);
console.log("## Working, sorted by rank:");
printCrateList(report.working);
}).then(function() {
return db.disconnect(dbctx);
});
}).done();
} else if (reportSpec.type == "popularity") {
reports.createPopularityReport(config).then(function(report) {
console.log("# Popularity report");
console.log("");
report.forEach(function(r) {
console.log("* " + r.pop + " [" + r.crateName + "](" + r.registryUrl + ")");
});
});
} else if (reportSpec.type == "toolchain") {
db.connect(config).then(function(dbctx) {
return reports.createToolchainReport(reportSpec.toolchain, dbctx, config).then(function(report) {
console.log("# Toolchain report for " + util.toolchainToString(report.toolchain));
console.log("");
console.log("* " + report.successes.length + " successes / " + report.failures.length + " failures");
console.log("* " + report.rootFailures.length + " root failures / " + report.nonRootFailures.length + " non-root failures");
console.log("");
console.log("## Root failures, sorted by rank");
console.log("");
report.rootFailures.forEach(function(r) {
var s = "* [" + r.crateName + "-" + r.crateVers + "](" + r.inspectorLink + ")";
console.log(s);
});
console.log("");
console.log("## Non-root failures, sorted by rank");
console.log("");
report.nonRootFailures.forEach(function(r) {
var s = "* [" + r.crateName + "-" + r.crateVers + "](" + r.inspectorLink + ")";
console.log(s);
});
console.log("");
console.log("## Successes, sorted by rank");
console.log("");
report.successes.forEach(function(r) {
var s = "* [" + r.crateName + "-" + r.crateVers + "](" + r.inspectorLink + ")";
console.log(s);
});
console.log("");
return db.disconnect(dbctx);
});
}).done();
} else {
console.log("unknown report type");
}
}
function printCrateList(statuses) {
console.log();
statuses.forEach(function(reg) {
var fromLink = reg.from.inspectorLink;
var toLink = reg.to.inspectorLink;
var s = "* [" + reg.crateName + "-" + reg.crateVers + "](" + reg.registryUrl + ") " +
"([before](" + fromLink + ")) " +
"([after](" + toLink + "))";
console.log(s);
});
console.log();
}
function getReportSpecFromArgs() {
if (process.argv[2] == "current") {
return {
type: "current",
date: process.argv[3] || util.rustDate(new Date(Date.now()))
};
} else if (process.argv[2] == "weekly") {
return {
type: "weekly",
date: process.argv[3] || util.rustDate(new Date(Date.now()))
};
} else if (process.argv[2] == "comparison") {
if (!process.argv[3] || !process.argv[4]) {
return null;
}
return {
type: "comparison",
fromToolchain: util.parseToolchain(process.argv[3]),
toToolchain: util.parseToolchain(process.argv[4])
};
} else if (process.argv[2] == "popularity") {
return {
type: "popularity"
};
} else if (process.argv[2] == "toolchain") {
return {
type: "toolchain",
toolchain: util.parseToolchain(process.argv[3])
};
} else {
return null;
}
}
main();