1
0
Fork 0

Merge pull request #3408 from bobrippling/feat/ci-warnings

sanitycheck: promote warnings to errors in CI
master
Gordon Williams 2024-05-09 14:52:40 +01:00 committed by GitHub
commit 0302a9b477
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -19,6 +19,7 @@ try {
var BASEDIR = __dirname+"/../"; var BASEDIR = __dirname+"/../";
var APPSDIR_RELATIVE = "apps/"; var APPSDIR_RELATIVE = "apps/";
var APPSDIR = BASEDIR + APPSDIR_RELATIVE; var APPSDIR = BASEDIR + APPSDIR_RELATIVE;
var knownWarningCount = 0;
var warningCount = 0; var warningCount = 0;
var errorCount = 0; var errorCount = 0;
function ERROR(msg, opt) { function ERROR(msg, opt) {
@ -32,11 +33,12 @@ function WARN(msg, opt) {
opt = opt||{}; opt = opt||{};
if (KNOWN_WARNINGS.includes(msg)) { if (KNOWN_WARNINGS.includes(msg)) {
console.log(`Known warning : ${msg}`); console.log(`Known warning : ${msg}`);
knownWarningCount++;
} else { } else {
console.log(`::warning${Object.keys(opt).length?" ":""}${Object.keys(opt).map(k=>k+"="+opt[k]).join(",")}::${msg}`); console.log(`::warning${Object.keys(opt).length?" ":""}${Object.keys(opt).map(k=>k+"="+opt[k]).join(",")}::${msg}`);
}
warningCount++; warningCount++;
} }
}
var apps = []; var apps = [];
var dirs = fs.readdirSync(APPSDIR, {withFileTypes: true}); var dirs = fs.readdirSync(APPSDIR, {withFileTypes: true});
@ -396,8 +398,11 @@ while(fileA=allFiles.pop()) {
} }
console.log("=================================="); console.log("==================================");
console.log(`${errorCount} errors, ${warningCount} warnings`); console.log(`${errorCount} errors, ${warningCount} warnings (and ${knownWarningCount} known warnings)`);
console.log("=================================="); console.log("==================================");
if (errorCount) { if (errorCount) {
process.exit(1); process.exit(1);
} else if ("CI" in process.env && warningCount) {
console.log("Running in CI, raising an error from warnings");
process.exit(1);
} }