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,31 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
from pathlib import PosixPath
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from codecov_cli import __version__
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger("codecovcli")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_cli_args(ctx: click.Context):
|
|
13
|
+
args = ctx.obj["cli_args"]
|
|
14
|
+
args["command"] = str(ctx.command.name)
|
|
15
|
+
args["version"] = f"cli-{__version__}"
|
|
16
|
+
args.update(ctx.params)
|
|
17
|
+
if "token" in args:
|
|
18
|
+
del args["token"]
|
|
19
|
+
|
|
20
|
+
filtered_args = {}
|
|
21
|
+
for k in args.keys():
|
|
22
|
+
try:
|
|
23
|
+
if isinstance(args[k], PosixPath):
|
|
24
|
+
filtered_args[k] = str(args[k])
|
|
25
|
+
else:
|
|
26
|
+
json.dumps(args[k])
|
|
27
|
+
filtered_args[k] = args[k]
|
|
28
|
+
except Exception:
|
|
29
|
+
continue
|
|
30
|
+
|
|
31
|
+
return filtered_args
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from codecov_cli.helpers.ci_adapters.appveyor_ci import AppveyorCIAdapter
|
|
5
|
+
from codecov_cli.helpers.ci_adapters.azure_pipelines import AzurePipelinesCIAdapter
|
|
6
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
7
|
+
from codecov_cli.helpers.ci_adapters.bitbucket_ci import BitbucketAdapter
|
|
8
|
+
from codecov_cli.helpers.ci_adapters.bitrise_ci import BitriseCIAdapter
|
|
9
|
+
from codecov_cli.helpers.ci_adapters.buildkite import BuildkiteAdapter
|
|
10
|
+
from codecov_cli.helpers.ci_adapters.circleci import CircleCICIAdapter
|
|
11
|
+
from codecov_cli.helpers.ci_adapters.cirrus_ci import CirrusCIAdapter
|
|
12
|
+
from codecov_cli.helpers.ci_adapters.cloudbuild import GoogleCloudBuildAdapter
|
|
13
|
+
from codecov_cli.helpers.ci_adapters.codebuild import AWSCodeBuildCIAdapter
|
|
14
|
+
from codecov_cli.helpers.ci_adapters.droneci import DroneCIAdapter
|
|
15
|
+
from codecov_cli.helpers.ci_adapters.github_actions import GithubActionsCIAdapter
|
|
16
|
+
from codecov_cli.helpers.ci_adapters.gitlab_ci import GitlabCIAdapter
|
|
17
|
+
from codecov_cli.helpers.ci_adapters.heroku import HerokuCIAdapter
|
|
18
|
+
from codecov_cli.helpers.ci_adapters.jenkins import JenkinsAdapter
|
|
19
|
+
from codecov_cli.helpers.ci_adapters.local import LocalAdapter
|
|
20
|
+
from codecov_cli.helpers.ci_adapters.teamcity import TeamcityAdapter
|
|
21
|
+
from codecov_cli.helpers.ci_adapters.travis_ci import TravisCIAdapter
|
|
22
|
+
from codecov_cli.helpers.ci_adapters.woodpeckerci import WoodpeckerCIAdapter
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger("codecovcli")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def get_ci_adapter(provider_name: str = None) -> Optional[CIAdapterBase]:
|
|
28
|
+
if provider_name:
|
|
29
|
+
for provider in get_ci_providers_list():
|
|
30
|
+
if provider.get_service_name().lower() == provider_name.lower():
|
|
31
|
+
logger.debug(f"Using ci service from provider name: {provider_name}")
|
|
32
|
+
return provider
|
|
33
|
+
else:
|
|
34
|
+
for provider in get_ci_providers_list():
|
|
35
|
+
if provider.detect():
|
|
36
|
+
logger.info(f"ci service found: {provider._get_service()}")
|
|
37
|
+
return provider
|
|
38
|
+
logger.warning("No ci adapter found")
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_ci_providers_list():
|
|
43
|
+
return [
|
|
44
|
+
CircleCICIAdapter(),
|
|
45
|
+
GithubActionsCIAdapter(),
|
|
46
|
+
GitlabCIAdapter(),
|
|
47
|
+
BitbucketAdapter(),
|
|
48
|
+
BitriseCIAdapter(),
|
|
49
|
+
AppveyorCIAdapter(),
|
|
50
|
+
WoodpeckerCIAdapter(),
|
|
51
|
+
HerokuCIAdapter(),
|
|
52
|
+
DroneCIAdapter(),
|
|
53
|
+
BuildkiteAdapter(),
|
|
54
|
+
AzurePipelinesCIAdapter(),
|
|
55
|
+
JenkinsAdapter(),
|
|
56
|
+
CirrusCIAdapter(),
|
|
57
|
+
TeamcityAdapter(),
|
|
58
|
+
TravisCIAdapter(),
|
|
59
|
+
AWSCodeBuildCIAdapter(),
|
|
60
|
+
GoogleCloudBuildAdapter(),
|
|
61
|
+
# local adapter should always be the last one
|
|
62
|
+
LocalAdapter(),
|
|
63
|
+
]
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AppveyorCIAdapter(CIAdapterBase):
|
|
7
|
+
# https://www.appveyor.com/docs/environment-variables/
|
|
8
|
+
|
|
9
|
+
def detect(self) -> bool:
|
|
10
|
+
return bool(os.getenv("CI")) and bool(os.getenv("APPVEYOR"))
|
|
11
|
+
|
|
12
|
+
def _get_commit_sha(self):
|
|
13
|
+
return os.getenv("APPVEYOR_PULL_REQUEST_HEAD_COMMIT") or os.getenv(
|
|
14
|
+
"APPVEYOR_REPO_COMMIT"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
def _get_build_url(self):
|
|
18
|
+
url = os.getenv("APPVEYOR_URL")
|
|
19
|
+
repo_name = os.getenv("APPVEYOR_REPO_NAME")
|
|
20
|
+
build_id = os.getenv("APPVEYOR_BUILD_ID")
|
|
21
|
+
job_id = os.getenv("APPVEYOR_JOB_ID")
|
|
22
|
+
|
|
23
|
+
if url and repo_name and build_id and job_id:
|
|
24
|
+
return f"{url}/project/{repo_name}/builds/{build_id}/job/{job_id}"
|
|
25
|
+
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
def _get_build_code(self):
|
|
29
|
+
return os.getenv("APPVEYOR_JOB_ID")
|
|
30
|
+
|
|
31
|
+
def _get_job_code(self):
|
|
32
|
+
account_name = os.getenv("APPVEYOR_ACCOUNT_NAME")
|
|
33
|
+
slug = os.getenv("APPVEYOR_PROJECT_SLUG")
|
|
34
|
+
build_version = os.getenv("APPVEYOR_BUILD_VERSION")
|
|
35
|
+
|
|
36
|
+
if account_name and slug and build_version:
|
|
37
|
+
return f"{account_name}/{slug}/{build_version}"
|
|
38
|
+
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
def _get_pull_request_number(self):
|
|
42
|
+
return os.getenv("APPVEYOR_PULL_REQUEST_NUMBER")
|
|
43
|
+
|
|
44
|
+
def _get_slug(self):
|
|
45
|
+
return os.getenv("APPVEYOR_REPO_NAME")
|
|
46
|
+
|
|
47
|
+
def _get_branch(self):
|
|
48
|
+
return os.getenv("APPVEYOR_REPO_BRANCH")
|
|
49
|
+
|
|
50
|
+
def _get_service(self):
|
|
51
|
+
return "appveyor"
|
|
52
|
+
|
|
53
|
+
def get_service_name(self):
|
|
54
|
+
return "AppVeyor"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AzurePipelinesCIAdapter(CIAdapterBase):
|
|
7
|
+
# https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#build-variables-devops-services
|
|
8
|
+
|
|
9
|
+
def detect(self) -> bool:
|
|
10
|
+
return bool(os.getenv("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"))
|
|
11
|
+
|
|
12
|
+
def _get_commit_sha(self):
|
|
13
|
+
return os.getenv("SYSTEM_PULLREQUEST_SOURCECOMMITID") or os.getenv(
|
|
14
|
+
"BUILD_SOURCEVERSION"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
def _get_build_url(self):
|
|
18
|
+
if os.getenv("SYSTEM_TEAMPROJECT") and os.getenv("BUILD_BUILDID"):
|
|
19
|
+
return f"{os.getenv('SYSTEM_TEAMFOUNDATIONCOLLECTIONURI')}{os.getenv('SYSTEM_TEAMPROJECT')}/_build/results?buildId={os.getenv('BUILD_BUILDID')}"
|
|
20
|
+
|
|
21
|
+
def _get_build_code(self):
|
|
22
|
+
return os.getenv("BUILD_BUILDNUMBER")
|
|
23
|
+
|
|
24
|
+
def _get_job_code(self):
|
|
25
|
+
return os.getenv("BUILD_BUILDID")
|
|
26
|
+
|
|
27
|
+
def _get_pull_request_number(self):
|
|
28
|
+
return os.getenv("SYSTEM_PULLREQUEST_PULLREQUESTNUMBER") or os.getenv(
|
|
29
|
+
"SYSTEM_PULLREQUEST_PULLREQUESTID"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
def _get_slug(self):
|
|
33
|
+
return os.getenv("BUILD_REPOSITORY_NAME")
|
|
34
|
+
|
|
35
|
+
def _get_branch(self):
|
|
36
|
+
branch = os.getenv("BUILD_SOURCEBRANCH")
|
|
37
|
+
if branch:
|
|
38
|
+
return branch.replace("refs/heads/", "")
|
|
39
|
+
|
|
40
|
+
def _get_service(self):
|
|
41
|
+
return "azure_pipelines"
|
|
42
|
+
|
|
43
|
+
def get_service_name(self):
|
|
44
|
+
return "AzurePipelines"
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
from abc import ABC
|
|
3
|
+
|
|
4
|
+
from codecov_cli.fallbacks import FallbackFieldEnum
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CIAdapterBase(ABC):
|
|
8
|
+
def __init__(self):
|
|
9
|
+
# If a fallbacker has extra fields, they should be added to this dictionary in the fallbacker's constructor.
|
|
10
|
+
self.fallback_to_method = {
|
|
11
|
+
FallbackFieldEnum.branch: self._get_branch,
|
|
12
|
+
FallbackFieldEnum.build_code: self._get_build_code,
|
|
13
|
+
FallbackFieldEnum.build_url: self._get_build_url,
|
|
14
|
+
FallbackFieldEnum.commit_sha: self._get_commit_sha,
|
|
15
|
+
FallbackFieldEnum.slug: self._get_slug,
|
|
16
|
+
FallbackFieldEnum.service: self._get_service,
|
|
17
|
+
FallbackFieldEnum.pull_request_number: self._get_pull_request_number,
|
|
18
|
+
FallbackFieldEnum.job_code: self._get_job_code,
|
|
19
|
+
FallbackFieldEnum.git_service: self._get_git_service,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
def get_fallback_value(
|
|
23
|
+
self, fallback_field: FallbackFieldEnum
|
|
24
|
+
) -> typing.Optional[str]:
|
|
25
|
+
if fallback_field not in self.fallback_to_method:
|
|
26
|
+
raise ValueError("The provided fallback_field is not valid")
|
|
27
|
+
|
|
28
|
+
return self.fallback_to_method[fallback_field]()
|
|
29
|
+
|
|
30
|
+
def detect(self) -> bool:
|
|
31
|
+
"""
|
|
32
|
+
Detects if this CI provider is being used
|
|
33
|
+
Returns bool
|
|
34
|
+
"""
|
|
35
|
+
raise NotImplementedError("`detect()` must be implemented.")
|
|
36
|
+
|
|
37
|
+
def _get_branch(self):
|
|
38
|
+
"""
|
|
39
|
+
Determine the branch of the repository based on envs
|
|
40
|
+
Returns: string
|
|
41
|
+
"""
|
|
42
|
+
raise NotImplementedError("`_get_branch()` must be implemented.")
|
|
43
|
+
|
|
44
|
+
def _get_commit_sha(self):
|
|
45
|
+
"""
|
|
46
|
+
Determine the commit SHA that is being uploaded, based on envs
|
|
47
|
+
Returns: string
|
|
48
|
+
"""
|
|
49
|
+
raise NotImplementedError("`_get_commit_sha()` must be implemented.")
|
|
50
|
+
|
|
51
|
+
def _get_slug(self):
|
|
52
|
+
"""
|
|
53
|
+
Determine the slug (org/repo) based on envs
|
|
54
|
+
Returns: string
|
|
55
|
+
"""
|
|
56
|
+
raise NotImplementedError("`_get_slug()` must be implemented.")
|
|
57
|
+
|
|
58
|
+
def _get_service(self):
|
|
59
|
+
"""
|
|
60
|
+
The CI service name that gets sent to the Codecov uploader as part of the query string
|
|
61
|
+
It gets displayed in the Codecov UI
|
|
62
|
+
Returns: string
|
|
63
|
+
"""
|
|
64
|
+
raise NotImplementedError("`_get_service()` must be implemented.")
|
|
65
|
+
|
|
66
|
+
def _get_build_url(self):
|
|
67
|
+
"""
|
|
68
|
+
Determine the build URL for use in the Codecov UI
|
|
69
|
+
Returns: string
|
|
70
|
+
"""
|
|
71
|
+
raise NotImplementedError("`_get_build_url()` must be implemented.")
|
|
72
|
+
|
|
73
|
+
def _get_build_code(self):
|
|
74
|
+
"""
|
|
75
|
+
Determine the build number, based on envs
|
|
76
|
+
Returns: string
|
|
77
|
+
"""
|
|
78
|
+
raise NotImplementedError("`_get_build_code()` must be implemented.")
|
|
79
|
+
|
|
80
|
+
def _get_job_code(self):
|
|
81
|
+
"""
|
|
82
|
+
Determine the job number, based on envs
|
|
83
|
+
Returns: string
|
|
84
|
+
"""
|
|
85
|
+
raise NotImplementedError("`_get_job_code()` must be implemented.")
|
|
86
|
+
|
|
87
|
+
def _get_pull_request_number(self):
|
|
88
|
+
"""
|
|
89
|
+
Determine the PR number, based on envs
|
|
90
|
+
Returns: string
|
|
91
|
+
"""
|
|
92
|
+
raise NotImplementedError("`_get_pull_request_number()` must be implemented.")
|
|
93
|
+
|
|
94
|
+
def get_service_name(self):
|
|
95
|
+
"""
|
|
96
|
+
The CI Service name that gets displayed when running the uploader
|
|
97
|
+
Returns: string
|
|
98
|
+
"""
|
|
99
|
+
raise NotImplementedError("`get_service_name()` must be implemented.")
|
|
100
|
+
|
|
101
|
+
def _get_git_service(self):
|
|
102
|
+
return None
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BitbucketAdapter(CIAdapterBase):
|
|
7
|
+
# https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
|
|
8
|
+
|
|
9
|
+
def detect(self) -> bool:
|
|
10
|
+
return bool(os.getenv("CI")) and bool(os.getenv("BITBUCKET_BUILD_NUMBER"))
|
|
11
|
+
|
|
12
|
+
def _get_commit_sha(self):
|
|
13
|
+
commit = os.getenv("BITBUCKET_COMMIT")
|
|
14
|
+
|
|
15
|
+
if not commit or len(commit) == 12:
|
|
16
|
+
return None
|
|
17
|
+
|
|
18
|
+
return commit
|
|
19
|
+
|
|
20
|
+
def _get_build_url(self):
|
|
21
|
+
return None
|
|
22
|
+
|
|
23
|
+
def _get_build_code(self):
|
|
24
|
+
return os.getenv("BITBUCKET_BUILD_NUMBER")
|
|
25
|
+
|
|
26
|
+
def _get_job_code(self):
|
|
27
|
+
return os.getenv("BITBUCKET_BUILD_NUMBER")
|
|
28
|
+
|
|
29
|
+
def _get_pull_request_number(self):
|
|
30
|
+
return os.getenv("BITBUCKET_PR_ID")
|
|
31
|
+
|
|
32
|
+
def _get_slug(self):
|
|
33
|
+
return os.getenv("BITBUCKET_REPO_FULL_NAME")
|
|
34
|
+
|
|
35
|
+
def _get_branch(self):
|
|
36
|
+
return os.getenv("BITBUCKET_BRANCH")
|
|
37
|
+
|
|
38
|
+
def _get_service(self):
|
|
39
|
+
return "bitbucket"
|
|
40
|
+
|
|
41
|
+
def get_service_name(self):
|
|
42
|
+
return "Bitbucket"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BitriseCIAdapter(CIAdapterBase):
|
|
7
|
+
# https://devcenter.bitrise.io/en/references/available-environment-variables.html
|
|
8
|
+
|
|
9
|
+
def detect(self) -> bool:
|
|
10
|
+
return bool(os.getenv("CI")) and bool(os.getenv("BITRISE_IO"))
|
|
11
|
+
|
|
12
|
+
def _get_commit_sha(self):
|
|
13
|
+
return os.getenv("GIT_CLONE_COMMIT_HASH")
|
|
14
|
+
|
|
15
|
+
def _get_build_url(self):
|
|
16
|
+
return os.getenv("BITRISE_BUILD_URL")
|
|
17
|
+
|
|
18
|
+
def _get_build_code(self):
|
|
19
|
+
return os.getenv("BITRISE_BUILD_NUMBER")
|
|
20
|
+
|
|
21
|
+
def _get_job_code(self):
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
def _get_pull_request_number(self):
|
|
25
|
+
return os.getenv("BITRISE_PULL_REQUEST")
|
|
26
|
+
|
|
27
|
+
def _get_slug(self):
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
def _get_branch(self):
|
|
31
|
+
return os.getenv("BITRISE_GIT_BRANCH")
|
|
32
|
+
|
|
33
|
+
def _get_service(self):
|
|
34
|
+
return "bitrise"
|
|
35
|
+
|
|
36
|
+
def get_service_name(self):
|
|
37
|
+
return "Bitrise"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BuildkiteAdapter(CIAdapterBase):
|
|
7
|
+
# https://buildkite.com/docs/pipelines/environment-variables
|
|
8
|
+
|
|
9
|
+
def detect(self) -> bool:
|
|
10
|
+
return bool(os.getenv("BUILDKITE"))
|
|
11
|
+
|
|
12
|
+
def _get_branch(self):
|
|
13
|
+
return os.getenv("BUILDKITE_BRANCH")
|
|
14
|
+
|
|
15
|
+
def _get_build_code(self):
|
|
16
|
+
return os.getenv("BUILDKITE_BUILD_NUMBER")
|
|
17
|
+
|
|
18
|
+
def _get_build_url(self):
|
|
19
|
+
return os.getenv("BUILDKITE_BUILD_URL")
|
|
20
|
+
|
|
21
|
+
def _get_commit_sha(self):
|
|
22
|
+
return os.getenv("BUILDKITE_COMMIT")
|
|
23
|
+
|
|
24
|
+
def _get_slug(self):
|
|
25
|
+
org = os.getenv("BUILDKITE_ORGANIZATION_SLUG")
|
|
26
|
+
repo = os.getenv("BUILDKITE_PIPELINE_SLUG")
|
|
27
|
+
if org and repo:
|
|
28
|
+
return f"{org}/{repo}"
|
|
29
|
+
return None
|
|
30
|
+
|
|
31
|
+
def _get_service(self):
|
|
32
|
+
return "buildkite"
|
|
33
|
+
|
|
34
|
+
def _get_pull_request_number(self):
|
|
35
|
+
pr_number = os.getenv("BUILDKITE_PULL_REQUEST")
|
|
36
|
+
# The number of the pull request, if this branch is a pull request.
|
|
37
|
+
if pr_number != "false":
|
|
38
|
+
return pr_number
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
def _get_job_code(self):
|
|
42
|
+
return os.getenv("BUILDKITE_JOB_ID")
|
|
43
|
+
|
|
44
|
+
def get_service_name(self):
|
|
45
|
+
return "BuildKite"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CircleCICIAdapter(CIAdapterBase):
|
|
7
|
+
# https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
|
|
8
|
+
def detect(self) -> bool:
|
|
9
|
+
return bool(os.getenv("CI")) and bool(os.getenv("CIRCLECI"))
|
|
10
|
+
|
|
11
|
+
def _get_commit_sha(self):
|
|
12
|
+
return os.getenv("CIRCLE_SHA1")
|
|
13
|
+
|
|
14
|
+
def _get_build_url(self):
|
|
15
|
+
return os.getenv("CIRCLE_BUILD_URL")
|
|
16
|
+
|
|
17
|
+
def _get_build_code(self):
|
|
18
|
+
return os.getenv("CIRCLE_BUILD_NUM")
|
|
19
|
+
|
|
20
|
+
def _get_job_code(self):
|
|
21
|
+
return os.getenv("CIRCLE_NODE_INDEX")
|
|
22
|
+
|
|
23
|
+
def _get_pull_request_number(self):
|
|
24
|
+
return os.getenv("CIRCLE_PR_NUMBER")
|
|
25
|
+
|
|
26
|
+
def _get_slug(self):
|
|
27
|
+
project_username = os.getenv("CIRCLE_PROJECT_USERNAME")
|
|
28
|
+
project_repo_name = os.getenv("CIRCLE_PROJECT_REPONAME")
|
|
29
|
+
|
|
30
|
+
if project_repo_name and project_username:
|
|
31
|
+
return f"{project_username}/{project_repo_name}"
|
|
32
|
+
|
|
33
|
+
repo_url = os.getenv("CIRCLE_REPOSITORY_URL")
|
|
34
|
+
|
|
35
|
+
if repo_url:
|
|
36
|
+
return repo_url.split(":")[1].split(".git")[0]
|
|
37
|
+
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
def _get_branch(self):
|
|
41
|
+
return os.getenv("CIRCLE_BRANCH")
|
|
42
|
+
|
|
43
|
+
def _get_service(self):
|
|
44
|
+
return "circleci"
|
|
45
|
+
|
|
46
|
+
def get_service_name(self):
|
|
47
|
+
return "CircleCI"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CirrusCIAdapter(CIAdapterBase):
|
|
7
|
+
# https://cirrus-ci.org/guide/writing-tasks/#environment-variables
|
|
8
|
+
def detect(self) -> bool:
|
|
9
|
+
return bool(os.getenv("CIRRUS_CI"))
|
|
10
|
+
|
|
11
|
+
def _get_branch(self):
|
|
12
|
+
return os.getenv("CIRRUS_BRANCH")
|
|
13
|
+
|
|
14
|
+
def _get_build_code(self):
|
|
15
|
+
return os.getenv("CIRRUS_BUILD_ID")
|
|
16
|
+
|
|
17
|
+
def _get_build_url(self):
|
|
18
|
+
return None
|
|
19
|
+
|
|
20
|
+
def _get_commit_sha(self):
|
|
21
|
+
return os.getenv("CIRRUS_CHANGE_IN_REPO")
|
|
22
|
+
|
|
23
|
+
def _get_slug(self):
|
|
24
|
+
return os.getenv("CIRRUS_REPO_FULL_NAME")
|
|
25
|
+
|
|
26
|
+
def _get_service(self):
|
|
27
|
+
return "cirrus"
|
|
28
|
+
|
|
29
|
+
def _get_pull_request_number(self):
|
|
30
|
+
return os.getenv("CIRRUS_PR")
|
|
31
|
+
|
|
32
|
+
def _get_job_code(self):
|
|
33
|
+
return os.getenv("CIRRUS_TASK_ID")
|
|
34
|
+
|
|
35
|
+
def get_service_name(self):
|
|
36
|
+
return "CirrusCI"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class GoogleCloudBuildAdapter(CIAdapterBase):
|
|
7
|
+
"""
|
|
8
|
+
Google Cloud Build uses variable substitutions in the builds
|
|
9
|
+
https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values
|
|
10
|
+
For these to be available as environment variables, so this adapter
|
|
11
|
+
can read the values, you have to manually map the substitution variables to
|
|
12
|
+
environment variables on the build step, like this
|
|
13
|
+
env:
|
|
14
|
+
- '_PR_NUMBER=$_PR_NUMBER'
|
|
15
|
+
- 'BRANCH_NAME=$BRANCH_NAME'
|
|
16
|
+
- 'BUILD_ID=$BUILD_ID'
|
|
17
|
+
- 'COMMIT_SHA=$COMMIT_SHA'
|
|
18
|
+
- 'LOCATION=$LOCATION'
|
|
19
|
+
- 'PROJECT_ID=$PROJECT_ID'
|
|
20
|
+
- 'PROJECT_NUMBER=$PROJECT_NUMBER'
|
|
21
|
+
- 'REF_NAME=$REF_NAME'
|
|
22
|
+
- 'REPO_FULL_NAME=$REPO_FULL_NAME'
|
|
23
|
+
- 'TRIGGER_NAME=$TRIGGER_NAME'
|
|
24
|
+
Read more about manual substitution mapping here:
|
|
25
|
+
https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values#map_substitutions_manually
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def detect(self) -> bool:
|
|
29
|
+
return all(
|
|
30
|
+
list(
|
|
31
|
+
map(os.getenv, ["LOCATION", "PROJECT_NUMBER", "PROJECT_ID", "BUILD_ID"])
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def _get_branch(self):
|
|
36
|
+
return os.getenv("BRANCH_NAME")
|
|
37
|
+
|
|
38
|
+
def _get_build_code(self):
|
|
39
|
+
return os.getenv("BUILD_ID")
|
|
40
|
+
|
|
41
|
+
def _get_commit_sha(self):
|
|
42
|
+
return os.getenv("COMMIT_SHA")
|
|
43
|
+
|
|
44
|
+
def _get_slug(self):
|
|
45
|
+
return os.getenv("REPO_FULL_NAME")
|
|
46
|
+
|
|
47
|
+
def _get_build_url(self):
|
|
48
|
+
# to build the url, the environment variables LOCATION, PROJECT_ID and BUILD_ID are needed
|
|
49
|
+
if not all(list(map(os.getenv, ["LOCATION", "PROJECT_ID", "BUILD_ID"]))):
|
|
50
|
+
return None
|
|
51
|
+
|
|
52
|
+
location = os.getenv("LOCATION")
|
|
53
|
+
project_id = os.getenv("PROJECT_ID")
|
|
54
|
+
build_id = os.getenv("BUILD_ID")
|
|
55
|
+
|
|
56
|
+
return f"https://console.cloud.google.com/cloud-build/builds;region={location}/{build_id}?project={project_id}"
|
|
57
|
+
|
|
58
|
+
def _get_pull_request_number(self):
|
|
59
|
+
pr_num = os.getenv("_PR_NUMBER")
|
|
60
|
+
return pr_num if pr_num != "" else None
|
|
61
|
+
|
|
62
|
+
def _get_job_code(self):
|
|
63
|
+
job_code = os.getenv("TRIGGER_NAME")
|
|
64
|
+
return job_code if job_code != "" else None
|
|
65
|
+
|
|
66
|
+
def _get_service(self):
|
|
67
|
+
return "google_cloud_build"
|
|
68
|
+
|
|
69
|
+
def get_service_name(self):
|
|
70
|
+
return "GoogleCloudBuild"
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
|
|
4
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AWSCodeBuildCIAdapter(CIAdapterBase):
|
|
8
|
+
# https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
|
|
9
|
+
def detect(self) -> bool:
|
|
10
|
+
return bool(os.getenv("CODEBUILD_CI"))
|
|
11
|
+
|
|
12
|
+
def _get_branch(self):
|
|
13
|
+
branch = os.getenv("CODEBUILD_WEBHOOK_HEAD_REF")
|
|
14
|
+
if branch:
|
|
15
|
+
return re.sub(r"^refs\/heads\/", "", branch)
|
|
16
|
+
return None
|
|
17
|
+
|
|
18
|
+
def _get_build_code(self):
|
|
19
|
+
return os.getenv("CODEBUILD_BUILD_ID")
|
|
20
|
+
|
|
21
|
+
def _get_build_url(self):
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
def _get_commit_sha(self):
|
|
25
|
+
return os.getenv("CODEBUILD_RESOLVED_SOURCE_VERSION")
|
|
26
|
+
|
|
27
|
+
def _get_slug(self):
|
|
28
|
+
slug = os.getenv("CODEBUILD_SOURCE_REPO_URL")
|
|
29
|
+
if slug:
|
|
30
|
+
slug = re.sub(r"^.*github.com\/", "", slug)
|
|
31
|
+
slug = re.sub(r"^.*gitlab.com\/", "", slug)
|
|
32
|
+
slug = re.sub(r"^.*bitbucket.com\/", "", slug)
|
|
33
|
+
return re.sub(r"\.git$", "", slug)
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
def _get_service(self):
|
|
37
|
+
return "AWS CodeBuild"
|
|
38
|
+
|
|
39
|
+
def _get_pull_request_number(self):
|
|
40
|
+
pr = os.getenv("CODEBUILD_SOURCE_VERSION")
|
|
41
|
+
if pr and pr.startswith("pr/"):
|
|
42
|
+
return re.sub(r"^pr\/", "", pr)
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
def _get_job_code(self):
|
|
46
|
+
return os.getenv("CODEBUILD_BUILD_ID")
|
|
47
|
+
|
|
48
|
+
def get_service_name(self):
|
|
49
|
+
return "AWSCodeBuild"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from codecov_cli.helpers.ci_adapters.base import CIAdapterBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DroneCIAdapter(CIAdapterBase):
|
|
7
|
+
# https://docs.drone.io/pipeline/environment/reference/
|
|
8
|
+
def detect(self) -> bool:
|
|
9
|
+
return bool(os.getenv("DRONE"))
|
|
10
|
+
|
|
11
|
+
def _get_branch(self):
|
|
12
|
+
return os.getenv("DRONE_BRANCH")
|
|
13
|
+
|
|
14
|
+
def _get_build_code(self):
|
|
15
|
+
return os.getenv("DRONE_BUILD_NUMBER")
|
|
16
|
+
|
|
17
|
+
def _get_build_url(self):
|
|
18
|
+
return os.getenv("DRONE_BUILD_LINK")
|
|
19
|
+
|
|
20
|
+
def _get_commit_sha(self):
|
|
21
|
+
return os.getenv("DRONE_COMMIT_SHA")
|
|
22
|
+
|
|
23
|
+
def _get_slug(self):
|
|
24
|
+
return os.getenv("DRONE_REPO")
|
|
25
|
+
|
|
26
|
+
def _get_service(self):
|
|
27
|
+
return "droneci"
|
|
28
|
+
|
|
29
|
+
def _get_pull_request_number(self):
|
|
30
|
+
return os.getenv("DRONE_PULL_REQUEST")
|
|
31
|
+
|
|
32
|
+
def _get_job_code(self):
|
|
33
|
+
return None
|
|
34
|
+
|
|
35
|
+
def get_service_name(self):
|
|
36
|
+
return "DroneCI"
|