-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathreport.py
More file actions
65 lines (60 loc) · 1.9 KB
/
report.py
File metadata and controls
65 lines (60 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import logging
import click
import sentry_sdk
from codecov_cli.fallbacks import CodecovOption, FallbackFieldEnum
from codecov_cli.helpers.args import get_cli_args
from codecov_cli.helpers.options import global_options
from codecov_cli.services.report import create_report_logic
from codecov_cli.types import CommandContext
logger = logging.getLogger("codecovcli")
@click.command()
@click.option(
"--code", help="The code of the report. If unsure, leave default", default="default", hidden=True
)
@click.option(
"-P",
"--pr",
"--pull-request-number",
"pull_request_number",
help="Specify the pull request number manually. Used to override pre-existing CI environment variables",
cls=CodecovOption,
fallback_field=FallbackFieldEnum.pull_request_number,
)
@global_options
@click.pass_context
def create_report(
ctx: CommandContext,
commit_sha: str,
code: str,
slug: str,
git_service: str,
token: str,
fail_on_error: bool,
pull_request_number: int,
):
with sentry_sdk.start_transaction(op="task", name="Create Report"):
with sentry_sdk.start_span(name="create_report"):
enterprise_url = ctx.obj.get("enterprise_url")
args = get_cli_args(ctx)
logger.debug(
"Starting create report process",
extra=dict(
extra_log_attributes=args,
),
)
res = create_report_logic(
commit_sha,
code,
slug,
git_service,
token,
enterprise_url,
pull_request_number,
fail_on_error,
args,
)
if not res.error:
logger.info(
"Finished creating report successfully",
extra=dict(extra_log_attributes=dict(response=res.text)),
)