8000 Test on all OSs by Swatinem · Pull Request #667 · codecov/codecov-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Test on all OSs #667

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

Merged
merged 3 commits into from
Mar 27, 2025
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
16 changes: 6 additions & 10 deletions .github/workflows/ci.yml
8000
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,12 @@ jobs:
codecovcli create-report -t ${{ secrets.CODECOV_TOKEN }} --git-service github

build-test-upload:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.13"
- python-version: "3.12"
- python-version: "3.11"
- python-version: "3.10"
- python-version: "3.9"
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.13", "3.12", "3.11", "3.10", "3.9"]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -97,7 +93,7 @@ jobs:
pip install -r tests/requirements.txt
- name: Test with pytest
run: |
pytest --cov --junitxml=${{matrix.python-version}}junit.xml
pytest --cov --junitxml=${{matrix.os}}-${{matrix.python-version}}junit.xml
env:
CODECOV_ENV: test
- name: Dogfooding codecov-cli
Expand All @@ -109,8 +105,8 @@ jobs:
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: ${{matrix.python-version}}junit.xml
path: ${{matrix.python-version}}junit.xml
name: ${{matrix.os}}-${{matrix.python-version}}junit.xml
path: ${{matrix.os}}-${{matrix.python-version}}junit.xml

process-test-results:
if: ${{ always() }}
Expand Down
2 changes: 1 addition & 1 deletion codecov_cli/commands/process_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,6 @@ def generate_message_payload(
payload.passed += 1
except ParserError as err:
raise click.ClickException(
f"Error parsing {str(result.get_filename(), 'utf8')} with error: {err}"
f"Error parsing {result.get_filename()} with error: {err}"
)
return payload
9 changes: 6 additions & 3 deletions codecov_cli/helpers/folder_searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _is_included(
):
return filename_include_regex.match(path.name) and (
multipart_include_regex is None
or multipart_include_regex.match(str(path.resolve()))
or multipart_include_regex.match(path.resolve().as_posix())
)


Expand All @@ -29,7 +29,8 @@ def _is_excluded(
return (
filename_exclude_regex is not None and filename_exclude_regex.match(path.name)
) or (
multipart_exclude_regex is not None and multipart_exclude_regex.match(str(path))
multipart_exclude_regex is not None
and multipart_exclude_regex.match(path.as_posix())
)


Expand Down Expand Up @@ -69,7 +70,9 @@ def search_files(
dirs_to_remove.union(
directory
for directory in dirnames
if multipart_exclude_regex.match(str(pathlib.Path(dirpath) / directory))
if multipart_exclude_regex.match(
(pathlib.Path(dirpath) / directory).as_posix()
)
)

for directory in dirs_to_remove:
Expand Down
74 changes: 41 additions & 33 deletions codecov_cli/helpers/versioning_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@
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',
"*.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*',
"*.gif",
"*.jpeg",
"*.jpg",
"*.md",
"*.png",
"shunit2*",
]


Expand Down Expand Up @@ -203,12 +203,20 @@ def list_relevant_files(

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),
str(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]
return [
filename
for filename in res.stdout.decode("unicode_escape").strip().split("\n")
if filename
]
44 changes: 24 additions & 20 deletions codecov_cli/plugins/xcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,66 +42,70 @@ def run_preparation(self, collector) -> PreparationPluginReturn:

filename_include_regex = globs_to_regex(["*.profdata"])

matched_paths = [
str(path)
for path in search_files(
matched_paths = list(
search_files(
folder_to_search=self.derived_data_folder,
folders_to_ignore=[],
filename_include_regex=filename_include_regex,
)
]
)

if not matched_paths:
logger.warning("No swift data found.")
return

logger.info(
"Running swift coverage on the following list of files:",
extra=dict(extra_log_attributes=dict(matched_paths=matched_paths)),
extra=dict(
extra_log_attributes=dict(
matched_paths=[p.as_posix() for p in matched_paths]
)
),
)

for path in matched_paths:
self.swiftcov(path, self.app_name)

return PreparationPluginReturn(success=True, messages="")

def swiftcov(self, path, app_name: str):
def swiftcov(self, path: pathlib.Path, app_name: str) -> None:
directory = os.path.dirname(path)
build_dir = pathlib.Path(re.sub("(Build).*", "Build", directory))

for type in ["app", "framework", "xctest"]:
filename_include_regex = re.compile(translate(f"*.{type}"))
matched_dir_paths = [
str(path)
for path in search_files(
folder_to_search=pathlib.Path(build_dir),
folders_to_ignore=[],
filename_include_regex=filename_include_regex,
search_for_directories=True,
)
]
matched_dir_paths = search_files(
folder_to_search=build_dir,
folders_to_ignore=[],
filename_include_regex=filename_include_regex,
search_for_directories=True,
)

for dir_path in matched_dir_paths:
# proj name without extension
proj = pathlib.Path(dir_path).stem
proj = dir_path.stem
if app_name == "" or (app_name.lower() in proj.lower()):
logger.info(f"+ Building reports for {proj} {type}")
proj_path = pathlib.Path(pathlib.Path(dir_path) / proj)
proj_path = dir_path / proj
dest = (
proj_path
if proj_path.is_file()
else pathlib.Path(f"{dir_path}/Contents/MacOS/{proj}")
else dir_path / "Contents/MacOS/{proj}"
)
output_file_name = f"{proj}.{type}.coverage.txt".replace(" ", "")
self.run_llvm_cov(output_file_name, path, dest)

def run_llvm_cov(self, output_file_name, path, dest):
def run_llvm_cov(
self, output_file_name: str, path: pathlib.Path, dest: pathlib.Path
) -> None:
with open(output_file_name, "w") as output_file:
s = subprocess.run(
[
"xcrun",
"llvm-cov",
"show",
"-instr-profile",
path,
str(path),
str(dest),
],
stdout=output_file,
Expand Down
13 changes: 7 additions & 6 deletions codecov_cli/services/upload/file_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ def __init__(
report_type: ReportType = ReportType.COVERAGE,
):
self.search_root = search_root or Path(os.getcwd())
self.folders_to_ignore = list(folders_to_ignore) if folders_to_ignore else []
self.explicitly_listed_files = explicitly_listed_files or None
self.folders_to_ignore = (
[f.as_posix() for f in folders_to_ignore] if folders_to_ignore else []
)
self.explicitly_listed_files = explicitly_listed_files or []
self.disable_search = disable_search
self.report_type: ReportType = report_type

Expand All @@ -223,8 +225,7 @@ def find_files(self) -> List[UploadCollectionResultFile]:
assert regex_patterns_to_include # this is never `None`
files_paths = search_files(
self.search_root,
default_folders_to_ignore
+ [str(folder) for folder in self.folders_to_ignore],
default_folders_to_ignore + self.folders_to_ignore,
filename_include_regex=regex_patterns_to_include,
filename_exclude_regex=regex_patterns_to_exclude,
)
Expand Down Expand Up @@ -252,7 +253,7 @@ def get_user_specified_files(self, regex_patterns_to_exclude: Pattern):
for file in self.explicitly_listed_files:
user_filenames_to_include.append(file.name)
if regex_patterns_to_exclude.match(file.name):
files_excluded_but_user_includes.append(str(file))
files_excluded_but_user_includes.append(file.as_posix())
if files_excluded_but_user_includes:
logger.warning(
"Some files being explicitly added are found in the list of excluded files for upload. We are still going to search for the explicitly added files.",
Expand All @@ -262,7 +263,7 @@ def get_user_specified_files(self, regex_patterns_to_exclude: Pattern):
)
regex_patterns_to_include = globs_to_regex(user_filenames_to_include)
multipart_include_regex = globs_to_regex(
[str(path.resolve()) for path in self.explicitly_listed_files]
[path.resolve().as_posix() for path in self.explicitly_listed_files]
)
user_files_paths = list(
search_files(
Expand Down
2 changes: 1 addition & 1 deletion codecov_cli/services/upload/legacy_upload_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _generate_coverage_files_section(self, upload_data: UploadCollectionResult):
return b"".join(self._format_coverage_file(file) for file in upload_data.files)

def _format_coverage_file(self, file: UploadCollectionResultFile) -> bytes:
header = b"# path=" + file.get_filename() + b"\n"
header = b"# path=" + file.get_filename().encode() + b"\n"
file_content = file.get_content() + b"\n"
file_end = b"<<<<<< EOF\n"

Expand Down
4 changes: 2 additions & 2 deletions codecov_cli/services/upload/upload_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _get_file_fixers(
total_fixed_lines = list(
file_fixer.fixed_lines_without_reason.union(fixed_lines_with_reason)
)
file_fixers[str(file_fixer.path)] = {
file_fixers[file_fixer.path.as_posix()] = {
"eof": file_fixer.eof,
"lines": total_fixed_lines,
}
Expand All @@ -189,7 +189,7 @@ def _get_files(self, upload_data: UploadCollectionResult):
def _format_file(self, file: UploadCollectionResultFile):
format, formatted_content = self._get_format_info(file)
return {
"filename": file.get_filename().decode(),
"filename": file.get_filename(),
"format": format,
"data": formatted_content,
"labels": "",
Expand Down
4 changes: 2 additions & 2 deletions codecov_cli/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class UploadCollectionResultFile(object):
def __init__(self, path: pathlib.Path):
self.path = path

def get_filename(self) -> bytes:
return bytes(self.path)
def get_filename(self) -> str:
return self.path.as_posix()

def get_content(self) -> bytes:
with open(self.path, "rb") as f:
Expand Down
6 changes: 5 additions & 1 deletion tests/helpers/test_args.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
from pathlib import PosixPath
import sys

import click
import pytest

from codecov_cli import __version__
from codecov_cli.helpers.args import get_cli_args
Expand All @@ -28,7 +29,10 @@ def test_get_cli_args():
assert get_cli_args(ctx) == expected


@pytest.mark.skipif(sys.platform == "win32", reason="requires posix platform")
def test_get_cli_args_with_posix():
from pathlib import PosixPath

ctx = click.Context(click.Command("do-upload"))
ctx.obj = {}
ctx.obj["cli_args"] = {
Expand Down
Loading
0