If we upload to s3/gcs then wait on sending budget message until data is uploaded (#3180)
* If we upload to s3/gcs then wait on sending budget message until data is uploaded. * Fix uploading * Also collect errors
This commit is contained in:
parent
bfc81cb56c
commit
a8e15f3d85
|
|
@ -8,15 +8,17 @@ const cliUtil = require('../../cli/util');
|
|||
const send = require('./send');
|
||||
|
||||
function getBrowserData(data) {
|
||||
return `${data.browser.name} ${data.browser.version} ${get(
|
||||
data,
|
||||
'android.model',
|
||||
''
|
||||
)} ${get(data, 'android.androidVersion', '')} ${get(
|
||||
data,
|
||||
'android.id',
|
||||
''
|
||||
)} `;
|
||||
if (data && data.browser) {
|
||||
return `${data.browser.name} ${data.browser.version} ${get(
|
||||
data,
|
||||
'android.model',
|
||||
''
|
||||
)} ${get(data, 'android.androidVersion', '')} ${get(
|
||||
data,
|
||||
'android.id',
|
||||
''
|
||||
)} `;
|
||||
} else return '';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -33,6 +35,7 @@ module.exports = {
|
|||
throwIfMissing(options.matrix, ['accessToken', 'host', 'room'], 'matrix');
|
||||
this.resultUrls = context.resultUrls;
|
||||
this.errorTexts = '';
|
||||
this.waitForUpload = false;
|
||||
},
|
||||
async processMessage(message) {
|
||||
const options = this.matrixOptions;
|
||||
|
|
@ -41,7 +44,14 @@ module.exports = {
|
|||
this.browserData = message.data;
|
||||
break;
|
||||
}
|
||||
case 'render': {
|
||||
case 'gcs.setup':
|
||||
case 'ftp.setup':
|
||||
case 's3.setup': {
|
||||
this.waitForUpload = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'sitespeedio.render': {
|
||||
if (this.errorTexts !== '') {
|
||||
const room = get(options, 'rooms.error', options.room);
|
||||
try {
|
||||
|
|
@ -98,15 +108,42 @@ module.exports = {
|
|||
}
|
||||
text += `</ul>`;
|
||||
}
|
||||
} else {
|
||||
text += `<p><b>⚠️ All (${
|
||||
}
|
||||
if (Object.keys(message.data.error).length > 0) {
|
||||
const errorURLs = Object.keys(message.data.error);
|
||||
text += `<h1>⚠️ Budget errors testing ${
|
||||
errorURLs.length
|
||||
} URLs</h1>`;
|
||||
for (let url of errorURLs) {
|
||||
text += `<h5>❌ ${url}</h5>`;
|
||||
text += `<pre>${message.data.error[url]}</pre>`;
|
||||
}
|
||||
}
|
||||
if (
|
||||
Object.keys(message.data.error).length === 0 &&
|
||||
Object.keys(message.data.failing).length === 0
|
||||
) {
|
||||
text += `<p><b>🎉 All (${
|
||||
message.data.working.length
|
||||
} URLs passed the budget. </b></p>`;
|
||||
}) URLs passed the budget. </b></p>`;
|
||||
text += `<p><b>${get(this.options, 'name', '') +
|
||||
'</b> '}${getBrowserData(this.browserData)}</p>`;
|
||||
}
|
||||
if (!this.waitForUpload) {
|
||||
const room = get(options, 'rooms.budget', options.room);
|
||||
await send(options.host, room, options.accessToken, text);
|
||||
} else {
|
||||
this.budgetText = text;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'gcs.finished':
|
||||
case 'ftp.finished':
|
||||
case 's3.finished': {
|
||||
if (this.waitForUpload && options.messages.indexOf('budget') > -1) {
|
||||
const room = get(options, 'rooms.budget', options.room);
|
||||
await send(options.host, room, options.accessToken, text);
|
||||
await send(options.host, room, options.accessToken, this.budgetText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue