⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion codecov_cli/helpers/versioning_systems.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from itertools import chain
import logging
import subprocess
import typing as t
Expand All @@ -10,6 +11,41 @@

logger = logging.getLogger("codecovcli")

IGNORE_DIRS = [
'*.egg-info',
'.DS_Store',
'.circleci',
'.env',
'.envs',
'.git',
'.gitignore',
'.mypy_cache',
'.nvmrc',
'.nyc_output',
'.ruff_cache',
'.venv',
'.venvns',
'.virtualenv',
'.virtualenvs',
'__pycache__',
'bower_components',
'build/lib/',
'jspm_packages',
'node_modules',
'vendor',
'virtualenv',
'virtualenvs',
]

IGNORE_PATHS = [
'*.gif',
'*.jpeg',
'*.jpg',
'*.md',
'*.png',
'shunit2*',
]


class VersioningSystemInterface(ABC):
def __repr__(self) -> str:
Expand Down Expand Up @@ -161,4 +197,18 @@ def get_fallback_value(self, fallback_field: FallbackFieldEnum):
def list_relevant_files(
self, directory: t.Optional[Path] = None, recurse_submodules: bool = False
) -> t.List[str]:
return []
dir_to_use = directory or self.get_network_root()
if dir_to_use is None:
raise ValueError("Can't determine root folder")

cmd = [
"find",
dir_to_use,
*chain.from_iterable(["-name", block, "-prune", "-o"] for block in IGNORE_DIRS),
*chain.from_iterable(["-path", block, "-prune", "-o"] for block in IGNORE_PATHS),
"-type",
"f",
"-print",
]
res = subprocess.run(cmd, capture_output=True)
return [filename for filename in res.stdout.decode("unicode_escape").strip().split("\n") if filename]
23 changes: 18 additions & 5 deletions tests/services/upload/test_upload_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,26 @@ def test_generate_upload_data_with_none_network(
res = collector.generate_upload_data()

mock_logger.debug.assert_any_call("Collecting relevant files")
mock_logger.debug.assert_any_call(
"Found 0 network files to report, (0 without filtering)"
)

mock_logger.info.assert_any_call("Found 1 coverage files to report")
mock_logger.info.assert_any_call("> {}".format(tmp_path / "coverage.xml"))

assert res.network == []
assert len(res.network) > 1
assert len(res.files) == 1
assert len(res.file_fixes) == 0
assert len(res.file_fixes) > 1

@patch("codecov_cli.services.upload.upload_collector.logger")
@patch.object(GitVersioningSystem, "get_network_root", return_value=None)
def test_generate_network_with_no_versioning_system(
mock_get_network_root, mock_logger, tmp_path
):
versioning_system = NoVersioningSystem()
found_files = versioning_system.list_relevant_files()
assert len(found_files) > 1

found_files = versioning_system.list_relevant_files(tmp_path)
assert len(found_files) == 0

(tmp_path / "coverage.xml").touch()
found_files = versioning_system.list_relevant_files(tmp_path)
assert len(found_files) == 1