snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
This commit is contained in:
348
e2e-tests/cypress/utils/report.js
Normal file
348
e2e-tests/cypress/utils/report.js
Normal file
@@ -0,0 +1,348 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
/* eslint-disable no-console */
|
||||
|
||||
const axios = require('axios');
|
||||
const fse = require('fs-extra');
|
||||
const dayjs = require('dayjs');
|
||||
const duration = require('dayjs/plugin/duration');
|
||||
dayjs.extend(duration);
|
||||
|
||||
const {MOCHAWESOME_REPORT_DIR, AD_CYCLE_FILE} = require('./constants');
|
||||
|
||||
const MAX_FAILED_TITLES = 5;
|
||||
|
||||
let incrementalDuration = 0;
|
||||
|
||||
function getAllTests(results) {
|
||||
const tests = [];
|
||||
results.forEach((result) => {
|
||||
result.tests.forEach((test) => {
|
||||
incrementalDuration += test.duration;
|
||||
tests.push({...test, incrementalDuration});
|
||||
});
|
||||
|
||||
if (result.suites.length > 0) {
|
||||
getAllTests(result.suites).forEach((test) => tests.push(test));
|
||||
}
|
||||
});
|
||||
|
||||
return tests;
|
||||
}
|
||||
|
||||
function generateStatsFieldValue(stats, failedFullTitles) {
|
||||
const startAt = dayjs(stats.start);
|
||||
const endAt = dayjs(stats.end);
|
||||
const statsDuration = dayjs.duration(endAt.diff(startAt)).format('H:mm:ss');
|
||||
|
||||
let statsFieldValue = `
|
||||
| Key | Value |
|
||||
|:---|:---|
|
||||
| Passing Rate | ${stats.passPercent.toFixed(2)}% |
|
||||
| Duration | ${statsDuration} |
|
||||
| Suites | ${stats.suites} |
|
||||
| Tests | ${stats.tests} |
|
||||
| :white_check_mark: Passed | ${stats.passes} |
|
||||
| :x: Failed | ${stats.failures} |
|
||||
| :fast_forward: Skipped | ${stats.skipped} |
|
||||
`;
|
||||
|
||||
// If present, add full title of failing tests.
|
||||
// Only show per maximum number of failed titles with the last item as "more..." if failing tests are more than that.
|
||||
let failedTests;
|
||||
if (failedFullTitles && failedFullTitles.length > 0) {
|
||||
const re = /[:'"\\]/gi;
|
||||
const failed = failedFullTitles;
|
||||
if (failed.length > MAX_FAILED_TITLES) {
|
||||
failedTests = failed.slice(0, MAX_FAILED_TITLES - 1).map((f) => `- ${f.replace(re, '')}`).join('\n');
|
||||
failedTests += '\n- more...';
|
||||
} else {
|
||||
failedTests = failed.map((f) => `- ${f.replace(re, '')}`).join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
if (failedTests) {
|
||||
statsFieldValue += '###### Failed Tests:\n' + failedTests;
|
||||
}
|
||||
|
||||
return statsFieldValue;
|
||||
}
|
||||
|
||||
function generateShortSummary(report) {
|
||||
const {results, stats} = report;
|
||||
const tests = getAllTests(results);
|
||||
|
||||
const failedFullTitles = tests.filter((t) => t.fail).map((t) => t.fullTitle);
|
||||
const statsFieldValue = generateStatsFieldValue(stats, failedFullTitles);
|
||||
|
||||
// If AD Cycle file is found, we have data from the Automation Dashboard available
|
||||
// We are able to override the run stats with enriched information
|
||||
const adCycle = readJsonFromFile(AD_CYCLE_FILE);
|
||||
if (!(adCycle instanceof Error)) {
|
||||
stats.passes = adCycle.pass;
|
||||
stats.failures = adCycle.fail;
|
||||
stats.tests = adCycle.pass + adCycle.fail;
|
||||
stats.passPercent = 100 * (stats.passes / stats.tests);
|
||||
}
|
||||
|
||||
return {
|
||||
stats,
|
||||
statsFieldValue,
|
||||
};
|
||||
}
|
||||
|
||||
function removeOldGeneratedReports() {
|
||||
[
|
||||
'all.json',
|
||||
'summary.json',
|
||||
'mochawesome.html',
|
||||
].forEach((file) => fse.removeSync(`${MOCHAWESOME_REPORT_DIR}/${file}`));
|
||||
}
|
||||
|
||||
function writeJsonToFile(jsonObject, filename, dir) {
|
||||
fse.writeJson(`${dir}/${filename}`, jsonObject).
|
||||
then(() => console.log('Successfully written:', filename)).
|
||||
catch((err) => console.error(err));
|
||||
}
|
||||
|
||||
function readJsonFromFile(file) {
|
||||
try {
|
||||
return fse.readJsonSync(file);
|
||||
} catch (err) {
|
||||
return {err};
|
||||
}
|
||||
}
|
||||
|
||||
const result = [
|
||||
{status: 'Passed', priority: 'none', cutOff: 100, color: '#43A047'},
|
||||
{status: 'Failed', priority: 'low', cutOff: 98, color: '#FFEB3B'},
|
||||
{status: 'Failed', priority: 'medium', cutOff: 95, color: '#FF9800'},
|
||||
{status: 'Failed', priority: 'high', cutOff: 0, color: '#F44336'},
|
||||
];
|
||||
|
||||
function generateTestReport(summary, isUploadedToS3, reportLink, environment, testCycleKey) {
|
||||
const {
|
||||
FULL_REPORT,
|
||||
TEST_CYCLE_LINK_PREFIX,
|
||||
MM_ENV,
|
||||
SERVER_TYPE,
|
||||
BUILD_ID,
|
||||
AUTOMATION_DASHBOARD_FRONTEND_URL,
|
||||
} = process.env;
|
||||
const {statsFieldValue, stats} = summary;
|
||||
const {
|
||||
cypress_version: cypressVersion,
|
||||
browser_name: browserName,
|
||||
browser_version: browserVersion,
|
||||
headless,
|
||||
os_name: osName,
|
||||
os_version: osVersion,
|
||||
node_version: nodeVersion,
|
||||
} = environment;
|
||||
|
||||
let testResult;
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
if (stats.passPercent >= result[i].cutOff) {
|
||||
testResult = result[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const title = generateTitle();
|
||||
const runnerEnvValue = `cypress@${cypressVersion} | node@${nodeVersion} | ${browserName}@${browserVersion}${headless ? ' (headless)' : ''} | ${osName}@${osVersion}`;
|
||||
|
||||
if (FULL_REPORT === 'true') {
|
||||
let reportField;
|
||||
if (isUploadedToS3) {
|
||||
reportField = {
|
||||
short: false,
|
||||
title: 'Test Report',
|
||||
value: `[Link to the report](${reportLink})`,
|
||||
};
|
||||
}
|
||||
|
||||
let testCycleField;
|
||||
if (testCycleKey) {
|
||||
testCycleField = {
|
||||
short: false,
|
||||
title: 'Test Execution',
|
||||
value: `[Recorded test executions](${TEST_CYCLE_LINK_PREFIX}${testCycleKey})`,
|
||||
};
|
||||
}
|
||||
|
||||
let serverEnvField;
|
||||
if (MM_ENV) {
|
||||
serverEnvField = {
|
||||
short: false,
|
||||
title: 'Test Server Override',
|
||||
value: MM_ENV,
|
||||
};
|
||||
}
|
||||
|
||||
let serverTypeField;
|
||||
if (SERVER_TYPE) {
|
||||
serverTypeField = {
|
||||
short: false,
|
||||
title: 'Test Server',
|
||||
value: SERVER_TYPE,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
username: 'Cypress UI Test',
|
||||
icon_url: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
||||
attachments: [{
|
||||
color: testResult.color,
|
||||
author_name: 'Webapp End-to-end Testing',
|
||||
author_icon: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
||||
author_link: 'https://www.mattermost.com',
|
||||
title,
|
||||
fields: [
|
||||
{
|
||||
short: false,
|
||||
title: 'Environment',
|
||||
value: runnerEnvValue,
|
||||
},
|
||||
serverTypeField,
|
||||
serverEnvField,
|
||||
reportField,
|
||||
testCycleField,
|
||||
{
|
||||
short: false,
|
||||
title: `Key metrics (required support: ${testResult.priority})`,
|
||||
value: statsFieldValue,
|
||||
},
|
||||
],
|
||||
}],
|
||||
};
|
||||
}
|
||||
|
||||
let quickSummary = `${stats.passPercent.toFixed(2)}% (${stats.passes}/${stats.tests}) in ${stats.suites} suites`;
|
||||
if (isUploadedToS3) {
|
||||
quickSummary = `[${quickSummary}](${reportLink})`;
|
||||
}
|
||||
|
||||
let testCycleLink = '';
|
||||
if (testCycleKey) {
|
||||
testCycleLink = testCycleKey ? `| [Recorded test executions](${TEST_CYCLE_LINK_PREFIX}${testCycleKey})` : '';
|
||||
}
|
||||
|
||||
const automationDashboardField = AUTOMATION_DASHBOARD_FRONTEND_URL ? `| [Automation Dashboard](${AUTOMATION_DASHBOARD_FRONTEND_URL}/cycle/${BUILD_ID})` : '';
|
||||
|
||||
const rollingReleaseMatchRegex = BUILD_ID.match(/-rolling(?<version>[^-]+)-/);
|
||||
const rollingReleaseFrom = rollingReleaseMatchRegex?.groups?.version;
|
||||
const rollingReleaseFromField = rollingReleaseFrom ? `\nRolling release upgrade from: ${rollingReleaseFrom}` : '';
|
||||
|
||||
const startAt = dayjs(stats.start);
|
||||
const endAt = dayjs(stats.end);
|
||||
const statsDuration = dayjs.duration(endAt.diff(startAt)).format('H:mm:ss');
|
||||
|
||||
return {
|
||||
username: 'Cypress UI Test',
|
||||
icon_url: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
||||
attachments: [{
|
||||
color: testResult.color,
|
||||
author_name: 'Webapp End-to-end Testing',
|
||||
author_icon: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
||||
author_link: 'https://www.mattermost.com/',
|
||||
title,
|
||||
text: `${quickSummary} | ${statsDuration} ${testCycleLink} ${automationDashboardField}\n${runnerEnvValue}${SERVER_TYPE ? '\nTest server: ' + SERVER_TYPE : ''}${rollingReleaseFromField}${MM_ENV ? '\nTest server override: ' + MM_ENV : ''}`,
|
||||
}],
|
||||
};
|
||||
}
|
||||
|
||||
function generateTitle() {
|
||||
const {
|
||||
BRANCH,
|
||||
MM_DOCKER_IMAGE,
|
||||
MM_DOCKER_TAG,
|
||||
PULL_REQUEST,
|
||||
RELEASE_DATE,
|
||||
TYPE,
|
||||
} = process.env;
|
||||
|
||||
let dockerImageLink = '';
|
||||
if (MM_DOCKER_IMAGE && MM_DOCKER_TAG) {
|
||||
dockerImageLink = ` with [${MM_DOCKER_IMAGE}:${MM_DOCKER_TAG}](https://hub.docker.com/r/mattermostdevelopment/${MM_DOCKER_IMAGE}/tags?name=${MM_DOCKER_TAG})`;
|
||||
}
|
||||
|
||||
let releaseDate = '';
|
||||
if (RELEASE_DATE) {
|
||||
releaseDate = ` for ${RELEASE_DATE}`;
|
||||
}
|
||||
|
||||
let title;
|
||||
|
||||
switch (TYPE) {
|
||||
case 'PR':
|
||||
title = `E2E for Pull Request Build: [${BRANCH}](${PULL_REQUEST})${dockerImageLink}`;
|
||||
break;
|
||||
case 'RELEASE':
|
||||
title = `E2E for Release Build${dockerImageLink}${releaseDate}`;
|
||||
break;
|
||||
case 'MASTER':
|
||||
title = `E2E for Master Nightly Build (Prod tests)${dockerImageLink}`;
|
||||
break;
|
||||
case 'MASTER_UNSTABLE':
|
||||
title = `E2E for Master Nightly Build (Unstable tests)${dockerImageLink}`;
|
||||
break;
|
||||
case 'CLOUD':
|
||||
title = `E2E for Cloud Build (Prod tests)${dockerImageLink}${releaseDate}`;
|
||||
break;
|
||||
case 'CLOUD_UNSTABLE':
|
||||
title = `E2E for Cloud Build (Unstable tests)${dockerImageLink}`;
|
||||
break;
|
||||
default:
|
||||
title = `E2E for Build${dockerImageLink}`;
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
function generateDiagnosticReport(summary, serverInfo) {
|
||||
const {BRANCH, BUILD_ID} = process.env;
|
||||
|
||||
return {
|
||||
username: 'Cypress UI Test',
|
||||
icon_url: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
||||
attachments: [{
|
||||
color: '#43A047',
|
||||
author_name: 'Cypress UI Test',
|
||||
author_icon: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
||||
author_link: 'https://community.mattermost.com/core/channels/ui-test-automation',
|
||||
title: `Cypress UI Test Automation #${BUILD_ID}, **${BRANCH}** branch`,
|
||||
fields: [{
|
||||
short: false,
|
||||
value: `Start: **${summary.stats.start}**\nEnd: **${summary.stats.end}**\nUser ID: **${serverInfo.userId}**\nTeam ID: **${serverInfo.teamId}**`,
|
||||
}],
|
||||
}],
|
||||
};
|
||||
}
|
||||
|
||||
async function sendReport(name, url, data) {
|
||||
const requestOptions = {method: 'POST', url, data};
|
||||
|
||||
try {
|
||||
const response = await axios(requestOptions);
|
||||
|
||||
if (response.data) {
|
||||
console.log(`Successfully sent ${name}.`);
|
||||
}
|
||||
return response;
|
||||
} catch (er) {
|
||||
console.log(`Something went wrong while sending ${name}.`, er);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateDiagnosticReport,
|
||||
generateShortSummary,
|
||||
generateTestReport,
|
||||
getAllTests,
|
||||
removeOldGeneratedReports,
|
||||
sendReport,
|
||||
readJsonFromFile,
|
||||
writeJsonToFile,
|
||||
};
|
||||
Reference in New Issue
Block a user