Skip to content

Commit

Permalink
feat: NoVersioningSystem functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrockhu-codecov committed Jan 26, 2025
1 parent 8963404 commit 079ee13
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 5 deletions.
41 changes: 38 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,41 @@ jobs:
run: |
codecovcli create-report -t ${{ secrets.CODECOV_TOKEN }} --git-service github
build-test-upload-container:
runs-on: ubuntu-latest
container: python:latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python ${{matrix.python-version}}
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m pip install -e .
pip install -r tests/requirements.txt
- name: Test with pytest
run: |
pytest --cov --junitxml=${{matrix.python-version}}junit.xml
- name: Dogfooding codecov-cli
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -v upload-coverage --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}-container
codecovcli upload-coverage --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}-container
- name: Upload artifacts for test-results-processing
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: ${{matrix.python-version}}junit.xml
path: ${{matrix.python-version}}junit.xml
- name: Try git
run: |
git -C . ls-files
build-test-upload:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -101,8 +136,8 @@ jobs:
- name: Dogfooding codecov-cli
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -v do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}
codecovcli do-upload --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}
codecovcli -v upload-coverage --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}
codecovcli upload-coverage --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}
- name: Upload artifacts for test-results-processing
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -158,7 +193,7 @@ jobs:
codecovcli label-analysis --token ${{ secrets.STATIC_TOKEN }} --base-sha=$BASE_SHA --max-wait-time=120
- name: Upload smart-labels
run: |
codecovcli --codecov-yml-path=codecov.yml do-upload --plugin pycoverage --plugin compress-pycoverage --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --flag smart-labels
codecovcli --codecov-yml-path=codecov.yml upload-coverage --plugin pycoverage --plugin compress-pycoverage --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --flag smart-labels
process-test-results:
if: ${{ always() }}
Expand Down
35 changes: 33 additions & 2 deletions codecov_cli/helpers/versioning_systems.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import logging
import subprocess
import typing as t
import os
from pathlib import Path
from pathspec import PathSpec
from shutil import which
import subprocess
import typing as t

from codecov_cli.fallbacks import FallbackFieldEnum
from codecov_cli.helpers.git import parse_git_service, parse_slug
Expand Down Expand Up @@ -145,3 +147,32 @@ def is_available(cls):

def get_network_root(self):
return Path.cwd()

def _get_gitignore(self, root: Path) -> PathSpec:
gitignore = root / ".gitignore"
default_ignore = [
'.git/',
]
if not gitignore.is_file():
return PathSpec.from_lines("gitwildmatch", default_ignore)
else:
return PathSpec.from_lines("gitwildmatch", [*default_ignore, *gitignore.open()])

def list_relevant_files(self, root_folder: t.Optional[Path] = None) -> t.List[str]:
dir_to_use = root_folder or self.get_network_root()
if dir_to_use is None:
raise ValueError("Can't determine root folder")

all_files = set()
for dirpath, _, fnames in os.walk(root_folder):
for fname in fnames:
full_path = os.path.join(dirpath, fname)
all_files.add(full_path)

gitignore = self._get_gitignore(dir_to_use)
filtered_files = []
for file in all_files:
if not gitignore.match_file(Path(file)):
filtered_files.append(file)

return sorted(filtered_files)
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ idna==3.7
# requests
ijson==3.2.3
# via codecov-cli (setup.py)
pathspec==0.12.1
# via codecov-cli (setup.py)
pyyaml==6.0.1
# via codecov-cli (setup.py)
regex==2023.12.25
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"regex",
"sentry-sdk>=2.20.0",
"wrapt>=1.17.2",
"pathspec>=0.12.1",
],
entry_points={
"console_scripts": [
Expand Down

0 comments on commit 079ee13

Please sign in to comment.