diff --git a/README.md b/README.md index 71f2730a..4b6ffa65 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,7 @@ Codecov-cli supports user input. These inputs, along with their descriptions and | :---: | :---: | :---: | | -C, --sha, --commit-sha TEXT |Commit SHA (with 40 chars) | Required | -r, --slug TEXT |owner/repo slug used instead of the private repo token in Self-hosted | Required -| -t, --token UUID |Codecov upload token | Required +| -t, --token TEXT |Codecov upload token | Required | --git-service | Git provider. Options: github, gitlab, bitbucket, github_enterprise, gitlab_enterprise, bitbucket_server | Optional | -h,--help |Show this message and exit. diff --git a/codecov_cli/commands/base_picking.py b/codecov_cli/commands/base_picking.py index afe0f531..16d70bd9 100644 --- a/codecov_cli/commands/base_picking.py +++ b/codecov_cli/commands/base_picking.py @@ -1,6 +1,5 @@ import logging import typing -import uuid import click @@ -36,7 +35,6 @@ "-t", "--token", help="Codecov upload token", - type=click.UUID, envvar="CODECOV_TOKEN", ) @click.option( @@ -51,7 +49,7 @@ def pr_base_picking( base_sha: str, pr: typing.Optional[int], slug: typing.Optional[str], - token: typing.Optional[uuid.UUID], + token: typing.Optional[str], service: typing.Optional[str], ): enterprise_url = ctx.obj.get("enterprise_url") diff --git a/codecov_cli/commands/commit.py b/codecov_cli/commands/commit.py index 1b2bbb98..15a879d4 100644 --- a/codecov_cli/commands/commit.py +++ b/codecov_cli/commands/commit.py @@ -1,6 +1,5 @@ import logging import typing -import uuid import click @@ -42,7 +41,7 @@ def create_commit( pull_request_number: typing.Optional[int], branch: typing.Optional[str], slug: typing.Optional[str], - token: typing.Optional[uuid.UUID], + token: typing.Optional[str], git_service: typing.Optional[str], fail_on_error: bool, ): diff --git a/codecov_cli/commands/create_report_result.py b/codecov_cli/commands/create_report_result.py index 94bae460..1aa1c21f 100644 --- a/codecov_cli/commands/create_report_result.py +++ b/codecov_cli/commands/create_report_result.py @@ -1,10 +1,7 @@ import logging -import uuid import click -from codecov_cli.fallbacks import CodecovOption, FallbackFieldEnum -from codecov_cli.helpers.git import GitService from codecov_cli.helpers.options import global_options from codecov_cli.services.report import create_report_results_logic @@ -23,7 +20,7 @@ def create_report_results( code: str, slug: str, git_service: str, - token: uuid.UUID, + token: str, fail_on_error: bool, ): enterprise_url = ctx.obj.get("enterprise_url") diff --git a/codecov_cli/commands/empty_upload.py b/codecov_cli/commands/empty_upload.py index 4c429144..7cdd5428 100644 --- a/codecov_cli/commands/empty_upload.py +++ b/codecov_cli/commands/empty_upload.py @@ -1,6 +1,5 @@ import logging import typing -import uuid import click @@ -19,7 +18,7 @@ def empty_upload( ctx, commit_sha: str, slug: typing.Optional[str], - token: typing.Optional[uuid.UUID], + token: typing.Optional[str], git_service: typing.Optional[str], fail_on_error: typing.Optional[bool], ): diff --git a/codecov_cli/commands/get_report_results.py b/codecov_cli/commands/get_report_results.py index e676afac..a10ccefa 100644 --- a/codecov_cli/commands/get_report_results.py +++ b/codecov_cli/commands/get_report_results.py @@ -1,5 +1,4 @@ import logging -import uuid import click @@ -24,7 +23,7 @@ def get_report_results( code: str, slug: str, git_service: str, - token: uuid.UUID, + token: str, fail_on_error: bool, ): enterprise_url = ctx.obj.get("enterprise_url") diff --git a/codecov_cli/commands/report.py b/codecov_cli/commands/report.py index 02ea8ec3..6244c228 100644 --- a/codecov_cli/commands/report.py +++ b/codecov_cli/commands/report.py @@ -1,10 +1,7 @@ import logging -import uuid import click -from codecov_cli.fallbacks import CodecovOption, FallbackFieldEnum -from codecov_cli.helpers.git import GitService from codecov_cli.helpers.options import global_options from codecov_cli.services.report import create_report_logic @@ -23,7 +20,7 @@ def create_report( code: str, slug: str, git_service: str, - token: uuid.UUID, + token: str, fail_on_error: bool, ): enterprise_url = ctx.obj.get("enterprise_url") diff --git a/codecov_cli/commands/send_notifications.py b/codecov_cli/commands/send_notifications.py index ee962cfe..779e4054 100644 --- a/codecov_cli/commands/send_notifications.py +++ b/codecov_cli/commands/send_notifications.py @@ -1,6 +1,5 @@ import logging import typing -import uuid import click @@ -19,7 +18,7 @@ def send_notifications( ctx, commit_sha: str, slug: typing.Optional[str], - token: typing.Optional[uuid.UUID], + token: typing.Optional[str], git_service: typing.Optional[str], fail_on_error: bool, ): diff --git a/codecov_cli/commands/upload.py b/codecov_cli/commands/upload.py index cf6a4b1b..9ee04b99 100644 --- a/codecov_cli/commands/upload.py +++ b/codecov_cli/commands/upload.py @@ -2,7 +2,6 @@ import os import pathlib import typing -import uuid import click @@ -185,7 +184,7 @@ def do_upload( coverage_files_search_explicitly_listed_files: typing.List[pathlib.Path], disable_search: bool, disable_file_fixes: bool, - token: typing.Optional[uuid.UUID], + token: typing.Optional[str], plugin_names: typing.List[str], branch: typing.Optional[str], slug: typing.Optional[str], diff --git a/codecov_cli/commands/upload_process.py b/codecov_cli/commands/upload_process.py index 67fd14da..b8270b79 100644 --- a/codecov_cli/commands/upload_process.py +++ b/codecov_cli/commands/upload_process.py @@ -1,7 +1,6 @@ import logging import pathlib import typing -import uuid import click @@ -38,7 +37,7 @@ def upload_process( coverage_files_search_explicitly_listed_files: typing.List[pathlib.Path], disable_search: bool, disable_file_fixes: bool, - token: typing.Optional[uuid.UUID], + token: typing.Optional[str], plugin_names: typing.List[str], branch: typing.Optional[str], slug: typing.Optional[str], diff --git a/codecov_cli/helpers/options.py b/codecov_cli/helpers/options.py index 6b9ceede..ae22c633 100644 --- a/codecov_cli/helpers/options.py +++ b/codecov_cli/helpers/options.py @@ -31,7 +31,6 @@ "-t", "--token", help="Codecov upload token", - type=click.UUID, envvar="CODECOV_TOKEN", ), click.option( diff --git a/codecov_cli/helpers/request.py b/codecov_cli/helpers/request.py index 8596e3c7..3cfaa499 100644 --- a/codecov_cli/helpers/request.py +++ b/codecov_cli/helpers/request.py @@ -1,5 +1,4 @@ import logging -import uuid from time import sleep import click @@ -45,13 +44,11 @@ def send_post_request( return request_result(resp) -def get_token_header_or_fail(token: uuid.UUID) -> dict: +def get_token_header_or_fail(token: str) -> dict: if token is None: raise click.ClickException( "Codecov token not found. Please provide Codecov token with -t flag." ) - if not isinstance(token, uuid.UUID): - raise click.ClickException(f"Token must be UUID. Received {type(token)}") return {"Authorization": f"token {token.hex}"} diff --git a/codecov_cli/services/commit/__init__.py b/codecov_cli/services/commit/__init__.py index b07117eb..14ded429 100644 --- a/codecov_cli/services/commit/__init__.py +++ b/codecov_cli/services/commit/__init__.py @@ -1,6 +1,5 @@ import logging import typing -import uuid from codecov_cli.helpers.config import CODECOV_API_URL from codecov_cli.helpers.encoder import encode_slug @@ -19,7 +18,7 @@ def create_commit_logic( pr: typing.Optional[str], branch: typing.Optional[str], slug: typing.Optional[str], - token: uuid.UUID, + token: str, service: typing.Optional[str], enterprise_url: typing.Optional[str] = None, fail_on_error: bool = False, diff --git a/codecov_cli/services/report/__init__.py b/codecov_cli/services/report/__init__.py index d4173ee4..3c58b950 100644 --- a/codecov_cli/services/report/__init__.py +++ b/codecov_cli/services/report/__init__.py @@ -1,10 +1,6 @@ import json import logging import time -import typing -import uuid - -import requests from codecov_cli.helpers.config import CODECOV_API_URL from codecov_cli.helpers.encoder import encode_slug @@ -24,7 +20,7 @@ def create_report_logic( code: str, slug: str, service: str, - token: uuid.UUID, + token: str, enterprise_url: str, fail_on_error: bool = False, ): @@ -51,7 +47,7 @@ def create_report_results_logic( code: str, slug: str, service: str, - token: uuid.UUID, + token: str, enterprise_url: str, fail_on_error: bool = False, ): diff --git a/codecov_cli/services/upload/__init__.py b/codecov_cli/services/upload/__init__.py index 959d6ed9..c012beb4 100644 --- a/codecov_cli/services/upload/__init__.py +++ b/codecov_cli/services/upload/__init__.py @@ -1,6 +1,5 @@ import logging import typing -import uuid from pathlib import Path import click @@ -39,7 +38,7 @@ def do_upload_logic( coverage_files_search_exclude_folders: typing.List[Path], coverage_files_search_explicitly_listed_files: typing.List[Path], plugin_names: typing.List[str], - token: uuid.UUID, + token: str, branch: typing.Optional[str], slug: typing.Optional[str], pull_request_number: typing.Optional[str], diff --git a/codecov_cli/services/upload/legacy_upload_sender.py b/codecov_cli/services/upload/legacy_upload_sender.py index 99ff6429..53ab4bf4 100644 --- a/codecov_cli/services/upload/legacy_upload_sender.py +++ b/codecov_cli/services/upload/legacy_upload_sender.py @@ -1,10 +1,7 @@ import logging import typing -import uuid from dataclasses import dataclass -import requests - from codecov_cli import __version__ as codecov_cli_version from codecov_cli.helpers.config import LEGACY_CODECOV_API_URL from codecov_cli.helpers.request import send_post_request, send_put_request @@ -39,7 +36,7 @@ def send_upload_data( self, upload_data: UploadCollectionResult, commit_sha: str, - token: uuid.UUID, + token: str, env_vars: typing.Dict[str, str], report_code: str = None, name: typing.Optional[str] = None, diff --git a/codecov_cli/services/upload/upload_sender.py b/codecov_cli/services/upload/upload_sender.py index af9dc7b5..9c92d577 100644 --- a/codecov_cli/services/upload/upload_sender.py +++ b/codecov_cli/services/upload/upload_sender.py @@ -2,7 +2,6 @@ import json import logging import typing -import uuid import zlib from typing import Any, Dict @@ -28,7 +27,7 @@ def send_upload_data( self, upload_data: UploadCollectionResult, commit_sha: str, - token: uuid.UUID, + token: str, env_vars: typing.Dict[str, str], report_code: str, name: typing.Optional[str] = None, diff --git a/tests/commands/test_invoke_upload_process.py b/tests/commands/test_invoke_upload_process.py index 026c128d..7476588b 100644 --- a/tests/commands/test_invoke_upload_process.py +++ b/tests/commands/test_invoke_upload_process.py @@ -70,7 +70,7 @@ def test_upload_process_options(mocker): " -C, --sha, --commit-sha TEXT Commit SHA (with 40 chars) [required]", " -Z, --fail-on-error Exit with non-zero code in case of error", " --git-service [github|gitlab|bitbucket|github_enterprise|gitlab_enterprise|bitbucket_server]", - " -t, --token UUID Codecov upload token", + " -t, --token TEXT Codecov upload token", " -r, --slug TEXT owner/repo slug used instead of the private", " repo token in Self-hosted", " --report-code TEXT The code of the report. If unsure, leave", diff --git a/tests/helpers/test_legacy_upload_sender.py b/tests/helpers/test_legacy_upload_sender.py index 405f87e0..8889d6ec 100644 --- a/tests/helpers/test_legacy_upload_sender.py +++ b/tests/helpers/test_legacy_upload_sender.py @@ -1,4 +1,3 @@ -import uuid from urllib import parse import pytest @@ -11,7 +10,7 @@ from tests.data import reports_examples upload_collection = UploadCollectionResult(["1", "apple.py", "3"], [], []) -random_token = uuid.UUID("f359afb9-8a2a-42ab-a448-c3d267ff495b") +random_token = "f359afb9-8a2a-42ab-a448-c3d267ff495b" random_sha = "845548c6b95223f12e8317a1820705f64beaf69e" named_upload_data = { "name": "name", diff --git a/tests/helpers/test_request.py b/tests/helpers/test_request.py index 4e65f7c5..5b2c0e69 100644 --- a/tests/helpers/test_request.py +++ b/tests/helpers/test_request.py @@ -62,13 +62,6 @@ def test_get_token_header_or_fail(): == "Codecov token not found. Please provide Codecov token with -t flag." ) - # Test with an invalid token type - token = "invalid_token" - with pytest.raises(Exception) as e: - get_token_header_or_fail(token) - - assert str(e.value) == f"Token must be UUID. Received {type(token)}" - def test_request_retry(mocker, valid_response): expected_response = request_result(valid_response) diff --git a/tests/helpers/test_upload_sender.py b/tests/helpers/test_upload_sender.py index 26fa5511..c9943740 100644 --- a/tests/helpers/test_upload_sender.py +++ b/tests/helpers/test_upload_sender.py @@ -1,5 +1,4 @@ import json -import uuid from pathlib import Path import pytest @@ -13,7 +12,7 @@ from tests.data import reports_examples upload_collection = UploadCollectionResult(["1", "apple.py", "3"], [], []) -random_token = uuid.UUID("f359afb9-8a2a-42ab-a448-c3d267ff495b") +random_token = "f359afb9-8a2a-42ab-a448-c3d267ff495b" random_sha = "845548c6b95223f12e8317a1820705f64beaf69e" named_upload_data = { "report_code": "report_code",