GitHub Actions integration tests were failing due to port conflicts. The issue occurred because:
- GitHub Actions provides PostgreSQL (port 5432) and Redis (port 6379) as services
- The test setup code attempted to start its own Docker containers on the same ports
- This caused port binding conflicts and test failures
Added environment detection to automatically handle both CI and local development environments:
-
Environment Detection (
tests/integrate/conftest.py)- Added
_detect_github_actions()method that checks for:GITHUB_ACTIONS=trueCI=trueRUNNER_OSenvironment variable
- Added
-
Conditional Container Management
- In GitHub Actions: Skip Docker container creation, use provided services
- In Local Development: Start Docker containers as before
-
Updated Cleanup Logic (
tests/run_tests.sh)- Skip container cleanup in CI environments
- Preserve normal cleanup in local development
The fix was comprehensively tested with 6 test cases covering:
- Environment detection in various CI scenarios
- Container management logic for both environments
- Proper cleanup behavior
# Works as before - containers are started automatically
make test-integration# No changes needed - detection is automatic
- name: Run integration tests
run: python -m pytest tests/integrate/ -vThe fix automatically detects the environment and handles container management appropriately, eliminating port conflicts while maintaining compatibility with existing workflows.