Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 6269e67

Browse files
fix: first pass with tests (#506)
1 parent 1ad6ca9 commit 6269e67

32 files changed

+268
-166
lines changed

codecov_cli/commands/base_picking.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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
910
from codecov_cli.types import CommandContext
@@ -54,16 +55,11 @@ def pr_base_picking(
5455
service: typing.Optional[str],
5556
):
5657
enterprise_url = ctx.obj.get("enterprise_url")
58+
args = get_cli_args(ctx)
5759
logger.debug(
5860
"Starting base picking process",
5961
extra=dict(
60-
extra_log_attributes=dict(
61-
pr=pr,
62-
slug=slug,
63-
token=token,
64-
service=service,
65-
enterprise_url=enterprise_url,
66-
)
62+
extra_log_attributes=args,
6763
),
6864
)
6965

@@ -73,4 +69,4 @@ def pr_base_picking(
7369
)
7470
return
7571

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

codecov_cli/commands/commit.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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.git import GitService
89
from codecov_cli.helpers.options import global_options
910
from codecov_cli.services.commit import create_commit_logic
@@ -47,19 +48,11 @@ def create_commit(
4748
fail_on_error: bool,
4849
):
4950
enterprise_url = ctx.obj.get("enterprise_url")
51+
args = get_cli_args(ctx)
5052
logger.debug(
5153
"Starting create commit process",
5254
extra=dict(
53-
extra_log_attributes=dict(
54-
commit_sha=commit_sha,
55-
parent_sha=parent_sha,
56-
pr=pull_request_number,
57-
branch=branch,
58-
slug=slug,
59-
token=token,
60-
service=git_service,
61-
enterprise_url=enterprise_url,
62-
)
55+
extra_log_attributes=args,
6356
),
6457
)
6558
create_commit_logic(
@@ -72,4 +65,5 @@ def create_commit(
7265
git_service,
7366
enterprise_url,
7467
fail_on_error,
68+
args,
7569
)

codecov_cli/commands/create_report_result.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import click
44

5+
from codecov_cli.helpers.args import get_cli_args
56
from codecov_cli.helpers.options import global_options
67
from codecov_cli.services.report import create_report_results_logic
78
from codecov_cli.types import CommandContext
@@ -25,19 +26,13 @@ def create_report_results(
2526
fail_on_error: bool,
2627
):
2728
enterprise_url = ctx.obj.get("enterprise_url")
29+
args = get_cli_args(ctx)
2830
logger.debug(
2931
"Creating report results",
3032
extra=dict(
31-
extra_log_attributes=dict(
32-
commit_sha=commit_sha,
33-
code=code,
34-
slug=slug,
35-
service=git_service,
36-
enterprise_url=enterprise_url,
37-
token=token,
38-
)
33+
extra_log_attributes=args,
3934
),
4035
)
4136
create_report_results_logic(
42-
commit_sha, code, slug, git_service, token, enterprise_url, fail_on_error
37+
commit_sha, code, slug, git_service, token, enterprise_url, fail_on_error, args
4338
)

codecov_cli/commands/empty_upload.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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.git import GitService
89
from codecov_cli.helpers.options import global_options
910
from codecov_cli.services.empty_upload import empty_upload_logic
@@ -26,19 +27,13 @@ def empty_upload(
2627
fail_on_error: typing.Optional[bool],
2728
):
2829
enterprise_url = ctx.obj.get("enterprise_url")
30+
args = get_cli_args(ctx)
2931
logger.debug(
3032
"Starting empty upload process",
3133
extra=dict(
32-
extra_log_attributes=dict(
33-
commit_sha=commit_sha,
34-
slug=slug,
35-
token=token,
36-
service=git_service,
37-
enterprise_url=enterprise_url,
38-
fail_on_error=fail_on_error,
39-
)
34+
extra_log_attributes=args,
4035
),
4136
)
4237
return empty_upload_logic(
43-
commit_sha, slug, token, git_service, enterprise_url, fail_on_error, force
38+
commit_sha, slug, token, git_service, enterprise_url, fail_on_error, force, args
4439
)

codecov_cli/commands/get_report_results.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,11 @@ def get_report_results(
2828
fail_on_error: bool,
2929
):
3030
enterprise_url = ctx.obj.get("enterprise_url")
31+
args = get_cli_args(ctx)
3132
logger.debug(
3233
"Getting report results",
3334
extra=dict(
34-
extra_log_attributes=dict(
35-
commit_sha=commit_sha,
36-
code=code,
37-
slug=slug,
38-
service=git_service,
39-
enterprise_url=enterprise_url,
40-
token=token,
41-
)
35+
extra_log_attributes=args,
4236
),
4337
)
4438
encoded_slug = encode_slug(slug)

codecov_cli/commands/labelanalysis.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from codecov_cli.fallbacks import CodecovOption, FallbackFieldEnum
1111
from codecov_cli.helpers import request
12+
from codecov_cli.helpers.args import get_cli_args
1213
from codecov_cli.helpers.config import CODECOV_API_URL
1314
from codecov_cli.helpers.validators import validate_commit_sha
1415
from codecov_cli.runners import get_runner
@@ -89,18 +90,11 @@ def label_analysis(
8990
runner_params: List[str],
9091
):
9192
enterprise_url = ctx.obj.get("enterprise_url")
93+
args = get_cli_args(ctx)
9294
logger.debug(
9395
"Starting label analysis",
9496
extra=dict(
95-
extra_log_attributes=dict(
96-
head_commit_sha=head_commit_sha,
97-
base_commit_sha=base_commit_sha,
98-
token=token,
99-
runner_name=runner_name,
100-
enterprise_url=enterprise_url,
101-
max_wait_time=max_wait_time,
102-
dry_run=dry_run,
103-
)
97+
extra_log_attributes=args,
10498
),
10599
)
106100
if head_commit_sha == base_commit_sha:

codecov_cli/commands/process_test_results.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
parse_junit_xml,
1414
)
1515

16+
from codecov_cli.helpers.args import get_cli_args
1617
from codecov_cli.helpers.request import (
1718
log_warnings_and_errors_if_any,
1819
send_post_request,
1920
)
2021
from codecov_cli.services.upload.file_finder import select_file_finder
22+
from codecov_cli.types import CommandContext
2123

2224
logger = logging.getLogger("codecovcli")
2325

@@ -83,8 +85,14 @@ class TestResultsNotificationPayload:
8385

8486
@click.command()
8587
@process_test_results_options
88+
@click.pass_context
8689
def process_test_results(
87-
dir=None, files=None, exclude_folders=None, disable_search=None, provider_token=None
90+
ctx: CommandContext,
91+
dir=None,
92+
files=None,
93+
exclude_folders=None,
94+
disable_search=None,
95+
provider_token=None,
8896
):
8997
if provider_token is None:
9098
raise click.ClickException(
@@ -130,10 +138,11 @@ def process_test_results(
130138
# GITHUB_REF is documented here: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
131139
pr_number = ref.split("/")[2]
132140

133-
create_github_comment(provider_token, slug, pr_number, message)
141+
args = get_cli_args(ctx)
142+
create_github_comment(provider_token, slug, pr_number, message, args)
134143

135144

136-
def create_github_comment(token, repo_slug, pr_number, message):
145+
def create_github_comment(token, repo_slug, pr_number, message, args):
137146
url = f"https://api.github.com/repos/{repo_slug}/issues/{pr_number}/comments"
138147

139148
headers = {
@@ -144,7 +153,14 @@ def create_github_comment(token, repo_slug, pr_number, message):
144153
logger.info("Posting github comment")
145154

146155
log_warnings_and_errors_if_any(
147-
send_post_request(url=url, data={"body": message}, headers=headers),
156+
send_post_request(
157+
url=url,
158+
data={
159+
"body": message,
160+
"cli_args": args,
161+
},
162+
headers=headers,
163+
),
148164
"Posting test results comment",
149165
)
150166

codecov_cli/commands/report.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import click
44

55
from codecov_cli.fallbacks import CodecovOption, FallbackFieldEnum
6+
from codecov_cli.helpers.args import get_cli_args
67
from codecov_cli.helpers.options import global_options
78
from codecov_cli.services.report import create_report_logic
89
from codecov_cli.types import CommandContext
@@ -36,17 +37,11 @@ def create_report(
3637
pull_request_number: int,
3738
):
3839
enterprise_url = ctx.obj.get("enterprise_url")
40+
args = get_cli_args(ctx)
3941
logger.debug(
4042
"Starting create report process",
4143
extra=dict(
42-
extra_log_attributes=dict(
43-
commit_sha=commit_sha,
44-
code=code,
45-
slug=slug,
46-
service=git_service,
47-
enterprise_url=enterprise_url,
48-
token=token,
49-
)
44+
extra_log_attributes=args,
5045
),
5146
)
5247
res = create_report_logic(
@@ -58,6 +53,7 @@ def create_report(
5853
enterprise_url,
5954
pull_request_number,
6055
fail_on_error,
56+
args,
6157
)
6258
if not res.error:
6359
logger.info(

codecov_cli/commands/send_notifications.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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.git import GitService
89
from codecov_cli.helpers.options import global_options
910
from codecov_cli.services.upload_completion import upload_completion_logic
@@ -24,16 +25,11 @@ def send_notifications(
2425
fail_on_error: bool,
2526
):
2627
enterprise_url = ctx.obj.get("enterprise_url")
28+
args = get_cli_args(ctx)
2729
logger.debug(
2830
"Sending notifications process has started",
2931
extra=dict(
30-
extra_log_attributes=dict(
31-
commit_sha=commit_sha,
32-
slug=slug,
33-
token=token,
34-
service=git_service,
35-
enterprise_url=enterprise_url,
36-
)
32+
extra_log_attributes=args,
3733
),
3834
)
3935
return upload_completion_logic(
@@ -43,4 +39,5 @@ def send_notifications(
4339
git_service,
4440
enterprise_url,
4541
fail_on_error,
42+
args,
4643
)

codecov_cli/commands/staticanalysis.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import click
77

88
from codecov_cli.fallbacks import CodecovOption, FallbackFieldEnum
9+
from codecov_cli.helpers.args import get_cli_args
910
from codecov_cli.helpers.validators import validate_commit_sha
1011
from codecov_cli.services.staticanalysis import run_analysis_entrypoint
1112
from codecov_cli.types import CommandContext
@@ -59,19 +60,11 @@ def static_analysis(
5960
folders_to_exclude: typing.List[pathlib.Path],
6061
):
6162
enterprise_url = ctx.obj.get("enterprise_url")
63+
args = get_cli_args(ctx)
6264
logger.debug(
6365
"Starting Static Analysis processing",
6466
extra=dict(
65-
extra_log_attributes=dict(
66-
foldertosearch=foldertosearch,
67-
numberprocesses=numberprocesses,
68-
pattern=pattern,
69-
commit_sha=commit,
70-
token=token,
71-
force=force,
72-
folders_to_exclude=folders_to_exclude,
73-
enterprise_url=enterprise_url,
74-
)
67+
extra_log_attributes=args,
7568
),
7669
)
7770
return asyncio.run(
@@ -85,5 +78,6 @@ def static_analysis(
8578
force,
8679
list(folders_to_exclude),
8780
enterprise_url,
81+
args,
8882
)
8983
)

0 commit comments

Comments
 (0)