Skip to content
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

Fix compatibility on non-git project folders when git is installed on the system #399

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

jamie
Copy link
Contributor

@jamie jamie commented Mar 6, 2024

Hi, I'm not a python person so not sure best way to add test coverage for this, but to kick off a discussion here's the code change.

We run our CI through Jenkins, and to support job fanout our build process involves doing a git checkout on one node, caching the application files, and then subsequent nodes will restore code from that cache and run a subset of our tests. (We currently have a job fanout of around 50.) To reduce the size of the cached blob, we are excluding our .git folder from the cache.

This leads to us hitting a problem uploading our coverage files, because the GitVersioningSystem:

  • says it is_available if git is installed on the system (which it is because we reuse our worker base images)
  • in get_network_root it fails because git rev-parse --show-toplevel is erroring out fatal: not a git repository
  • in list_relevant_files it therefore raises Can't determine root folder and blows up the stack:
<snip>
  File "/home/deploy/.local/lib/python3.7/site-packages/codecov_cli/commands/upload.py", line 256, in do_upload
    handle_no_reports_found=handle_no_reports_found,
  File "/home/deploy/.local/lib/python3.7/site-packages/codecov_cli/services/upload/__init__.py", line 66, in do_upload_logic
    upload_data = collector.generate_upload_data()
  File "/home/deploy/.local/lib/python3.7/site-packages/codecov_cli/services/upload/upload_collector.py", line 145, in generate_upload_data
    network = self.network_finder.find_files()
  File "/home/deploy/.local/lib/python3.7/site-packages/codecov_cli/services/upload/network_finder.py", line 17, in find_files
    return self.versioning_system.list_relevant_files(network_root)
  File "/home/deploy/.local/lib/python3.7/site-packages/codecov_cli/helpers/versioning_systems.py", line 111, in list_relevant_files
    raise ValueError("Can't determine root folder")
ValueError: Can't determine root folder

I'm Patching It Live (thanks for the perl oneliner help, ChatGPT) to get it working for us, and can confirm that this change does successfully prevent GitVersioningSystem from being used, and NoVersioningSystem is treating us fine with just the Path.cwd() check.

@joseph-sentry
Copy link
Contributor

Hi @jamie, thanks for opening this PR and for the thorough explanation of the problem!

These changes look good to me.

It looks like the linting step in the CI failed, you can get rid of that by running make lint and pushing those changes.

@jamie jamie force-pushed the no-.git-compatibility branch from 16fbbf4 to 8313f6f Compare March 6, 2024 22:16
@jamie
Copy link
Contributor Author

jamie commented Mar 6, 2024

@joseph-sentry Cleaned this up.

joseph-sentry
joseph-sentry previously approved these changes Mar 7, 2024
@joseph-sentry
Copy link
Contributor

joseph-sentry commented Mar 7, 2024

This repo requires commits to be signed :(

my preferred way of retroactively signing commits (source):

git rebase --exec 'git commit --amend --no-edit -n -S' <ref of commit until which you want to sign>

this may require a force push to the branch

@jamie jamie force-pushed the no-.git-compatibility branch 3 times, most recently from 150b51f to a9f7eaa Compare March 7, 2024 00:24
@jamie jamie force-pushed the no-.git-compatibility branch from a9f7eaa to ea90503 Compare March 7, 2024 00:24
@jamie
Copy link
Contributor Author

jamie commented Mar 7, 2024

👍 Signed

@joseph-sentry joseph-sentry merged commit c198e38 into codecov:main Mar 7, 2024
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.

2 participants