codecov-cli 11.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codecov_cli/__init__.py +3 -0
- codecov_cli/commands/__init__.py +0 -0
- codecov_cli/commands/base_picking.py +75 -0
- codecov_cli/commands/commit.py +72 -0
- codecov_cli/commands/create_report_result.py +41 -0
- codecov_cli/commands/empty_upload.py +80 -0
- codecov_cli/commands/get_report_results.py +50 -0
- codecov_cli/commands/labelanalysis.py +269 -0
- codecov_cli/commands/process_test_results.py +273 -0
- codecov_cli/commands/report.py +65 -0
- codecov_cli/commands/send_notifications.py +46 -0
- codecov_cli/commands/staticanalysis.py +62 -0
- codecov_cli/commands/upload.py +316 -0
- codecov_cli/commands/upload_coverage.py +186 -0
- codecov_cli/commands/upload_process.py +133 -0
- codecov_cli/fallbacks.py +41 -0
- codecov_cli/helpers/__init__.py +0 -0
- codecov_cli/helpers/args.py +31 -0
- codecov_cli/helpers/ci_adapters/__init__.py +63 -0
- codecov_cli/helpers/ci_adapters/appveyor_ci.py +54 -0
- codecov_cli/helpers/ci_adapters/azure_pipelines.py +44 -0
- codecov_cli/helpers/ci_adapters/base.py +102 -0
- codecov_cli/helpers/ci_adapters/bitbucket_ci.py +42 -0
- codecov_cli/helpers/ci_adapters/bitrise_ci.py +37 -0
- codecov_cli/helpers/ci_adapters/buildkite.py +45 -0
- codecov_cli/helpers/ci_adapters/circleci.py +47 -0
- codecov_cli/helpers/ci_adapters/cirrus_ci.py +36 -0
- codecov_cli/helpers/ci_adapters/cloudbuild.py +70 -0
- codecov_cli/helpers/ci_adapters/codebuild.py +49 -0
- codecov_cli/helpers/ci_adapters/droneci.py +36 -0
- codecov_cli/helpers/ci_adapters/github_actions.py +90 -0
- codecov_cli/helpers/ci_adapters/gitlab_ci.py +56 -0
- codecov_cli/helpers/ci_adapters/heroku.py +36 -0
- codecov_cli/helpers/ci_adapters/jenkins.py +38 -0
- codecov_cli/helpers/ci_adapters/local.py +39 -0
- codecov_cli/helpers/ci_adapters/teamcity.py +37 -0
- codecov_cli/helpers/ci_adapters/travis_ci.py +44 -0
- codecov_cli/helpers/ci_adapters/woodpeckerci.py +36 -0
- codecov_cli/helpers/config.py +66 -0
- codecov_cli/helpers/encoder.py +49 -0
- codecov_cli/helpers/folder_searcher.py +114 -0
- codecov_cli/helpers/git.py +97 -0
- codecov_cli/helpers/git_services/__init__.py +14 -0
- codecov_cli/helpers/git_services/github.py +40 -0
- codecov_cli/helpers/glob.py +146 -0
- codecov_cli/helpers/logging_utils.py +77 -0
- codecov_cli/helpers/options.py +51 -0
- codecov_cli/helpers/request.py +198 -0
- codecov_cli/helpers/upload_type.py +15 -0
- codecov_cli/helpers/validators.py +13 -0
- codecov_cli/helpers/versioning_systems.py +201 -0
- codecov_cli/main.py +99 -0
- codecov_cli/opentelemetry.py +26 -0
- codecov_cli/plugins/__init__.py +92 -0
- codecov_cli/plugins/compress_pycoverage_contexts.py +141 -0
- codecov_cli/plugins/gcov.py +69 -0
- codecov_cli/plugins/pycoverage.py +134 -0
- codecov_cli/plugins/types.py +8 -0
- codecov_cli/plugins/xcode.py +117 -0
- codecov_cli/runners/__init__.py +80 -0
- codecov_cli/runners/dan_runner.py +64 -0
- codecov_cli/runners/pytest_standard_runner.py +184 -0
- codecov_cli/runners/types.py +33 -0
- codecov_cli/services/__init__.py +0 -0
- codecov_cli/services/commit/__init__.py +86 -0
- codecov_cli/services/commit/base_picking.py +24 -0
- codecov_cli/services/empty_upload/__init__.py +42 -0
- codecov_cli/services/report/__init__.py +169 -0
- codecov_cli/services/upload/__init__.py +169 -0
- codecov_cli/services/upload/file_finder.py +320 -0
- codecov_cli/services/upload/legacy_upload_sender.py +132 -0
- codecov_cli/services/upload/network_finder.py +49 -0
- codecov_cli/services/upload/upload_collector.py +198 -0
- codecov_cli/services/upload/upload_sender.py +232 -0
- codecov_cli/services/upload_completion/__init__.py +38 -0
- codecov_cli/services/upload_coverage/__init__.py +93 -0
- codecov_cli/types.py +88 -0
- codecov_cli-11.0.0.dist-info/METADATA +298 -0
- codecov_cli-11.0.0.dist-info/RECORD +83 -0
- codecov_cli-11.0.0.dist-info/WHEEL +5 -0
- codecov_cli-11.0.0.dist-info/entry_points.txt +3 -0
- codecov_cli-11.0.0.dist-info/licenses/LICENSE +201 -0
- codecov_cli-11.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from codecov_cli.helpers.config import CODECOV_INGEST_URL
|
|
6
|
+
from codecov_cli.helpers.encoder import encode_slug
|
|
7
|
+
from codecov_cli.helpers.request import (
|
|
8
|
+
get_token_header,
|
|
9
|
+
log_warnings_and_errors_if_any,
|
|
10
|
+
send_post_request,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger("codecovcli")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def create_commit_logic(
|
|
17
|
+
commit_sha: str,
|
|
18
|
+
parent_sha: typing.Optional[str],
|
|
19
|
+
pr: typing.Optional[str],
|
|
20
|
+
branch: typing.Optional[str],
|
|
21
|
+
slug: typing.Optional[str],
|
|
22
|
+
token: typing.Optional[str],
|
|
23
|
+
service: typing.Optional[str],
|
|
24
|
+
enterprise_url: typing.Optional[str] = None,
|
|
25
|
+
fail_on_error: bool = False,
|
|
26
|
+
args: dict = None,
|
|
27
|
+
):
|
|
28
|
+
encoded_slug = encode_slug(slug)
|
|
29
|
+
sending_result = send_commit_data(
|
|
30
|
+
commit_sha=commit_sha,
|
|
31
|
+
parent_sha=parent_sha,
|
|
32
|
+
pr=pr,
|
|
33
|
+
branch=branch,
|
|
34
|
+
slug=encoded_slug,
|
|
35
|
+
token=token,
|
|
36
|
+
service=service,
|
|
37
|
+
enterprise_url=enterprise_url,
|
|
38
|
+
args=args,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
log_warnings_and_errors_if_any(sending_result, "Commit creating", fail_on_error)
|
|
42
|
+
return sending_result
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def send_commit_data(
|
|
46
|
+
commit_sha,
|
|
47
|
+
parent_sha,
|
|
48
|
+
pr,
|
|
49
|
+
branch,
|
|
50
|
+
slug,
|
|
51
|
+
token,
|
|
52
|
+
service,
|
|
53
|
+
enterprise_url,
|
|
54
|
+
args,
|
|
55
|
+
):
|
|
56
|
+
# Old versions of the GHA use this env var instead of the regular branch
|
|
57
|
+
# argument to provide an unprotected branch name
|
|
58
|
+
if tokenless := os.environ.get("TOKENLESS"):
|
|
59
|
+
branch = tokenless
|
|
60
|
+
|
|
61
|
+
if branch and ":" in branch:
|
|
62
|
+
logger.info(f"Creating a commit for an unprotected branch: {branch}")
|
|
63
|
+
elif token is None:
|
|
64
|
+
logger.warning(
|
|
65
|
+
f"Branch `{branch}` is protected but no token was provided\nFor information on Codecov upload tokens, see https://docs.codecov.com/docs/codecov-tokens"
|
|
66
|
+
)
|
|
67
|
+
else:
|
|
68
|
+
logger.info(f"Using token to create a commit for protected branch `{branch}`")
|
|
69
|
+
|
|
70
|
+
headers = get_token_header(token)
|
|
71
|
+
|
|
72
|
+
data = {
|
|
73
|
+
"branch": branch,
|
|
74
|
+
"cli_args": args,
|
|
75
|
+
"commitid": commit_sha,
|
|
76
|
+
"parent_commit_id": parent_sha,
|
|
77
|
+
"pullid": pr,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
upload_url = enterprise_url or CODECOV_INGEST_URL
|
|
81
|
+
url = f"{upload_url}/upload/{service}/{slug}/commits"
|
|
82
|
+
return send_post_request(
|
|
83
|
+
url=url,
|
|
84
|
+
data=data,
|
|
85
|
+
headers=headers,
|
|
86
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from codecov_cli.helpers.config import CODECOV_API_URL
|
|
4
|
+
from codecov_cli.helpers.request import (
|
|
5
|
+
get_token_header,
|
|
6
|
+
log_warnings_and_errors_if_any,
|
|
7
|
+
send_put_request,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger("codecovcli")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def base_picking_logic(base_sha, pr, slug, token, service, enterprise_url, args):
|
|
14
|
+
data = {
|
|
15
|
+
"cli_args": args,
|
|
16
|
+
"user_provided_base_sha": base_sha,
|
|
17
|
+
}
|
|
18
|
+
headers = get_token_header(token)
|
|
19
|
+
upload_url = enterprise_url or CODECOV_API_URL
|
|
20
|
+
url = f"{upload_url}/api/v1/{service}/{slug}/pulls/{pr}"
|
|
21
|
+
sending_result = send_put_request(url=url, data=data, headers=headers)
|
|
22
|
+
|
|
23
|
+
log_warnings_and_errors_if_any(sending_result, "Base picking")
|
|
24
|
+
return sending_result
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from codecov_cli.helpers.config import CODECOV_API_URL
|
|
5
|
+
from codecov_cli.helpers.encoder import encode_slug
|
|
6
|
+
from codecov_cli.helpers.request import (
|
|
7
|
+
get_token_header,
|
|
8
|
+
log_warnings_and_errors_if_any,
|
|
9
|
+
send_post_request,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger("codecovcli")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def empty_upload_logic(
|
|
16
|
+
commit_sha,
|
|
17
|
+
slug,
|
|
18
|
+
token,
|
|
19
|
+
git_service,
|
|
20
|
+
enterprise_url,
|
|
21
|
+
fail_on_error,
|
|
22
|
+
should_force,
|
|
23
|
+
args,
|
|
24
|
+
):
|
|
25
|
+
encoded_slug = encode_slug(slug)
|
|
26
|
+
headers = get_token_header(token)
|
|
27
|
+
upload_url = enterprise_url or CODECOV_API_URL
|
|
28
|
+
url = f"{upload_url}/upload/{git_service}/{encoded_slug}/commits/{commit_sha}/empty-upload"
|
|
29
|
+
sending_result = send_post_request(
|
|
30
|
+
url=url,
|
|
31
|
+
headers=headers,
|
|
32
|
+
data={
|
|
33
|
+
"cli_args": args,
|
|
34
|
+
"should_force": should_force,
|
|
35
|
+
},
|
|
36
|
+
)
|
|
37
|
+
log_warnings_and_errors_if_any(sending_result, "Empty Upload", fail_on_error)
|
|
38
|
+
if sending_result.status_code == 200:
|
|
39
|
+
response_json = json.loads(sending_result.text)
|
|
40
|
+
logger.info(response_json.get("result"))
|
|
41
|
+
logger.info(f"Non ignored files {response_json.get('non_ignored_files')}")
|
|
42
|
+
return sending_result
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
import time
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
import requests
|
|
7
|
+
|
|
8
|
+
from codecov_cli.helpers import request
|
|
9
|
+
from codecov_cli.helpers.config import CODECOV_API_URL, CODECOV_INGEST_URL
|
|
10
|
+
from codecov_cli.helpers.encoder import encode_slug
|
|
11
|
+
from codecov_cli.helpers.request import (
|
|
12
|
+
get_token_header,
|
|
13
|
+
log_warnings_and_errors_if_any,
|
|
14
|
+
request_result,
|
|
15
|
+
send_post_request,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger("codecovcli")
|
|
19
|
+
MAX_NUMBER_TRIES = 3
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def create_report_logic(
|
|
23
|
+
commit_sha: str,
|
|
24
|
+
code: str,
|
|
25
|
+
slug: str,
|
|
26
|
+
service: str,
|
|
27
|
+
token: typing.Optional[str],
|
|
28
|
+
enterprise_url: str,
|
|
29
|
+
pull_request_number: int,
|
|
30
|
+
fail_on_error: bool = False,
|
|
31
|
+
args: typing.Union[dict, None] = None,
|
|
32
|
+
):
|
|
33
|
+
encoded_slug = encode_slug(slug)
|
|
34
|
+
sending_result = send_create_report_request(
|
|
35
|
+
commit_sha,
|
|
36
|
+
code,
|
|
37
|
+
service,
|
|
38
|
+
token,
|
|
39
|
+
encoded_slug,
|
|
40
|
+
enterprise_url,
|
|
41
|
+
pull_request_number,
|
|
42
|
+
args,
|
|
43
|
+
)
|
|
44
|
+
log_warnings_and_errors_if_any(sending_result, "Report creating", fail_on_error)
|
|
45
|
+
return sending_result
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def send_create_report_request(
|
|
49
|
+
commit_sha,
|
|
50
|
+
code,
|
|
51
|
+
service,
|
|
52
|
+
token,
|
|
53
|
+
encoded_slug,
|
|
54
|
+
enterprise_url,
|
|
55
|
+
pull_request_number,
|
|
56
|
+
args,
|
|
57
|
+
):
|
|
58
|
+
data = {
|
|
59
|
+
"cli_args": args,
|
|
60
|
+
"code": code,
|
|
61
|
+
}
|
|
62
|
+
headers = get_token_header(token)
|
|
63
|
+
upload_url = enterprise_url or CODECOV_INGEST_URL
|
|
64
|
+
url = f"{upload_url}/upload/{service}/{encoded_slug}/commits/{commit_sha}/reports"
|
|
65
|
+
return send_post_request(url=url, headers=headers, data=data)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def create_report_results_logic(
|
|
69
|
+
commit_sha: str,
|
|
70
|
+
code: str,
|
|
71
|
+
slug: str,
|
|
72
|
+
service: str,
|
|
73
|
+
token: typing.Optional[str],
|
|
74
|
+
enterprise_url: str,
|
|
75
|
+
fail_on_error: bool = False,
|
|
76
|
+
args: typing.Union[dict, None] = None,
|
|
77
|
+
):
|
|
78
|
+
encoded_slug = encode_slug(slug)
|
|
79
|
+
sending_result = send_reports_result_request(
|
|
80
|
+
commit_sha=commit_sha,
|
|
81
|
+
report_code=code,
|
|
82
|
+
encoded_slug=encoded_slug,
|
|
83
|
+
service=service,
|
|
84
|
+
token=token,
|
|
85
|
+
enterprise_url=enterprise_url,
|
|
86
|
+
args=args,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
log_warnings_and_errors_if_any(
|
|
90
|
+
sending_result, "Report results creating", fail_on_error
|
|
91
|
+
)
|
|
92
|
+
return sending_result
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def send_reports_result_request(
|
|
96
|
+
commit_sha,
|
|
97
|
+
report_code,
|
|
98
|
+
encoded_slug,
|
|
99
|
+
service,
|
|
100
|
+
token,
|
|
101
|
+
enterprise_url,
|
|
102
|
+
args,
|
|
103
|
+
):
|
|
104
|
+
data = {
|
|
105
|
+
"cli_args": args,
|
|
106
|
+
}
|
|
107
|
+
headers = get_token_header(token)
|
|
108
|
+
upload_url = enterprise_url or CODECOV_API_URL
|
|
109
|
+
url = f"{upload_url}/upload/{service}/{encoded_slug}/commits/{commit_sha}/reports/{report_code}/results"
|
|
110
|
+
return send_post_request(url=url, data=data, headers=headers)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def send_reports_result_get_request(
|
|
114
|
+
commit_sha,
|
|
115
|
+
report_code,
|
|
116
|
+
encoded_slug,
|
|
117
|
+
service,
|
|
118
|
+
token,
|
|
119
|
+
enterprise_url,
|
|
120
|
+
fail_on_error=False,
|
|
121
|
+
):
|
|
122
|
+
headers = get_token_header(token)
|
|
123
|
+
upload_url = enterprise_url or CODECOV_API_URL
|
|
124
|
+
url = f"{upload_url}/upload/{service}/{encoded_slug}/commits/{commit_sha}/reports/{report_code}/results"
|
|
125
|
+
number_tries = 0
|
|
126
|
+
while number_tries < MAX_NUMBER_TRIES:
|
|
127
|
+
resp = request.get(url=url, headers=headers)
|
|
128
|
+
response_obj = request_result(resp)
|
|
129
|
+
response_content = json.loads(response_obj.text)
|
|
130
|
+
|
|
131
|
+
# if response_status is 400 and higher
|
|
132
|
+
if response_obj.error:
|
|
133
|
+
log_warnings_and_errors_if_any(
|
|
134
|
+
response_obj, "Getting report results", fail_on_error
|
|
135
|
+
)
|
|
136
|
+
return response_obj
|
|
137
|
+
|
|
138
|
+
state = response_content.get("state").lower()
|
|
139
|
+
if state == "error":
|
|
140
|
+
logger.error(
|
|
141
|
+
"An error occurred while processing the report. Please try again later.",
|
|
142
|
+
extra=dict(
|
|
143
|
+
extra_log_attributes=dict(
|
|
144
|
+
response_status_code=response_obj.status_code,
|
|
145
|
+
state=response_content.get("state"),
|
|
146
|
+
result=response_content.get("result"),
|
|
147
|
+
)
|
|
148
|
+
),
|
|
149
|
+
)
|
|
150
|
+
return response_obj
|
|
151
|
+
elif state == "pending":
|
|
152
|
+
logger.info("Report with the given code is still being processed.")
|
|
153
|
+
elif state == "completed":
|
|
154
|
+
logger.info(
|
|
155
|
+
"Finished processing report results",
|
|
156
|
+
extra=dict(
|
|
157
|
+
extra_log_attributes=dict(
|
|
158
|
+
state=response_content.get("result")["state"],
|
|
159
|
+
message=response_content.get("result")["message"],
|
|
160
|
+
)
|
|
161
|
+
),
|
|
162
|
+
)
|
|
163
|
+
return response_obj
|
|
164
|
+
else:
|
|
165
|
+
logger.error("Please try again later.")
|
|
166
|
+
return response_obj
|
|
167
|
+
time.sleep(5)
|
|
168
|
+
number_tries += 1
|
|
169
|
+
return response_obj
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import typing
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from codecov_cli.fallbacks import FallbackFieldEnum
|
|
8
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
9
|
+
from codecov_cli.helpers.request import log_warnings_and_errors_if_any
|
|
10
|
+
from codecov_cli.helpers.versioning_systems import VersioningSystemInterface
|
|
11
|
+
from codecov_cli.helpers.upload_type import ReportType
|
|
12
|
+
from codecov_cli.plugins import select_preparation_plugins
|
|
13
|
+
from codecov_cli.services.upload.file_finder import select_file_finder
|
|
14
|
+
from codecov_cli.services.upload.legacy_upload_sender import LegacyUploadSender
|
|
15
|
+
from codecov_cli.services.upload.network_finder import select_network_finder
|
|
16
|
+
from codecov_cli.services.upload.upload_collector import UploadCollector
|
|
17
|
+
from codecov_cli.services.upload.upload_sender import UploadSender
|
|
18
|
+
from codecov_cli.services.upload_completion import upload_completion_logic
|
|
19
|
+
from codecov_cli.types import RequestResult
|
|
20
|
+
|
|
21
|
+
logger = logging.getLogger("codecovcli")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def do_upload_logic(
|
|
25
|
+
cli_config: typing.Dict,
|
|
26
|
+
versioning_system: VersioningSystemInterface,
|
|
27
|
+
ci_adapter: CIAdapterBase,
|
|
28
|
+
upload_coverage: bool = False,
|
|
29
|
+
*,
|
|
30
|
+
args: dict = None,
|
|
31
|
+
branch: typing.Optional[str],
|
|
32
|
+
build_code: typing.Optional[str],
|
|
33
|
+
build_url: typing.Optional[str],
|
|
34
|
+
commit_sha: str,
|
|
35
|
+
disable_file_fixes: bool = False,
|
|
36
|
+
disable_search: bool = False,
|
|
37
|
+
dry_run: bool = False,
|
|
38
|
+
enterprise_url: typing.Optional[str],
|
|
39
|
+
env_vars: typing.Dict[str, str],
|
|
40
|
+
fail_on_error: bool = False,
|
|
41
|
+
files_search_exclude_folders: typing.List[Path],
|
|
42
|
+
files_search_explicitly_listed_files: typing.List[Path],
|
|
43
|
+
files_search_root_folder: Path,
|
|
44
|
+
flags: typing.List[str],
|
|
45
|
+
gcov_args: typing.Optional[str],
|
|
46
|
+
gcov_executable: typing.Optional[str],
|
|
47
|
+
gcov_ignore: typing.Optional[str],
|
|
48
|
+
gcov_include: typing.Optional[str],
|
|
49
|
+
git_service: typing.Optional[str],
|
|
50
|
+
handle_no_reports_found: bool = False,
|
|
51
|
+
job_code: typing.Optional[str],
|
|
52
|
+
name: typing.Optional[str],
|
|
53
|
+
network_filter: typing.Optional[str],
|
|
54
|
+
network_prefix: typing.Optional[str],
|
|
55
|
+
network_root_folder: Path,
|
|
56
|
+
parent_sha: typing.Optional[str] = None,
|
|
57
|
+
plugin_names: typing.List[str],
|
|
58
|
+
pull_request_number: typing.Optional[str],
|
|
59
|
+
recurse_submodules: bool = False,
|
|
60
|
+
report_code: str,
|
|
61
|
+
slug: typing.Optional[str],
|
|
62
|
+
swift_project: typing.Optional[str],
|
|
63
|
+
token: typing.Optional[str],
|
|
64
|
+
report_type: ReportType = ReportType.COVERAGE,
|
|
65
|
+
use_legacy_uploader: bool = False,
|
|
66
|
+
):
|
|
67
|
+
plugin_config = {
|
|
68
|
+
"folders_to_ignore": files_search_exclude_folders,
|
|
69
|
+
"gcov_args": gcov_args,
|
|
70
|
+
"gcov_executable": gcov_executable,
|
|
71
|
+
"gcov_ignore": gcov_ignore,
|
|
72
|
+
"gcov_include": gcov_include,
|
|
73
|
+
"project_root": files_search_root_folder,
|
|
74
|
+
"swift_project": swift_project,
|
|
75
|
+
}
|
|
76
|
+
if report_type == ReportType.COVERAGE:
|
|
77
|
+
preparation_plugins = select_preparation_plugins(
|
|
78
|
+
cli_config, plugin_names, plugin_config
|
|
79
|
+
)
|
|
80
|
+
elif report_type == ReportType.TEST_RESULTS:
|
|
81
|
+
preparation_plugins = []
|
|
82
|
+
file_selector = select_file_finder(
|
|
83
|
+
files_search_root_folder,
|
|
84
|
+
files_search_exclude_folders,
|
|
85
|
+
files_search_explicitly_listed_files,
|
|
86
|
+
disable_search,
|
|
87
|
+
report_type,
|
|
88
|
+
)
|
|
89
|
+
network_finder = select_network_finder(
|
|
90
|
+
versioning_system,
|
|
91
|
+
recurse_submodules=recurse_submodules,
|
|
92
|
+
network_filter=network_filter,
|
|
93
|
+
network_prefix=network_prefix,
|
|
94
|
+
network_root_folder=network_root_folder,
|
|
95
|
+
)
|
|
96
|
+
collector = UploadCollector(
|
|
97
|
+
preparation_plugins,
|
|
98
|
+
network_finder,
|
|
99
|
+
file_selector,
|
|
100
|
+
disable_file_fixes,
|
|
101
|
+
plugin_config,
|
|
102
|
+
)
|
|
103
|
+
try:
|
|
104
|
+
upload_data = collector.generate_upload_data(report_type)
|
|
105
|
+
except click.ClickException as exp:
|
|
106
|
+
if handle_no_reports_found:
|
|
107
|
+
logger.info(
|
|
108
|
+
"No coverage reports found. Triggering notifications without uploading."
|
|
109
|
+
)
|
|
110
|
+
upload_completion_logic(
|
|
111
|
+
commit_sha=commit_sha,
|
|
112
|
+
slug=slug,
|
|
113
|
+
token=token,
|
|
114
|
+
git_service=git_service,
|
|
115
|
+
enterprise_url=enterprise_url,
|
|
116
|
+
fail_on_error=fail_on_error,
|
|
117
|
+
)
|
|
118
|
+
return RequestResult(
|
|
119
|
+
error=None,
|
|
120
|
+
warnings=None,
|
|
121
|
+
status_code=200,
|
|
122
|
+
text="No coverage reports found. Triggering notifications without uploading.",
|
|
123
|
+
)
|
|
124
|
+
else:
|
|
125
|
+
raise exp
|
|
126
|
+
if use_legacy_uploader:
|
|
127
|
+
sender = LegacyUploadSender()
|
|
128
|
+
else:
|
|
129
|
+
sender = UploadSender()
|
|
130
|
+
logger.debug(f"Selected uploader to use: {type(sender)}")
|
|
131
|
+
ci_service = (
|
|
132
|
+
ci_adapter.get_fallback_value(FallbackFieldEnum.service)
|
|
133
|
+
if ci_adapter is not None
|
|
134
|
+
else None
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
if not dry_run:
|
|
138
|
+
sending_result = sender.send_upload_data(
|
|
139
|
+
upload_data=upload_data,
|
|
140
|
+
commit_sha=commit_sha,
|
|
141
|
+
token=token,
|
|
142
|
+
env_vars=env_vars,
|
|
143
|
+
report_code=report_code,
|
|
144
|
+
report_type=report_type,
|
|
145
|
+
name=name,
|
|
146
|
+
branch=branch,
|
|
147
|
+
slug=slug,
|
|
148
|
+
pull_request_number=pull_request_number,
|
|
149
|
+
build_code=build_code,
|
|
150
|
+
build_url=build_url,
|
|
151
|
+
job_code=job_code,
|
|
152
|
+
flags=flags,
|
|
153
|
+
ci_service=ci_service,
|
|
154
|
+
git_service=git_service,
|
|
155
|
+
enterprise_url=enterprise_url,
|
|
156
|
+
parent_sha=parent_sha,
|
|
157
|
+
upload_coverage=upload_coverage,
|
|
158
|
+
args=args,
|
|
159
|
+
)
|
|
160
|
+
else:
|
|
161
|
+
logger.info("dry-run option activated. NOT sending data to Codecov.")
|
|
162
|
+
sending_result = RequestResult(
|
|
163
|
+
error=None,
|
|
164
|
+
warnings=None,
|
|
165
|
+
status_code=200,
|
|
166
|
+
text="Data NOT sent to Codecov because of dry-run option",
|
|
167
|
+
)
|
|
168
|
+
log_warnings_and_errors_if_any(sending_result, "Upload", fail_on_error)
|
|
169
|
+
return sending_result
|