CI failure #190242
Replies: 5 comments 1 reply
-
🧪 Debugging CI Failures That Don’t Reproduce LocallyThis situation is very common: everything passes locally, but CI fails across multiple environments. The key is understanding that CI != your local machine. Let’s break this down properly. 🔍 What’s Likely HappeningYour failures across:
→ strongly suggest environment differences, not random failures. 🧠 1. Always Start With CI Logs (Most Important Step)Before guessing, open one failing job and:
💡 Tip: GitHub collapses logs — expand everything. 🎨 2. Matplotlib Issues (Very Common in CI)CI environments are headless (no GUI), so rendering fails. Fix it globally: import matplotlib
matplotlib.use("Agg")Or set environment variable in your workflow: Also consider: import matplotlib.pyplot as plt
plt.switch_backend("Agg")🪟 3. Cross-Platform Issues (Windows/macOS/Linux)Path ProblemsAvoid hardcoded paths: ❌ "data/file.txt" from pathlib import Path
Path("data") / "file.txt"Line Endings (CRLF vs LF)Windows uses CRLF, Linux/macOS use LF. If you compare strings/files:
text.replace("\r\n", "\n")Case SensitivityLinux is case-sensitive, Windows is not: ❌ "File.txt" vs "file.txt" 📦 4. Minimum Versions Job (Very Important)This is often the real issue. CI installs the lowest allowed dependency versions, while locally you use latest. Reproduce locally:pip install -e .[test] --upgrade --upgrade-strategy=only-if-neededOr even better: pip install "numpy==<min_version>" "matplotlib==<min_version>"💡 Check CI logs to see exact versions installed. 🧪 5. Hidden State / Environment DifferencesCI is clean. Your local machine is not. Common issues:
Debug tip:Print environment inside tests: import os
print(os.getcwd())
print(os.environ)🧵 6. Parallelism IssuesCI may run tests in parallel. If tests depend on shared state:
→ they may fail randomly 🐳 7. Reproduce CI Locally (Best Technique)Use actThis runs your GitHub Actions workflow locally using Docker. 📎 8. Upload Logs as ArtifactsModify your workflow to upload full test logs: - name: Upload logs
uses: actions/upload-artifact@v4
with:
name: pytest-logs
path: logs/This makes debugging MUCH easier. 📉 9. Coverage Drop (Codecov)0.10% drop is negligible. Possible reasons:
Temporary workaround: fail_ci_if_error: false🧭 Debug Strategy (TL;DR)
✅ Final ThoughtIf tests pass locally but fail everywhere in CI, it's almost always: If you can share one full traceback from CI, the exact issue can usually be pinpointed very quickly. |
Beta Was this translation helpful? Give feedback.
-
|
IklilIlm's answer covers most of it. Also for the matplotlib failures on macOS specifically, sometimes just setting If you can paste the actual traceback from one of the macOS failures that'd make it a lot easier to pinpoint. |
Beta Was this translation helpful? Give feedback.
-
|
This is a pretty common CI vs local mismatch issue. If it passes locally but fails across multiple CI environments (Windows/macOS/Linux), it’s usually one of these:
A few things that might help narrow it down:
CI logs tend to bury the actual error, so focusing on the first real failure in one job usually helps a lot. I’ve been working on a small tool to extract the actual error + suggest fixes from CI logs — happy to share if useful. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @Aryan-Gore , Your issue is classic "works locally, fails on CI" — here's exactly what to fix for each failure.
import matplotlib Or set it via environment variable in your workflow YAML: env:
pip freeze > requirements-ci.txt
Also check if you're using any f-strings or syntax that behaves differently on Python 3.12 — it removed some deprecated features.
If no constraints file exists, manually install the oldest versions listed in your setup.cfg or pyproject.toml.
👍 If this helped you, please mark it as the answer — it helps others in the community who run into the same issue find the solution faster! |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Why are you starting this discussion?
Question
What GitHub Actions topic or product is this about?
General
Discussion Details
Hi,
I’m currently facing issues with failing CI checks on my PR and I’m unable to identify the exact cause.
Failing checks:
What I’ve tried:
pre-commit run --all-filespytestlocally (tests pass on my system)However, I’m unable to reproduce these CI failures locally.
Request:
Could you please guide me on:
Thanks for your time!
Beta Was this translation helpful? Give feedback.
All reactions