mirror of
https://github.com/discourse/discourse.git
synced 2024-12-09 18:03:44 +08:00
72ea00d0cc
By default, in CI environments, Ember CLI does not output anything between "building..." and "cleaning up". Depending on configuration and hardware, Discourse asset builds can take upwards of 60s, and so this lack of output can make the build feel 'stuck'. This commit introduces an addon which checks for CI mode, and then outputs status information periodically. The logic is very similar to Ember CLI's non-CI progress output implementation (https://github.com/ember-cli/ember-cli/blob/04a38fda2c/lib/models/builder.js#L183-L185).
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
"use strict";
|
|
|
|
const progress = require("ember-cli/lib/utilities/heimdall-progress");
|
|
|
|
const CHECK_INTERVAL = 100;
|
|
const LOG_DUPLICATE_AFTER_DURATION = 5000;
|
|
|
|
const REPEAT_DUPLICATE_LOG_ITERATIONS =
|
|
LOG_DUPLICATE_AFTER_DURATION / CHECK_INTERVAL;
|
|
|
|
// If running in CI mode, this addon will poll the current build node and log it.
|
|
// If the node runs for more than LOG_DUPLICATE_AFTER_DURATION, it will be logged again.
|
|
module.exports = {
|
|
name: require("./package").name,
|
|
|
|
preBuild() {
|
|
if (this.project.ui.ci) {
|
|
this._startOutput();
|
|
}
|
|
},
|
|
|
|
outputReady() {
|
|
this._stopOutput();
|
|
},
|
|
|
|
buildError() {
|
|
this._stopOutput();
|
|
},
|
|
|
|
_startOutput() {
|
|
this._discourseProgressLoggerInterval = setInterval(
|
|
this._handleProgress.bind(this),
|
|
CHECK_INTERVAL
|
|
);
|
|
},
|
|
|
|
_handleProgress() {
|
|
const text = progress();
|
|
if (
|
|
text === this._lastText &&
|
|
this._sameOutputCount < REPEAT_DUPLICATE_LOG_ITERATIONS
|
|
) {
|
|
this._sameOutputCount++;
|
|
} else {
|
|
this.project.ui.writeInfoLine("..." + (text ? `[${text}]` : "."));
|
|
this._sameOutputCount = 0;
|
|
}
|
|
this._lastText = text;
|
|
},
|
|
|
|
_stopOutput() {
|
|
clearInterval(this._discourseProgressLoggerInterval);
|
|
},
|
|
};
|