Skip to content

Commit 689fb06

Browse files
committed
fix flaky detector
1 parent 2bb31c4 commit 689fb06

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

.github/workflows/flaky-test-detector.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
paths:
66
- 'packages/browser-integration-tests/suites/**'
7+
branches-ignore:
8+
- master
9+
- develop
710

811
env:
912
HEAD_COMMIT: ${{ github.event.inputs.commit || github.sha }}
@@ -77,5 +80,4 @@ jobs:
7780
working-directory: packages/browser-integration-tests
7881
env:
7982
CHANGED_TEST_PATHS: ${{ steps.changed.outputs.browser_integration_files }}
80-
# Run 50 times when detecting changed test(s), else run all tests 5x
81-
TEST_RUN_COUNT: ${{ steps.changed.outputs.browser_integration == 'true' && 50 || 5 }}
83+
TEST_RUN_COUNT: 'AUTO'

packages/browser-integration-tests/scripts/detectFlakyTests.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,25 @@ ${changedPaths.join('\n')}
2323
}
2424
}
2525

26+
let runCount: number;
27+
if (process.env.TEST_RUN_COUNT === 'AUTO') {
28+
// No test paths detected: run everything 5x
29+
runCount = 5;
30+
31+
if (testPaths.length > 0) {
32+
// Run everything up to 100x, assuming that total runtime is less than 60min.
33+
// We assume an average runtime of 3s per test, times 4 (for different browsers) = 12s per detected testPaths
34+
// We want to keep overall runtime under 30min
35+
const testCount = testPaths.length * 4;
36+
const expectedRuntimePerTestPath = testCount * 3;
37+
const expectedRuntime = Math.floor((30 * 60) / expectedRuntimePerTestPath);
38+
runCount = Math.min(50, Math.max(expectedRuntime, 5));
39+
}
40+
} else {
41+
runCount = parseInt(process.env.TEST_RUN_COUNT || '10');
42+
}
43+
2644
const cwd = path.join(__dirname, '../');
27-
const runCount = parseInt(process.env.TEST_RUN_COUNT || '10');
2845

2946
try {
3047
await new Promise<void>((resolve, reject) => {

0 commit comments

Comments
 (0)