Skip to content

Commit 8de4357

Browse files
Merge branch 'main' into codecov-entrypoint
2 parents 491938c + d700630 commit 8de4357

File tree

86 files changed

+2379
-756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2379
-756
lines changed

.github/workflows/build_assets.yml

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Build Compiled Assets
23

34
on:
@@ -18,8 +19,10 @@ jobs:
1819
include:
1920
- os: macos-latest
2021
TARGET: macos
22+
# currently, wrapt pulls the arm64 version instead of the universal one, so the below is a hack
2123
CMD_REQS: >
22-
mkdir -p pip-packages && cd pip-packages && pip wheel --no-cache-dir --no-binary tree_sitter,ijson,charset_normalizer,PyYAML .. && cd .. &&
24+
mkdir -p pip-packages && cd pip-packages && pip wheel --no-cache-dir --no-binary tree_sitter,ijson,charset_normalizer,PyYAML .. &&
25+
rm $(ls | grep wrapt) && pip download wrapt --platform=universal2 --only-binary=:all: && pip install $(ls | grep wrapt) --force-reinstall && cd .. &&
2326
pip install --no-deps --no-index --find-links=pip-packages pip-packages/*
2427
CMD_BUILD: >
2528
STATICCODECOV_LIB_PATH=$(find build/ -maxdepth 1 -type d -name 'lib.*' -print -quit | xargs -I {} sh -c "find {} -type f -name 'staticcodecov*' -print -quit | sed 's|^./||'") &&
@@ -31,8 +34,7 @@ jobs:
3134
- os: ubuntu-20.04
3235
TARGET: ubuntu
3336
CMD_REQS: >
34-
pip install -r requirements.txt
35-
pip install .
37+
pip install -r requirements.txt && pip install .
3638
CMD_BUILD: >
3739
STATICCODECOV_LIB_PATH=$(find build/ -maxdepth 1 -type d -name 'lib.*' -print -quit | xargs -I {} sh -c "find {} -type f -name 'staticcodecov*' -print -quit | sed 's|^./||'") &&
3840
pyinstaller --add-binary ${STATICCODECOV_LIB_PATH}:. --copy-metadata codecov-cli --hidden-import staticcodecov_languages -F codecov_cli/main.py &&
@@ -42,8 +44,7 @@ jobs:
4244
- os: windows-latest
4345
TARGET: windows
4446
CMD_REQS: >
45-
pip install -r requirements.txt
46-
pip install .
47+
pip install -r requirements.txt && pip install .
4748
CMD_BUILD: >
4849
pyinstaller --add-binary "build\lib.win-amd64-cpython-311\staticcodecov_languages.cp311-win_amd64.pyd;." --copy-metadata codecov-cli --hidden-import staticcodecov_languages -F codecov_cli\main.py &&
4950
Copy-Item -Path ".\dist\main.exe" -Destination ".\dist\codecovcli_windows.exe"
@@ -93,10 +94,10 @@ jobs:
9394
- distro: "python:3.11-alpine3.18"
9495
arch: x86_64
9596
distro_name: alpine
96-
- distro: "python:3.11"
97+
- distro: "python:3.11-bullseye"
9798
arch: arm64
9899
distro_name: linux
99-
100+
100101
steps:
101102
- uses: actions/checkout@v4
102103
with:
@@ -129,6 +130,3 @@ jobs:
129130
asset_name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
130131
tag: ${{ github.ref }}
131132
overwrite: true
132-
133-
134-

.github/workflows/build_for_pypi.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ jobs:
3131
run: |
3232
pip install wheel
3333
python setup.py sdist bdist_wheel --plat-name=manylinux2014_x86_64
34-
python setup.py bdist_wheel --plat-name=macosx-12.6-x86_64
34+
python setup.py bdist_wheel --plat-name=macosx-12.6-universal2
3535
python setup.py bdist_wheel --plat-name=win_amd64
3636
- name: Publish package to PyPi
3737
if: inputs.publish == true
3838
uses: pypa/gh-action-pypi-publish@release/v1
39-
40-
41-
39+
with:
40+
attestations: false
41+
verbose: true

.github/workflows/ci-job.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: CLI CI Job
5+
6+
on:
7+
pull_request:
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
build-test-upload:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: true
19+
fetch-depth: 2
20+
- name: Set up Python 3.12
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.12"
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -r requirements.txt
28+
python -m pip install -e .
29+
pip install -r tests/requirements.txt
30+
- name: Test with pytest
31+
run: |
32+
pytest --cov --junitxml=3.12junit.xml
33+
34+
- name: Upload coverage to Codecov
35+
uses: codecov/codecov-action@v5
36+
with:
37+
token: ${{ secrets.CODECOV_TOKEN }}
38+
files: ./coverage.xml
39+
flags: python3.12
40+
fail_ci_if_error: true
41+
verbose: true

.github/workflows/ci.yml

+43-47
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,10 @@ jobs:
1616
- uses: actions/checkout@v4
1717
with:
1818
submodules: true
19-
- name: Install dependencies
19+
- name: Check linting with ruff
2020
run: |
21-
python -m pip install --upgrade pip
22-
pip install black==22.3.0 isort==5.10.1
23-
- name: Check linting with black
24-
run: |
25-
black --check codecov_cli
26-
- name: Check imports order with isort
27-
run: |
28-
isort --check --profile=black codecov_cli -p staticcodecov_languages
21+
make lint
22+
2923
3024
codecov-startup:
3125
runs-on: ubuntu-latest
@@ -54,11 +48,11 @@ jobs:
5448
fail-fast: false
5549
matrix:
5650
include:
51+
- python-version: "3.13"
5752
- python-version: "3.12"
5853
- python-version: "3.11"
5954
- python-version: "3.10"
6055
- python-version: "3.9"
61-
- python-version: "3.8"
6256
steps:
6357
- uses: actions/checkout@v4
6458
with:
@@ -76,12 +70,18 @@ jobs:
7670
pip install -r tests/requirements.txt
7771
- name: Test with pytest
7872
run: |
79-
pytest --cov --junitxml=junit.xml
73+
pytest --cov --junitxml=${{matrix.python-version}}junit.xml
8074
- name: Dogfooding codecov-cli
8175
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
8276
run: |
8377
codecovcli -v do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}
8478
codecovcli do-upload --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}}
79+
- name: Upload artifacts for test-results-processing
80+
if: ${{ !cancelled() }}
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: ${{matrix.python-version}}junit.xml
84+
path: ${{matrix.python-version}}junit.xml
8585

8686
static-analysis:
8787
runs-on: ubuntu-latest
@@ -118,10 +118,12 @@ jobs:
118118
- uses: actions/setup-python@v5
119119
with:
120120
python-version: "3.12"
121-
- name: Install CLI
121+
- name: Install dependencies for Dogfooding
122122
run: |
123-
pip install -r requirements.txt -r tests/requirements.txt
124-
pip install codecov-cli
123+
python -m pip install --upgrade pip
124+
pip install -r requirements.txt
125+
python -m pip install -e .
126+
pip install -r tests/requirements.txt
125127
- name: Label Analysis
126128
run: |
127129
BASE_SHA=$(git merge-base HEAD^ origin/main)
@@ -131,38 +133,32 @@ jobs:
131133
run: |
132134
codecovcli --codecov-yml-path=codecov.yml do-upload --plugin pycoverage --plugin compress-pycoverage --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --flag smart-labels
133135
134-
test-process-test-results-cmd:
136+
process-test-results:
137+
if: ${{ always() }}
138+
needs: build-test-upload
135139
runs-on: ubuntu-latest
136-
permissions:
137-
pull-requests: write
138-
strategy:
139-
fail-fast: false
140-
matrix:
141-
include:
142-
- python-version: "3.12"
143-
- python-version: "3.11"
144-
- python-version: "3.10"
145-
- python-version: "3.9"
146-
- python-version: "3.8"
147140
steps:
148-
- uses: actions/checkout@v4
149-
with:
150-
submodules: true
151-
fetch-depth: 2
152-
- name: Set up Python ${{matrix.python-version}}
153-
uses: actions/setup-python@v5
154-
with:
155-
python-version: "${{matrix.python-version}}"
156-
- name: Install dependencies
157-
run: |
158-
python -m pip install --upgrade pip
159-
pip install -r requirements.txt
160-
python -m pip install -e .
161-
pip install -r tests/requirements.txt
162-
- name: Test with pytest
163-
run: |
164-
pytest --cov --junitxml=junit.xml
165-
- name: Dogfooding codecov-cli
166-
if: ${{ !cancelled() }}
167-
run: |
168-
codecovcli process-test-results --provider-token ${{ secrets.GITHUB_TOKEN }}
141+
- uses: actions/checkout@v4
142+
with:
143+
submodules: true
144+
fetch-depth: 2
145+
- uses: actions/setup-python@v5
146+
with:
147+
python-version: "3.12"
148+
- name: Install dependencies for Dogfooding
149+
run: |
150+
python -m pip install --upgrade pip
151+
pip install -r requirements.txt
152+
python -m pip install -e .
153+
pip install -r tests/requirements.txt
154+
- name: Download all test results
155+
uses: actions/download-artifact@v4
156+
with:
157+
pattern: "*junit.xml"
158+
path: "test_results"
159+
merge-multiple: true
160+
161+
- name: Dogfooding codecov-cli
162+
if: ${{ !cancelled() && github.ref && contains(github.ref, 'pull') }}
163+
run: |
164+
codecovcli process-test-results --dir test_results --github-token ${{ secrets.GITHUB_TOKEN }}

Makefile

+20-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@ name ?= codecovcli
22
# Semantic versioning format https://semver.org/
33
tag_regex := ^v([0-9]{1,}\.){2}[0-9]{1,}([-_]\w+)?$
44

5+
lint.install:
6+
echo "Installing ruff..."
7+
pip install -Iv ruff
8+
9+
# The preferred method (for now) w.r.t. fixable rules is to manually update the makefile
10+
# with --fix and re-run 'make lint.' Since ruff is constantly adding rules this is a slight
11+
# amount of "needed" friction imo.
12+
lint.run:
13+
ruff check --ignore F401 --exclude languages --exclude samples
14+
ruff format --exclude languages --exclude samples
15+
16+
lint.check:
17+
echo "Linting..."
18+
ruff check --ignore F401 --exclude languages --exclude samples
19+
echo "Formatting..."
20+
ruff format --check --exclude languages --exclude samples
21+
522
lint:
6-
pip install black==22.3.0 isort==5.10.1
7-
black codecov_cli
8-
isort --profile=black codecov_cli -p staticcodecov_languages
9-
black tests
10-
isort --profile black tests
23+
make lint.install
24+
make lint.run
1125

1226
tag.release:
1327
ifeq ($(shell echo ${version} | egrep "${tag_regex}"),)
@@ -16,4 +30,4 @@ else
1630
@echo "Tagging new release ${version}"
1731
git tag -a ${version} -m "Autogenerated release tag for codecov-cli"
1832
git push origin ${version}
19-
endif
33+
endif

README.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,15 @@ are ignored by codecov (including README and configuration files)
240240

241241
`Usage: codecovcli empty-upload [OPTIONS]`
242242

243-
Options:
244-
-C, --sha, --commit-sha TEXT Commit SHA (with 40 chars) [required]
245-
-Z, --fail-on-error Exit with non-zero code in case of error
246-
--git-service [github|gitlab|bitbucket|github_enterprise|gitlab_enterprise|bitbucket_server]
247-
-t, --token TEXT Codecov upload token
248-
-r, --slug TEXT owner/repo slug used instead of the private
249-
repo token in Self-hosted
250-
-h, --help Show this message and exit.
243+
| Options | Description | usage |
244+
| :--------------------------: | :----------------------------------------------------------------------------------------: | :------: |
245+
| -C, --sha, --commit-sha TEXT | Commit SHA (with 40 chars) | Required |
246+
| -t, --token TEXT | Codecov upload token | Required |
247+
| -r, --slug TEXT | owner/repo slug used instead of the private repo token in Self-hosted | Optional |
248+
| --force | Always emit passing checks regardless of changed files | Optional |
249+
| -Z, --fail-on-error | Exit with non-zero code in case of error | Optional |
250+
| --git-service | Options: github, gitlab, bitbucket, github_enterprise, gitlab_enterprise, bitbucket_server | Optional |
251+
| -h, --help | Show this message and exit. | Optional |
251252

252253
# How to Use Local Upload
253254

@@ -282,7 +283,7 @@ The CLI can perform basic static analysis on Python code today. This static anal
282283

283284
# Contributions
284285

285-
This repository, like all of Codecov's repositories, strives to follow our general [Contributing guidlines](https://github.com/codecov/contributing). If you're considering making a contribution to this repository, we encourage review of our Contributing guidelines first.
286+
This repository, like all of Codecov's repositories, strives to follow our general [Contributing guidelines](https://github.com/codecov/contributing). If you're considering making a contribution to this repository, we encourage review of our Contributing guidelines first.
286287

287288
## Requirements
288289

codecov_cli/commands/base_picking.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import click
55

66
from codecov_cli.fallbacks import CodecovOption, FallbackFieldEnum
7+
from codecov_cli.helpers.args import get_cli_args
78
from codecov_cli.helpers.encoder import slug_without_subgroups_is_invalid
89
from codecov_cli.services.commit.base_picking import base_picking_logic
10+
from codecov_cli.types import CommandContext
911

1012
logger = logging.getLogger("codecovcli")
1113

@@ -45,24 +47,19 @@
4547
)
4648
@click.pass_context
4749
def pr_base_picking(
48-
ctx,
50+
ctx: CommandContext,
4951
base_sha: str,
5052
pr: typing.Optional[int],
5153
slug: typing.Optional[str],
5254
token: typing.Optional[str],
5355
service: typing.Optional[str],
5456
):
5557
enterprise_url = ctx.obj.get("enterprise_url")
58+
args = get_cli_args(ctx)
5659
logger.debug(
5760
"Starting base picking process",
5861
extra=dict(
59-
extra_log_attributes=dict(
60-
pr=pr,
61-
slug=slug,
62-
token=token,
63-
service=service,
64-
enterprise_url=enterprise_url,
65-
)
62+
extra_log_attributes=args,
6663
),
6764
)
6865

@@ -72,4 +69,4 @@ def pr_base_picking(
7269
)
7370
return
7471

75-
base_picking_logic(base_sha, pr, slug, token, service, enterprise_url)
72+
base_picking_logic(base_sha, pr, slug, token, service, enterprise_url, args)

0 commit comments

Comments
 (0)