Skip to content

Add automatic retry mechanism for flaky tests#380

Merged
MaxGhenis merged 18 commits intoPolicyEngine:masterfrom
MaxGhenis:add-test-retry-mechanism
Jul 24, 2025
Merged

Add automatic retry mechanism for flaky tests#380
MaxGhenis merged 18 commits intoPolicyEngine:masterfrom
MaxGhenis:add-test-retry-mechanism

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

This PR adds automatic retry functionality for tests that fail intermittently in CI, addressing issue #379.

Changes

  • Added pytest-rerunfailures plugin to dependencies
  • Configured pytest to automatically retry failed tests up to 2 times with a 5-second delay between retries
  • Updated both setup.py and Makefile to include the retry configuration

Benefits

  • Reduces manual intervention needed when tests fail due to transient issues
  • Improves developer experience by handling intermittent failures gracefully
  • Tests that consistently fail will still fail after retries, so real issues won't be masked

Test Plan

  • Added pytest-rerunfailures to dependencies
  • Updated test command with retry flags
  • CI tests should pass (with retries if needed)

Fixes #379

🤖 Generated with Claude Code

MaxGhenis and others added 2 commits July 22, 2025 16:21
- Add pytest-rerunfailures plugin to dependencies
- Configure pytest to retry failed tests up to 2 times with 5 second delay
- This helps handle intermittent CI failures without manual intervention
- Fixes PolicyEngine#379

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Jul 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.67%. Comparing base (1379b52) to head (bec3554).
Report is 24 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #380      +/-   ##
==========================================
+ Coverage   80.50%   80.67%   +0.17%     
==========================================
  Files         194      194              
  Lines       10038    10036       -2     
  Branches     1058     1057       -1     
==========================================
+ Hits         8081     8097      +16     
+ Misses       1668     1651      -17     
+ Partials      289      288       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Change smoke test job to install policyengine-core without [dev] to get general requirements
- This ensures pytest-rerunfailures is available for all test runs
- Keep retry flags in Makefile only (not in pytest.ini) to avoid issues with jobs that don't have the plugin

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@MaxGhenis MaxGhenis force-pushed the add-test-retry-mechanism branch from 4298382 to c4da58d Compare July 23, 2025 03:18
MaxGhenis and others added 15 commits July 22, 2025 23:22
The smoke tests may have conflicts with the plugin, so disable it explicitly
for those tests while keeping it enabled for the main test suite.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add pip list command to see what pytest packages are installed
to help diagnose the smoke test failures.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This prevents conflicts when installing policyengine-us in smoke tests
while keeping the retry functionality for main test suite.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Python 3.13 appears to have compatibility issues with policyengine-us.
Skip these tests until policyengine-us is updated to support 3.13.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Install HDF5 libraries before installing policyengine-us to fix
tables package build failures on both Ubuntu and Windows.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Pre-install a newer version of tables that has Python 3.13 wheels
to avoid build failures. The old tables==3.9.2 doesn't have 3.13 wheels.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@MaxGhenis MaxGhenis merged commit 8cb79e3 into PolicyEngine:master Jul 24, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI tests occasionally fail and require manual rerun

1 participant