Skip to content

Commit d2c4a0d

Browse files
committed
e2e: allow tests failure
1 parent ca942ca commit d2c4a0d

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
@@ -221,6 +221,36 @@ jobs:
221221
env:
222222
GITHUB_TOKEN: ${{ github.token }}
223223

224+
- name: Check if test has skipped tests
225+
id: checkIfSkippedTestsDetected
226+
run: |
227+
if grep -q '⚠️' "./Host_Machine_Files/\$WORKING_DIRECTORY/output.md"; then
228+
# Create an output to the GH action that the tests were skipped:
229+
echo "skippedTestsDetected=true" >> "$GITHUB_OUTPUT"
230+
else
231+
echo "skippedTestsDetected=false" >> "$GITHUB_OUTPUT"
232+
echo '✅ no skipped tests detected'
233+
fi
234+
env:
235+
GITHUB_TOKEN: ${{ github.token }}
236+
237+
- name: 'Announce skipped tests in Slack'
238+
if: ${{ steps.checkIfSkippedTestsDetected.outputs.skippedTestsDetected == 'true' }}
239+
uses: 8398a7/action-slack@v3
240+
with:
241+
status: custom
242+
custom_payload: |
243+
{
244+
channel: '#e2e-announce',
245+
attachments: [{
246+
color: 'danger',
247+
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 ⚠️`,
248+
}]
249+
}
250+
env:
251+
GITHUB_TOKEN: ${{ github.token }}
252+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
253+
224254
- name: 'Announce regression in Slack'
225255
if: ${{ steps.checkIfRegressionDetected.outputs.performanceRegressionDetected == 'true' }}
226256
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,16 +1,20 @@
1+
import type {NativeConfig} from 'react-native-config';
12
import Config from 'react-native-config';
23
import * as E2EGenericPressableWrapper from '@components/Pressable/GenericPressable/index.e2e';
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 getPromiseWithResolve from '@libs/E2E/utils/getPromiseWithResolve';
79
import Performance from '@libs/Performance';
810
import CONST from '@src/CONST';
911

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

16+
const name = getConfigValueOrThrow('name', config);
17+
1418
E2ELogin().then((neededLogin: boolean): Promise<Response> | undefined => {
1519
if (neededLogin) {
1620
return waitForAppLoaded().then(() =>
@@ -59,7 +63,7 @@ const test = () => {
5963
if (entry.name === CONST.TIMING.SEARCH_ROUTER_RENDER) {
6064
E2EClient.submitTestResults({
6165
branch: Config.E2E_BRANCH,
62-
name: 'Open Search Router TTI',
66+
name: `${name} Open Search Router TTI`,
6367
metric: entry.duration,
6468
unit: 'ms',
6569
})
@@ -75,7 +79,7 @@ const test = () => {
7579
if (entry.name === CONST.TIMING.LOAD_SEARCH_OPTIONS) {
7680
E2EClient.submitTestResults({
7781
branch: Config.E2E_BRANCH,
78-
name: 'Load Search Options',
82+
name: `${name} Load Search Options`,
7983
metric: entry.duration,
8084
unit: 'ms',
8185
})

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)