Skip to content

Commit

Permalink
Merge branch 'e2e/do-not-fail-exceution-if-one-test-failed' into vit-…
Browse files Browse the repository at this point in the history
…51248copy
  • Loading branch information
mountiny committed Oct 23, 2024
2 parents f251dbc + eeb623d commit 50f641b
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 88 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/e2ePerformanceTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,36 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Check if test has skipped tests
id: checkIfSkippedTestsDetected
run: |
if grep -q '⚠️' "./Host_Machine_Files/\$WORKING_DIRECTORY/output.md"; then
# Create an output to the GH action that the tests were skipped:
echo "skippedTestsDetected=true" >> "$GITHUB_OUTPUT"
else
echo "skippedTestsDetected=false" >> "$GITHUB_OUTPUT"
echo '✅ no skipped tests detected'
fi
env:
GITHUB_TOKEN: ${{ github.token }}

- name: 'Announce skipped tests in Slack'
if: ${{ steps.checkIfSkippedTestsDetected.outputs.skippedTestsDetected == 'true' }}
uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
channel: '#e2e-announce',
attachments: [{
color: 'danger',
text: `⚠️ ${process.env.AS_REPO} Some of E2E tests were skipped on <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}> workflow ⚠️`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: 'Announce regression in Slack'
if: ${{ steps.checkIfRegressionDetected.outputs.performanceRegressionDetected == 'true' }}
uses: 8398a7/action-slack@v3
Expand Down
7 changes: 5 additions & 2 deletions src/libs/E2E/tests/appStartTimeTest.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import Config from 'react-native-config';
import type {NativeConfig} from 'react-native-config';
import type {PerformanceEntry} from 'react-native-performance';
import E2ELogin from '@libs/E2E/actions/e2eLogin';
import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded';
import E2EClient from '@libs/E2E/client';
import getConfigValueOrThrow from '@libs/E2E/utils/getConfigValueOrThrow';
import Performance from '@libs/Performance';

const test = () => {
const test = (config: NativeConfig) => {
const name = getConfigValueOrThrow('name', config);
// check for login (if already logged in the action will simply resolve)
E2ELogin().then((neededLogin) => {
if (neededLogin) {
Expand All @@ -25,7 +28,7 @@ const test = () => {
metrics.map((metric) =>
E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: `App start ${metric.name}`,
name: `${name} ${metric.name}`,
metric: metric.duration,
unit: 'ms',
}),
Expand Down
5 changes: 3 additions & 2 deletions src/libs/E2E/tests/chatOpeningTest.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const test = (config: NativeConfig) => {
console.debug('[E2E] Logging in for chat opening');

const reportID = getConfigValueOrThrow('reportID', config);
const name = getConfigValueOrThrow('name', config);

E2ELogin().then((neededLogin) => {
if (neededLogin) {
Expand Down Expand Up @@ -48,7 +49,7 @@ const test = (config: NativeConfig) => {
if (entry.name === CONST.TIMING.CHAT_RENDER) {
E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Chat opening',
name: `${name} Chat opening`,
metric: entry.duration,
unit: 'ms',
})
Expand All @@ -64,7 +65,7 @@ const test = (config: NativeConfig) => {
if (entry.name === CONST.TIMING.OPEN_REPORT) {
E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Chat TTI',
name: `${name} Chat TTI`,
metric: entry.duration,
unit: 'ms',
})
Expand Down
3 changes: 2 additions & 1 deletion src/libs/E2E/tests/linkingTest.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const test = (config: NativeConfig) => {
const reportID = getConfigValueOrThrow('reportID', config);
const linkedReportID = getConfigValueOrThrow('linkedReportID', config);
const linkedReportActionID = getConfigValueOrThrow('linkedReportActionID', config);
const name = getConfigValueOrThrow('name', config);

E2ELogin().then((neededLogin) => {
if (neededLogin) {
Expand Down Expand Up @@ -74,7 +75,7 @@ const test = (config: NativeConfig) => {

E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Comment linking',
name,
metric: entry.duration,
unit: 'ms',
});
Expand Down
10 changes: 7 additions & 3 deletions src/libs/E2E/tests/openSearchRouterTest.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import type {NativeConfig} from 'react-native-config';
import Config from 'react-native-config';
import * as E2EGenericPressableWrapper from '@components/Pressable/GenericPressable/index.e2e';
import E2ELogin from '@libs/E2E/actions/e2eLogin';
import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded';
import E2EClient from '@libs/E2E/client';
import getConfigValueOrThrow from '@libs/E2E/utils/getConfigValueOrThrow';
import getPromiseWithResolve from '@libs/E2E/utils/getPromiseWithResolve';
import Performance from '@libs/Performance';
import CONST from '@src/CONST';

const test = () => {
const test = (config: NativeConfig) => {
// check for login (if already logged in the action will simply resolve)
console.debug('[E2E] Logging in for new search router');

const name = getConfigValueOrThrow('name', config);

E2ELogin().then((neededLogin: boolean): Promise<Response> | undefined => {
if (neededLogin) {
return waitForAppLoaded().then(() =>
Expand Down Expand Up @@ -59,7 +63,7 @@ const test = () => {
if (entry.name === CONST.TIMING.SEARCH_ROUTER_RENDER) {
E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Open Search Router TTI',
name: `${name} Open Search Router TTI`,
metric: entry.duration,
unit: 'ms',
})
Expand All @@ -75,7 +79,7 @@ const test = () => {
if (entry.name === CONST.TIMING.LOAD_SEARCH_OPTIONS) {
E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Load Search Options',
name: `${name} Load Search Options`,
metric: entry.duration,
unit: 'ms',
})
Expand Down
5 changes: 3 additions & 2 deletions src/libs/E2E/tests/reportTypingTest.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const test = (config: NativeConfig) => {

const reportID = getConfigValueOrThrow('reportID', config);
const message = getConfigValueOrThrow('message', config);
const name = getConfigValueOrThrow('name', config);

E2ELogin().then((neededLogin) => {
if (neededLogin) {
Expand All @@ -45,7 +46,7 @@ const test = (config: NativeConfig) => {
if (entry.name === CONST.TIMING.MESSAGE_SENT) {
E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Message sent',
name: `${name} Message sent`,
metric: entry.duration,
unit: 'ms',
}).then(messageSentResolve);
Expand Down Expand Up @@ -77,7 +78,7 @@ const test = (config: NativeConfig) => {

E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: 'Composer typing rerender count',
name: `${name} Composer typing rerender count`,
metric: rerenderCount,
unit: 'renders',
})
Expand Down
13 changes: 10 additions & 3 deletions tests/e2e/compare/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,23 @@ function compareResults(baselineEntries: Metric | string, compareEntries: Metric
};
}

export default (main: Metric | string, delta: Metric | string, outputFile: string, outputFormat = 'all', metricForTest = {}) => {
type Options = {
outputFile: string;
outputFormat: 'console' | 'markdown' | 'all';
metricForTest: Record<string, Unit>;
skippedTests: string[];
};

export default (main: Metric | string, delta: Metric | string, {outputFile, outputFormat = 'all', metricForTest = {}, skippedTests}: Options) => {
// IMPORTANT NOTE: make sure you are passing the main/baseline results first, then the delta/compare results:
const outputData = compareResults(main, delta, metricForTest);

if (outputFormat === 'console' || outputFormat === 'all') {
printToConsole(outputData);
printToConsole(outputData, skippedTests);
}

if (outputFormat === 'markdown' || outputFormat === 'all') {
return writeToMarkdown(outputFile, outputData);
return writeToMarkdown(outputFile, outputData, skippedTests);
}
};
export {compareResults};
6 changes: 5 additions & 1 deletion tests/e2e/compare/output/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const printRegularLine = (entry: Entry) => {
/**
* Prints the result simply to console.
*/
export default (data: Data) => {
export default (data: Data, skippedTests: string[]) => {
// No need to log errors or warnings as these were be logged on the fly
console.debug('');
console.debug('❇️ Performance comparison results:');
Expand All @@ -38,6 +38,10 @@ export default (data: Data) => {
data.meaningless.forEach(printRegularLine);

console.debug('');

if (skippedTests.length > 0) {
console.debug(`⚠️ Some tests did not pass successfully, so some results are omitted from final report: ${skippedTests.join(', ')}`);
}
};

export type {Data, Entry};
10 changes: 7 additions & 3 deletions tests/e2e/compare/output/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const buildSummaryTable = (entries: Entry[], collapse = false) => {
return collapse ? collapsibleSection('Show entries', content) : content;
};

const buildMarkdown = (data: Data) => {
const buildMarkdown = (data: Data, skippedTests: string[]) => {
let result = '## Performance Comparison Report 📊';

if (data.errors?.length) {
Expand All @@ -92,6 +92,10 @@ const buildMarkdown = (data: Data) => {
result += `\n${buildDetailsTable(data.meaningless)}`;
result += '\n';

if (skippedTests.length > 0) {
result += `⚠️ Some tests did not pass successfully, so some results are omitted from final report: ${skippedTests.join(', ')}`;
}

return result;
};

Expand All @@ -109,8 +113,8 @@ const writeToFile = (filePath: string, content: string) =>
throw error;
});

const writeToMarkdown = (filePath: string, data: Data) => {
const markdown = buildMarkdown(data);
const writeToMarkdown = (filePath: string, data: Data, skippedTests: string[]) => {
const markdown = buildMarkdown(data, skippedTests);
return writeToFile(filePath, markdown).catch((error) => {
console.error(error);
throw error;
Expand Down
Loading

0 comments on commit 50f641b

Please sign in to comment.