Skip to content

Commit 6fc5da7

Browse files
committed
e2e: allow tests failure
1 parent df3e1e4 commit 6fc5da7

10 files changed

+170
-87
lines changed

.github/workflows/e2ePerformanceTests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,36 @@ jobs:
237237
env:
238238
GITHUB_TOKEN: ${{ github.token }}
239239

240+
- name: Check if test has skipped tests
241+
id: checkIfSkippedTestsDetected
242+
run: |
243+
if grep -q '⚠️' "./Host_Machine_Files/\$WORKING_DIRECTORY/output.md"; then
244+
# Create an output to the GH action that the tests were skipped:
245+
echo "skippedTestsDetected=true" >> "$GITHUB_OUTPUT"
246+
else
247+
echo "skippedTestsDetected=false" >> "$GITHUB_OUTPUT"
248+
echo '✅ no skipped tests detected'
249+
fi
250+
env:
251+
GITHUB_TOKEN: ${{ github.token }}
252+
253+
- name: 'Announce skipped tests in Slack'
254+
if: ${{ steps.checkIfSkippedTestsDetected.outputs.skippedTestsDetected == 'true' }}
255+
uses: 8398a7/action-slack@v3
256+
with:
257+
status: custom
258+
custom_payload: |
259+
{
260+
channel: '#e2e-announce',
261+
attachments: [{
262+
color: 'danger',
263+
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 ⚠️`,
264+
}]
265+
}
266+
env:
267+
GITHUB_TOKEN: ${{ github.token }}
268+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
269+
240270
- name: 'Announce regression in Slack'
241271
if: ${{ steps.checkIfRegressionDetected.outputs.performanceRegressionDetected == 'true' }}
242272
uses: 8398a7/action-slack@v3

src/libs/E2E/tests/appStartTimeTest.e2e.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import Config from 'react-native-config';
2+
import type {NativeConfig} from 'react-native-config';
23
import type {PerformanceEntry} from 'react-native-performance';
34
import E2ELogin from '@libs/E2E/actions/e2eLogin';
45
import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded';
56
import E2EClient from '@libs/E2E/client';
7+
import getConfigValueOrThrow from '@libs/E2E/utils/getConfigValueOrThrow';
68
import Performance from '@libs/Performance';
79

8-
const test = () => {
10+
const test = (config: NativeConfig) => {
11+
const name = getConfigValueOrThrow('name', config);
912
// check for login (if already logged in the action will simply resolve)
1013
E2ELogin().then((neededLogin) => {
1114
if (neededLogin) {
@@ -25,7 +28,7 @@ const test = () => {
2528
metrics.map((metric) =>
2629
E2EClient.submitTestResults({
2730
branch: Config.E2E_BRANCH,
28-
name: `App start ${metric.name}`,
31+
name: `${name} ${metric.name}`,
2932
metric: metric.duration,
3033
unit: 'ms',
3134
}),

src/libs/E2E/tests/chatOpeningTest.e2e.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const test = (config: NativeConfig) => {
1515
console.debug('[E2E] Logging in for chat opening');
1616

1717
const reportID = getConfigValueOrThrow('reportID', config);
18+
const name = getConfigValueOrThrow('name', config);
1819

1920
E2ELogin().then((neededLogin) => {
2021
if (neededLogin) {
@@ -48,7 +49,7 @@ const test = (config: NativeConfig) => {
4849
if (entry.name === CONST.TIMING.CHAT_RENDER) {
4950
E2EClient.submitTestResults({
5051
branch: Config.E2E_BRANCH,
51-
name: 'Chat opening',
52+
name: `${name} Chat opening`,
5253
metric: entry.duration,
5354
unit: 'ms',
5455
})
@@ -64,7 +65,7 @@ const test = (config: NativeConfig) => {
6465
if (entry.name === CONST.TIMING.OPEN_REPORT) {
6566
E2EClient.submitTestResults({
6667
branch: Config.E2E_BRANCH,
67-
name: 'Chat TTI',
68+
name: `${name} Chat TTI`,
6869
metric: entry.duration,
6970
unit: 'ms',
7071
})

src/libs/E2E/tests/linkingTest.e2e.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const test = (config: NativeConfig) => {
2424
const reportID = getConfigValueOrThrow('reportID', config);
2525
const linkedReportID = getConfigValueOrThrow('linkedReportID', config);
2626
const linkedReportActionID = getConfigValueOrThrow('linkedReportActionID', config);
27+
const name = getConfigValueOrThrow('name', config);
2728

2829
E2ELogin().then((neededLogin) => {
2930
if (neededLogin) {
@@ -74,7 +75,7 @@ const test = (config: NativeConfig) => {
7475

7576
E2EClient.submitTestResults({
7677
branch: Config.E2E_BRANCH,
77-
name: 'Comment linking',
78+
name,
7879
metric: entry.duration,
7980
unit: 'ms',
8081
});

src/libs/E2E/tests/openSearchRouterTest.e2e.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
import type {NativeConfig} from 'react-native-config';
12
import Config from 'react-native-config';
23
import E2ELogin from '@libs/E2E/actions/e2eLogin';
34
import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded';
45
import E2EClient from '@libs/E2E/client';
6+
import getConfigValueOrThrow from '@libs/E2E/utils/getConfigValueOrThrow';
57
import getPromiseWithResolve from '@libs/E2E/utils/getPromiseWithResolve';
68
import Performance from '@libs/Performance';
79
import CONST from '@src/CONST';
810

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

15+
const name = getConfigValueOrThrow('name', config);
16+
1317
E2ELogin().then((neededLogin: boolean): Promise<Response> | undefined => {
1418
if (neededLogin) {
1519
return waitForAppLoaded().then(() =>
@@ -35,7 +39,7 @@ const test = () => {
3539
if (entry.name === CONST.TIMING.SEARCH_ROUTER_RENDER) {
3640
E2EClient.submitTestResults({
3741
branch: Config.E2E_BRANCH,
38-
name: 'Open Search Router TTI',
42+
name: `${name} Open Search Router TTI`,
3943
metric: entry.duration,
4044
unit: 'ms',
4145
})
@@ -51,7 +55,7 @@ const test = () => {
5155
if (entry.name === CONST.TIMING.LOAD_SEARCH_OPTIONS) {
5256
E2EClient.submitTestResults({
5357
branch: Config.E2E_BRANCH,
54-
name: 'Load Search Options',
58+
name: `${name} Load Search Options`,
5559
metric: entry.duration,
5660
unit: 'ms',
5761
})

src/libs/E2E/tests/reportTypingTest.e2e.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const test = (config: NativeConfig) => {
2121

2222
const reportID = getConfigValueOrThrow('reportID', config);
2323
const message = getConfigValueOrThrow('message', config);
24+
const name = getConfigValueOrThrow('name', config);
2425

2526
E2ELogin().then((neededLogin) => {
2627
if (neededLogin) {
@@ -45,7 +46,7 @@ const test = (config: NativeConfig) => {
4546
if (entry.name === CONST.TIMING.MESSAGE_SENT) {
4647
E2EClient.submitTestResults({
4748
branch: Config.E2E_BRANCH,
48-
name: 'Message sent',
49+
name: `${name} Message sent`,
4950
metric: entry.duration,
5051
unit: 'ms',
5152
}).then(messageSentResolve);
@@ -77,7 +78,7 @@ const test = (config: NativeConfig) => {
7778

7879
E2EClient.submitTestResults({
7980
branch: Config.E2E_BRANCH,
80-
name: 'Composer typing rerender count',
81+
name: `${name} Composer typing rerender count`,
8182
metric: rerenderCount,
8283
unit: 'renders',
8384
})

tests/e2e/compare/compare.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,23 @@ function compareResults(baselineEntries: Metric | string, compareEntries: Metric
9191
};
9292
}
9393

94-
export default (main: Metric | string, delta: Metric | string, outputFile: string, outputFormat = 'all', metricForTest = {}) => {
94+
type Options = {
95+
outputFile: string;
96+
outputFormat: 'console' | 'markdown' | 'all';
97+
metricForTest: Record<string, Unit>;
98+
hasMissingData: boolean;
99+
};
100+
101+
export default (main: Metric | string, delta: Metric | string, {outputFile, outputFormat = 'all', metricForTest = {}, hasMissingData}: Options) => {
95102
// IMPORTANT NOTE: make sure you are passing the main/baseline results first, then the delta/compare results:
96103
const outputData = compareResults(main, delta, metricForTest);
97104

98105
if (outputFormat === 'console' || outputFormat === 'all') {
99-
printToConsole(outputData);
106+
printToConsole(outputData, hasMissingData);
100107
}
101108

102109
if (outputFormat === 'markdown' || outputFormat === 'all') {
103-
return writeToMarkdown(outputFile, outputData);
110+
return writeToMarkdown(outputFile, outputData, hasMissingData);
104111
}
105112
};
106113
export {compareResults};

tests/e2e/compare/output/console.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const printRegularLine = (entry: Entry) => {
2626
/**
2727
* Prints the result simply to console.
2828
*/
29-
export default (data: Data) => {
29+
export default (data: Data, hasMissingData: boolean) => {
3030
// No need to log errors or warnings as these were be logged on the fly
3131
console.debug('');
3232
console.debug('❇️ Performance comparison results:');
@@ -38,6 +38,10 @@ export default (data: Data) => {
3838
data.meaningless.forEach(printRegularLine);
3939

4040
console.debug('');
41+
42+
if (hasMissingData) {
43+
console.debug('⚠️ Some tests did not pass successfully, so some results are omitted from final report');
44+
}
4145
};
4246

4347
export type {Data, Entry};

tests/e2e/compare/output/markdown.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const buildSummaryTable = (entries: Entry[], collapse = false) => {
6767
return collapse ? collapsibleSection('Show entries', content) : content;
6868
};
6969

70-
const buildMarkdown = (data: Data) => {
70+
const buildMarkdown = (data: Data, hasMissingData: boolean) => {
7171
let result = '## Performance Comparison Report 📊';
7272

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

95+
if (hasMissingData) {
96+
result += '⚠️ Some tests did not pass successfully, so some results are omitted from final report';
97+
}
98+
9599
return result;
96100
};
97101

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

112-
const writeToMarkdown = (filePath: string, data: Data) => {
113-
const markdown = buildMarkdown(data);
116+
const writeToMarkdown = (filePath: string, data: Data, hasMissingData: boolean) => {
117+
const markdown = buildMarkdown(data, hasMissingData);
114118
return writeToFile(filePath, markdown).catch((error) => {
115119
console.error(error);
116120
throw error;

0 commit comments

Comments
 (0)