Skip to content
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
2 changes: 2 additions & 0 deletions .github/workflows/ci-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ jobs:
python-version: "3.12"
- name: Install dependencies
run: |
cd codecov-cli
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: |
cd codecov-cli
pytest --cov --junitxml=3.12junit.xml
env:
CODECOV_ENV: test
Expand Down
69 changes: 20 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m pip install -e .
python -m pip install -e codecov-cli
python -m pip install -e prevent-cli
- name: Run command_dump
run: |
python command_dump.py
./command_dump.py
- name: Detect changes on commit
run: |
if [ -n "$(git diff codecovcli_commands)" ]; then
if [ -n "$(git diff codecov-cli/codecovcli_commands prevent-cli/preventcli_commands)" ]; then
echo "Please run `python command_dump.py` before submitting, or install the hooks"
echo "$(git diff codecovcli_commands)"
echo "$(git diff codecov-cli/codecovcli_commands prevent-cli/preventcli_commands)"
exit 1
fi

codecov-startup:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'getsentry' }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -60,6 +60,7 @@ jobs:
with:
python-version: "3.12"
- name: Install CLI
# todo: update this to dogfood prevent cli, maybe try both?
run: |
pip install codecov-cli
- name: Create commit in codecov
Expand Down Expand Up @@ -88,52 +89,22 @@ jobs:
- 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
python -m pip install -e codecov-cli
python -m pip install -e prevent-cli
pip install -r codecov-cli/tests/requirements.txt
- name: Test with pytest
run: |
cd codecov-cli
pytest --cov --junitxml=${{matrix.os}}-${{matrix.python-version}}junit.xml
env:
CODECOV_ENV: test
- name: Dogfooding codecov-cli
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'getsentry' }}
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}}
- name: Upload artifacts for test-results-processing
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: ${{matrix.os}}-${{matrix.python-version}}junit.xml
path: ${{matrix.os}}-${{matrix.python-version}}junit.xml

process-test-results:
if: ${{ always() }}
needs: build-test-upload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 2
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies for Dogfooding
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m pip install -e .
pip install -r tests/requirements.txt
- name: Download all test results
uses: actions/download-artifact@v4
with:
pattern: "*junit.xml"
path: "test_results"
merge-multiple: true

- name: Dogfooding codecov-cli
if: ${{ !cancelled() && github.ref && contains(github.ref, 'pull') }}
codecovcli -v do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag codecovcli
codecovcli do-upload --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag codecovcli
- name: Dogfooding sentry-prevent-cli
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'getsentry' }}
run: |
codecovcli process-test-results --dir test_results --github-token ${{ secrets.GITHUB_TOKEN }}
sentry-prevent-cli -v do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag sentry-prevent-cli
sentry-prevent-cli do-upload --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag sentry-prevent-cli
2 changes: 1 addition & 1 deletion codecov-cli/tests/helpers/test_versioning_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_exotic_git_filenames():

# See <https://github.com/codecov/codecov-action/issues/1550>
assert (
"tests/data/Контроллеры/Пользователь/ГлавныйКонтроллер.php" in found_repo_files
"codecov-cli/tests/data/Контроллеры/Пользователь/ГлавныйКонтроллер.php" in found_repo_files
)


Expand Down
4 changes: 3 additions & 1 deletion codecov-cli/tests/services/upload/test_upload_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def test_generate_upload_data(tmp_path):

file_finder = FileFinder(tmp_path)

network_finder = NetworkFinder(GitVersioningSystem(), False, None, None, None)
network_finder = NetworkFinder(
GitVersioningSystem(), False, None, None, Path("codecov-cli")
)

collector = UploadCollector([], network_finder, file_finder, None)

Expand Down
14 changes: 9 additions & 5 deletions command_dump.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
import subprocess


def command_dump(commands):
def command_dump(commands: list[str], out_path: str):
print(f"Dumping {' '.join(commands)}")
command_docs = subprocess.run(
[*commands, "--help"], capture_output=True
Expand All @@ -16,16 +17,19 @@ def command_dump(commands):

if "Commands:" in split_docs:
sub_commands = [
sub_command.strip() for sub_command in split_docs[index_of + 1 :] if sub_command.strip()
sub_command.strip()
for sub_command in split_docs[index_of + 1 :]
if sub_command.strip()
]
for sub_command in sub_commands:
command_docs = "\n".join(
[command_docs, command_dump([*commands, sub_command])]
[command_docs, command_dump([*commands, sub_command], out_path)]
)

with open("codecovcli_commands", "w") as f:
with open(out_path, "w") as f:
f.write(command_docs)


if __name__ == "__main__":
command_dump(["codecovcli"])
command_dump(["codecovcli"], "codecov-cli/codecovcli_commands")
command_dump(["sentry-prevent-cli"], "prevent-cli/preventcli_commands")
Loading
Loading