Skip to content

Commit 327cbef

Browse files
feat: create new upload command (#77)
Fixes CCMRG-1362 Fixes CCMRG-1361 we wanted to have a simplified interface so we're going to create a new "upload" command. This command is just a copy of upload-coverage but obviously with a diffrent name and it also accepts `test-results` alongside `test_results` for the "--report-type" option
1 parent c3ab689 commit 327cbef

File tree

4 files changed

+93
-3
lines changed

4 files changed

+93
-3
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,6 @@ jobs:
114114
- name: Dogfooding sentry-prevent-cli
115115
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'getsentry' }}
116116
run: |
117-
uv run --project prevent-cli sentry-prevent-cli -v do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag sentry-prevent-cli
118-
uv run --project prevent-cli sentry-prevent-cli do-upload --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag sentry-prevent-cli
117+
uv run --project prevent-cli sentry-prevent-cli upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag sentry-prevent-cli
118+
uv run --project prevent-cli sentry-prevent-cli upload --report-type test_results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag sentry-prevent-cli
119+
uv run --project prevent-cli sentry-prevent-cli upload --report-type test-results --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python${{matrix.python-version}} --flag sentry-prevent-cli

codecov-cli/codecov_cli/helpers/upload_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ReportType(Enum):
99
def report_type_from_str(report_type_str: str) -> ReportType:
1010
if report_type_str == "coverage":
1111
return ReportType.COVERAGE
12-
elif report_type_str == "test_results":
12+
elif report_type_str.replace("-", "_") == "test_results":
1313
return ReportType.TEST_RESULTS
1414
else:
1515
raise ValueError(f"Invalid upload type: {report_type_str}")

prevent-cli/preventcli_commands

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Commands:
1818
pr-base-picking
1919
process-test-results
2020
send-notifications
21+
upload
2122
upload-coverage
2223
upload-process
2324

@@ -189,6 +190,78 @@ Options:
189190
repo token in Self-hosted
190191
-h, --help Show this message and exit.
191192

193+
Usage: sentry-prevent-cli upload [OPTIONS]
194+
195+
Options:
196+
-C, --sha, --commit-sha TEXT Commit SHA (with 40 chars) [required]
197+
-Z, --fail-on-error Exit with non-zero code in case of error
198+
--git-service [github|gitlab|bitbucket|github_enterprise|gitlab_enterprise|bitbucket_server]
199+
-t, --token TEXT Codecov upload token
200+
-r, --slug TEXT owner/repo slug used instead of the private
201+
repo token in Self-hosted
202+
--network-root-folder PATH Root folder from which to consider paths on
203+
the network section [default: (Current
204+
working directory)]
205+
-s, --dir, --coverage-files-search-root-folder, --files-search-root-folder PATH
206+
Folder where to search for coverage files
207+
[default: (Current Working Directory)]
208+
--exclude, --coverage-files-search-exclude-folder, --files-search-exclude-folder PATH
209+
Folders to exclude from search
210+
-f, --file, --coverage-files-search-direct-file, --files-search-direct-file PATH
211+
Explicit files to upload. These will be
212+
added to the coverage files found for
213+
upload. If you wish to only upload the
214+
specified files, please consider using
215+
--disable-search to disable uploading other
216+
files.
217+
--recurse-submodules Whether to enumerate files inside of
218+
submodules for path-fixing purposes. Off by
219+
default.
220+
--disable-search Disable search for coverage files. This is
221+
helpful when specifying what files you want
222+
to upload with the --file option.
223+
--disable-file-fixes Disable file fixes to ignore common lines
224+
from coverage (e.g. blank lines or empty
225+
brackets)
226+
-b, --build, --build-code TEXT Specify the build number manually
227+
--build-url TEXT The URL of the build where this is running
228+
--job-code TEXT
229+
-n, --name TEXT Custom defined name of the upload. Visible
230+
in Codecov UI
231+
-B, --branch TEXT Branch to which this commit belongs to
232+
-P, --pr, --pull-request-number TEXT
233+
Specify the pull request number manually.
234+
Used to override pre-existing CI environment
235+
variables
236+
-e, --env, --env-var TEXT Specify environment variables to be included
237+
with this build.
238+
-F, --flag TEXT Flag the upload to group coverage metrics.
239+
Multiple flags allowed.
240+
--plugin TEXT
241+
-d, --dry-run Don't upload files to Codecov
242+
--legacy, --use-legacy-uploader
243+
Use the legacy upload endpoint
244+
--handle-no-reports-found Raise no exceptions when no coverage reports
245+
found.
246+
--report-type [coverage|test-results|test_results]
247+
The type of report to upload
248+
--network-filter TEXT Specify a filter on the files listed in the
249+
network section of the Codecov report. This
250+
will only add files whose path begin with
251+
the specified filter. Useful for upload-
252+
specific path fixing
253+
--network-prefix TEXT Specify a prefix on files listed in the
254+
network section of the Codecov report.
255+
Useful to help resolve path fixing
256+
--gcov-args TEXT Extra arguments to pass to gcov
257+
--gcov-ignore TEXT Paths to ignore during gcov gathering
258+
--gcov-include TEXT Paths to include during gcov gathering
259+
--gcov-executable TEXT gcov executable to run. Defaults to 'gcov'
260+
--swift-project TEXT Specify the swift project
261+
--parent-sha TEXT SHA (with 40 chars) of what should be the
262+
parent of this commit
263+
-h, --help Show this message and exit.
264+
192265
Usage: sentry-prevent-cli upload-coverage [OPTIONS]
193266

194267
Options:

prevent-cli/src/prevent_cli/main.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import pathlib
33
import typing
4+
from copy import deepcopy
45

56
import click
67
from codecov_cli import __version__
@@ -85,12 +86,27 @@ def cli(
8586
init_telem(ctx.obj)
8687

8788

89+
upload = deepcopy(upload_coverage)
90+
upload.name = "upload"
91+
92+
for i, param in enumerate(upload.params):
93+
if param.name == "report_type_str":
94+
upload.params[i] = click.Option(
95+
("--report-type", "report_type_str"),
96+
help="The type of report to upload",
97+
default="coverage",
98+
type=click.Choice(["coverage", "test-results", "test_results"]),
99+
)
100+
break
101+
102+
88103
cli.add_command(do_upload)
89104
cli.add_command(create_commit)
90105
cli.add_command(create_report)
91106
cli.add_command(pr_base_picking)
92107
cli.add_command(empty_upload)
93108
cli.add_command(upload_coverage)
109+
cli.add_command(upload)
94110
cli.add_command(upload_process)
95111
cli.add_command(send_notifications)
96112
cli.add_command(process_test_results)

0 commit comments

Comments
 (0)