Fixes + improvements

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 8 years ago
parent 2745d513e0
commit 4085799726
  1. 3
      BuildServer/lib/commenter.js
  2. 34
      BuildServer/lib/report-processor.js
  3. 2
      BuildServer/lib/task-processor.js
  4. 2
      BuildServer/lib/tasks/zip.js

@ -134,9 +134,10 @@ const checkPullRequest = (options, callback) => {
exports.commentOnPullRequest = (options, callback) => {
options.github = settings.createGithub(options.baseRepoOptions.owner);
options.headRepoOptions.onTenthAttempt = () => writeComment(options, "Waiting for build to finish...");
return checkPullRequest(options, (err, successMessage) => reportProcessor.getStatusMessageFromRelease(options.app, options.headRepoOptions, (err, successMessage) => {
const escapedErr = (err || "").substring(0, 64000).replace(/`/g, "` ");
const escapedErr = String(err || "").substring(0, 64000).replace(/`/g, "` ");
const message = err
? `Was not built:\r\n\r\n\`\`\`\r\n${escapedErr}\r\n\`\`\`\r\n\r\nDO NOT MERGE!`
: `Build OK\r\n\r\n${successMessage}`;

@ -10,32 +10,41 @@ const _ = require("underscore");
const reportFilename = "report.json.gz";
const writeReport = (releaseDir, err, result, callback) => {
const readable = new streamBuffers.ReadableStreamBuffer();
const data = JSON.stringify({
"date": Date.now(),
err,
result
});
const readable = new streamBuffers.ReadableStreamBuffer({
chunkSize: 1024 * 256,
frequency: 1
});
const writeStream = fs.createWriteStream(path.join(releaseDir, reportFilename));
readable
.on("error", callback)
.pipe(zlib.createGzip())
.on("error", callback)
.pipe(writeStream)
.on("error", callback)
.on("finish", () => {
writeStream.close();
writeStream.end();
callback();
});
readable.put(JSON.stringify({
"date": Date.now(),
err,
result
}));
readable.put(data);
readable.stop();
};
const readReport = (releaseDir, callback) => {
const writable = new streamBuffers.WritableStreamBuffer();
const readStream = fs.createReadStream(path.join(releaseDir, reportFilename));
const writable = new streamBuffers.WritableStreamBuffer();
readStream
.on("error", callback)
.pipe(zlib.createGunzip())
.on("error", callback)
.pipe(writable)
.on("error", callback)
.on("finish", () => {
@ -100,12 +109,17 @@ exports.getStatusMessageFromRelease = (app, options, callback) => {
if (!dirExists) {
return callback("Release directory not found. Probably repository hooks are not configured");
}
if (options.attemptsGetReport > 100) {
return callback("Report file not found");
}
// Maybe it is building right now
return setTimeout(() => exports.getStatusMessageFromRelease(app, options, callback), 10000);
if ((options.attemptsGetReport % 10 === 0) && options.onTenthAttempt) {
options.onTenthAttempt();
}
return setTimeout(() => exports.getStatusMessageFromRelease(app, options, callback), 30000);
}), 2000);
}
@ -136,6 +150,6 @@ exports.getStatusMessageFromRelease = (app, options, callback) => {
}
return callback(null, "OK");
}), 1000);
}), 5000);
});
};

@ -17,7 +17,7 @@ const TaskProcessor = function (task, outerProcessor, callback) {
return `${task.name}/${prefix}`;
}
return (task.name || "") + (prefix || "");
return String(task.name || "") + String(prefix || "");
};
const onError = (message, prefix) => {
errors.push(message);

@ -6,7 +6,7 @@ const Archiver = require("archiver");
module.exports = (params, processor) => ({
"process": () => {
const sourceDirectoryPath = path.normalize(path.join(processor.context.exported, params.directory || ""));
const sourceDirectoryPath = path.normalize(path.join(processor.context.exported, String(params.directory || "")));
const targetArchivePath = path.normalize(path.join(processor.context.release, params.archive));
processor.onInfo(`Compressing "${params.directory}" to "${params.archive}"`);

Loading…
Cancel
Save