-
Notifications
You must be signed in to change notification settings - Fork 132
Add test sharding, proactive clean, and retry logic for self-hosted CI #1171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c37c57f
a7219b3
bc0f282
b8f03ec
13db810
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,6 +99,14 @@ def __filter(cases_) -> typing.List[TestCase]: | |
| skipped_cases += example_cases | ||
| cases = [case for case in cases if case not in example_cases] | ||
|
|
||
| if ARG("shard") is not None: | ||
| parts = ARG("shard").split("/") | ||
| if len(parts) != 2 or not all(p.isdigit() for p in parts) or int(parts[1]) < 1 or not 1 <= int(parts[0]) <= int(parts[1]): | ||
| raise MFCException(f"Invalid --shard '{ARG('shard')}': expected 'i/n' with 1 <= i <= n (e.g., '1/2').") | ||
sbryngelson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| shard_idx, shard_count = int(parts[0]), int(parts[1]) | ||
| skipped_cases += [c for i, c in enumerate(cases) if i % shard_count != shard_idx - 1] | ||
| cases = [c for i, c in enumerate(cases) if i % shard_count == shard_idx - 1] | ||
|
|
||
| if ARG("percent") == 100: | ||
| return cases, skipped_cases | ||
|
|
||
|
|
@@ -182,6 +190,11 @@ def test(): | |
|
|
||
| # Check if we aborted due to high failure rate | ||
| if abort_tests.is_set(): | ||
| # Clean up stale failed_uuids.txt so CI doesn't retry wrong tests | ||
| failed_uuids_path = os.path.join(common.MFC_TEST_DIR, "failed_uuids.txt") | ||
| if os.path.exists(failed_uuids_path): | ||
| os.remove(failed_uuids_path) | ||
|
Comment on lines
+193
to
+196
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unguarded If 🛡️ Proposed fix failed_uuids_path = os.path.join(common.MFC_TEST_DIR, "failed_uuids.txt")
- if os.path.exists(failed_uuids_path):
- os.remove(failed_uuids_path)
+ try:
+ if os.path.exists(failed_uuids_path):
+ os.remove(failed_uuids_path)
+ except OSError:
+ pass🤖 Prompt for AI Agents |
||
|
|
||
| total_completed = nFAIL + nPASS | ||
| cons.print() | ||
| cons.unindent() | ||
|
|
@@ -206,6 +219,15 @@ def test(): | |
| # Build the summary report | ||
| _print_test_summary(nPASS, nFAIL, nSKIP, minutes, seconds, failed_tests, skipped_cases) | ||
|
|
||
| # Write failed UUIDs to file for CI retry logic | ||
| failed_uuids_path = os.path.join(common.MFC_TEST_DIR, "failed_uuids.txt") | ||
| if failed_tests: | ||
| with open(failed_uuids_path, "w") as f: | ||
sbryngelson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for test_info in failed_tests: | ||
| f.write(test_info['uuid'] + "\n") | ||
| elif os.path.exists(failed_uuids_path): | ||
| os.remove(failed_uuids_path) | ||
sbryngelson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| exit(nFAIL) | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.