Skip to content

fix: handle missing git in GitHub Actions CI adapter - #796

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/gh-actions-no-git
Open

sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/gh-actions-no-git

Conversation

@sentry

@sentry sentry Bot commented Sep 25, 2026

Copy link
Copy Markdown

This PR addresses a FileNotFoundError that occurred when the codecov-cli was run in a GitHub Actions environment where git was not installed or not in the system's PATH.

The GithubActionsCIAdapter._get_commit_sha() method attempts to determine the parent commit SHA using git rev-parse HEAD^@ when a pull request number is detected. Previously, this subprocess.run call was not wrapped in any error handling. If git was not found, it would lead to an unhandled FileNotFoundError and crash the CLI.

The fix involves wrapping the subprocess.run call in a try/except OSError block. If an OSError (which includes FileNotFoundError) occurs, the CLI will now gracefully fall back to using the GITHUB_SHA environment variable, which is already the intended fallback for other scenarios where the git command might not yield the expected result. This prevents the CLI from crashing and ensures it can still report coverage in environments without git.

Fixes CLI-HB

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
723 1 722 1
View the full list of 1 ❄️ flaky test(s)
api.temp.calculator.test_calculator::test_divide

Flake rate in main: 100.00% (Passed 0 times, Failed 1726 times)

Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

This branch has not been deployed

No deployments
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.

0 participants