Skip to content

feat: Support upload of extra files#190

Merged
nicholasmccrea merged 4 commits into
masterfrom
eng-7718-maven-cli-support-for-upload-of-arbitrary-files
Mar 31, 2025
Merged

feat: Support upload of extra files#190
nicholasmccrea merged 4 commits into
masterfrom
eng-7718-maven-cli-support-for-upload-of-arbitrary-files

Conversation

@nicholasmccrea
Copy link
Copy Markdown
Contributor

@nicholasmccrea nicholasmccrea commented Mar 26, 2025

What Changed?

Update the CLI to enable support for uploading arbitrary files when pushing Maven packages. These files may include anything beyond standard Maven files (pom, jar, sources, javadoc)

Arbitrary files can be specified using the --extra-files option, allowing multiple files to be attached. Whilst this work is directly linked to the Maven format, the implementation can be easily extended to other formats. They would need to add the extra_files attribute to their *UploadSerializer and then handle the incoming list of files accordingly on upload.

Testing

List of extra files

 python -m cloudsmith_cli push maven cloudsmith/maven-upload-testing nicky-maven-project-1.0.0.jar \
 --javadoc-file nicky-maven-project-1.0.0-javadoc.jar \
 --sources-file nicky-maven-project-1.0.0-sources.jar \ 
--pom-file nicky-maven-project-1.0.0.pom \
--group-id com.nicky \
--artifact-id nicky-maven-cli-single-list \
--version=1.0.0 \
--extra-files=random.xml,file.nicky

Checking maven package upload parameters ... OK
Checking nicky-maven-project-1.0.0-javadoc.jar file upload parameters ... OK
Checking nicky-maven-project-1.0.0-sources.jar file upload parameters ... OK
Checking nicky-maven-project-1.0.0.pom file upload parameters ... OK
Checking random.xml file upload parameters ... OK
Checking file.nicky file upload parameters ... OK
Checking nicky-maven-project-1.0.0.jar file upload parameters ... OK
Requesting file upload for nicky-maven-project-1.0.0-javadoc.jar ... OK
Uploading nicky-maven-project-1.0.0-javadoc.jar:  [####################################]  100%
Requesting file upload for nicky-maven-project-1.0.0-sources.jar ... OK
Uploading nicky-maven-project-1.0.0-sources.jar:  [####################################]  100%
Requesting file upload for nicky-maven-project-1.0.0.pom ... OK
Uploading nicky-maven-project-1.0.0.pom:  [####################################]  100%
Requesting file upload for random.xml ... OK
Uploading random.xml:  [####################################]  100%
Requesting file upload for file.nicky ... OK
Uploading file.nicky:  [####################################]  100%
Requesting file upload for nicky-maven-project-1.0.0.jar ... OK
Uploading nicky-maven-project-1.0.0.jar:  [####################################]  100%
Creating a new maven package ... OK
Created: cloudsmith/maven-upload-testing/nicky-maven-project-100jar-hwwv (ZjDXiUoII7hM)

Synchronising nicky-maven-project-100jar-hwwv:  [###################-----------------]   55%  00:00:04  In Progress / PSynchronising nicky-maven-project-100jar-hwwv:  [###########################---------]   75%  00:00:10  In Progress / ASynchronising nicky-maven-project-100jar-hwwv:  [####################################]  100%  Completed / Fully Synchronised

Package synchronised successfully in 77.947879 second(s)!

Multiple parameters

 python -m cloudsmith_cli push maven cloudsmith/maven-upload-testing nicky-maven-project-1.0.0.jar \
 --javadoc-file nicky-maven-project-1.0.0-javadoc.jar \
 --sources-file nicky-maven-project-1.0.0-sources.jar \ 
--pom-file nicky-maven-project-1.0.0.pom \
--group-id com.nicky \
--artifact-id nicky-maven-cli-multiple-params \
--version=1.0.0 \
--extra-files=random.xml \
--extra-files=build.sh

Checking maven package upload parameters ... OK
Checking nicky-maven-project-1.0.0-javadoc.jar file upload parameters ... OK
Checking nicky-maven-project-1.0.0-sources.jar file upload parameters ... OK
Checking nicky-maven-project-1.0.0.pom file upload parameters ... OK
Checking random.xml file upload parameters ... OK
Checking build.sh file upload parameters ... OK
Checking nicky-maven-project-1.0.0.jar file upload parameters ... OK
Requesting file upload for nicky-maven-project-1.0.0-javadoc.jar ... OK
Uploading nicky-maven-project-1.0.0-javadoc.jar:  [####################################]  100%
Requesting file upload for nicky-maven-project-1.0.0-sources.jar ... OK
Uploading nicky-maven-project-1.0.0-sources.jar:  [####################################]  100%
Requesting file upload for nicky-maven-project-1.0.0.pom ... OK
Uploading nicky-maven-project-1.0.0.pom:  [####################################]  100%
Requesting file upload for random.xml ... OK
Uploading random.xml:  [####################################]  100%
Requesting file upload for build.sh ... OK
Uploading build.sh:  [####################################]  100%
Requesting file upload for nicky-maven-project-1.0.0.jar ... OK
Uploading nicky-maven-project-1.0.0.jar:  [####################################]  100%
Creating a new maven package ... OK
Created: cloudsmith/maven-upload-testing/nicky-maven-project-100jar-znz6 (VxZ6ZvbbJEf3)

Synchronising nicky-maven-project-100jar-znz6:  [###################-----------------]   55%  00:00:05  In Progress / PSynchronising nicky-maven-project-100jar-znz6:  [####################################]  100%  Completed / Fully Synchronised

Package synchronised successfully in 52.716739 second(s)!

No extra files

 python -m cloudsmith_cli push maven cloudsmith/maven-upload-testing nicky-maven-project-1.0.0.jar \
 --javadoc-file nicky-maven-project-1.0.0-javadoc.jar \
 --sources-file nicky-maven-project-1.0.0-sources.jar \ 
--pom-file nicky-maven-project-1.0.0.pom \
--group-id com.nicky \
--artifact-id nicky-maven-cli-no-extra-files \
--version=1.0.0 \

Checking maven package upload parameters ... OK
Checking nicky-maven-project-1.0.0-javadoc.jar file upload parameters ... OK
Checking nicky-maven-project-1.0.0-sources.jar file upload parameters ... OK
Checking nicky-maven-project-1.0.0.pom file upload parameters ... OK
Checking nicky-maven-project-1.0.0.jar file upload parameters ... OK
Requesting file upload for nicky-maven-project-1.0.0-javadoc.jar ... OK
Uploading nicky-maven-project-1.0.0-javadoc.jar:  [####################################]  100%
Requesting file upload for nicky-maven-project-1.0.0-sources.jar ... OK
Uploading nicky-maven-project-1.0.0-sources.jar:  [####################################]  100%
Requesting file upload for nicky-maven-project-1.0.0.pom ... OK
Uploading nicky-maven-project-1.0.0.pom:  [####################################]  100%
Requesting file upload for nicky-maven-project-1.0.0.jar ... OK
Uploading nicky-maven-project-1.0.0.jar:  [####################################]  100%
Creating a new maven package ... OK
Created: cloudsmith/maven-upload-testing/nicky-maven-project-100jar-mcid (3S91girY5AYF)

Synchronising nicky-maven-project-100jar-mcid:  [###################-----------------]   55%  00:00:04  In Progress / PSynchronising nicky-maven-project-100jar-mcid:  [####################################]  100%  Completed / Fully Synchronised

Package synchronised successfully in 52.234896 second(s)!

Invalid extra filepath

 python -m cloudsmith_cli push maven cloudsmith/maven-upload-testing nicky-maven-project-1.0.0.jar \
 --javadoc-file nicky-maven-project-1.0.0-javadoc.jar \
 --sources-file nicky-maven-project-1.0.0-sources.jar \ 
--pom-file nicky-maven-project-1.0.0.pom \
--group-id com.nicky \
--artifact-id nicky-maven-cli-invalid-extra-filepath \
--version=1.0.0 \
--extra-files=random.xml,build.invalid

Usage: python -m cloudsmith_cli push maven [OPTIONS] OWNER/REPO PACKAGE_FILE
Try 'python -m cloudsmith_cli push maven -h' for help.

Error: Invalid value for '--extra-files': Invalid file path 'build.invalid': File 'build.invalid' does not exist.

@nicholasmccrea nicholasmccrea force-pushed the eng-7718-maven-cli-support-for-upload-of-arbitrary-files branch 3 times, most recently from b3841fb to b79da31 Compare March 27, 2025 12:48
@nicholasmccrea nicholasmccrea marked this pull request as ready for review March 27, 2025 13:53
Comment on lines +567 to +571
elif k == "extra_files":
# Handle mutliple files for extra_files parameter.
option_kwargs["type"] = str
option_kwargs["multiple"] = True
option_kwargs["callback"] = validators.validate_extra_files_parameter
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation allows any format to leverage the extra_files parameter. It's up to the format-specific upload serializer to process and handle the list of files appropriately.

@nicholasmccrea nicholasmccrea force-pushed the eng-7718-maven-cli-support-for-upload-of-arbitrary-files branch 4 times, most recently from 6d0e41d to 8d1f316 Compare March 28, 2025 12:10
Comment on lines +572 to +574
info["help"] = (
info["help"] + " Accepts a comma-separated list of values."
)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API serializer text isn’t specific to the CLI, so I’ve added this to clarify how the input is expected to be formatted.

...
  --artifact-id TEXT              The ID of the artifact.
  --extra-files TEXT              Extra files to include in the package. This
                                  can be a single file or multiple files.
                                  Accepts a comma-separated list of values.
  --group-id TEXT                 Artifact's group ID.
...

@nicholasmccrea nicholasmccrea force-pushed the eng-7718-maven-cli-support-for-upload-of-arbitrary-files branch from 8d1f316 to 291ccc4 Compare March 31, 2025 10:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for uploading extra files when pushing Maven packages via the CLI. Key changes include:

  • Bumping the cloudsmith-api dependency version in setup.py.
  • Adding a new validator to process and resolve extra file paths.
  • Updating the push command to handle multiple extra files and adding corresponding tests and changelog entries.

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
setup.py Updated dependency version for cloudsmith-api
cloudsmith_cli/cli/validators.py Added a new function to validate and convert extra file paths
cloudsmith_cli/cli/tests/test_push.py Added tests for the extra_files parameter in the package upload workflow
cloudsmith_cli/cli/commands/push.py Extended upload functions and push handler to support multiple extra files
CHANGELOG.md Documented new --extra-files parameter addition
Files not reviewed (2)
  • .bumpversion.cfg: Language not supported
  • cloudsmith_cli/data/VERSION: Language not supported

Comment thread cloudsmith_cli/cli/commands/push.py Outdated
dir_okay=False, exists=True, writable=False, resolve_path=True
)
elif k == "extra_files":
# Handle mutliple files for extra_files parameter.
Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the comment: 'mutliple' should be corrected to 'multiple'.

Suggested change
# Handle mutliple files for extra_files parameter.
# Handle multiple files for extra_files parameter.

Copilot uses AI. Check for mistakes.
@nicholasmccrea nicholasmccrea merged commit 8169ae9 into master Mar 31, 2025
@nicholasmccrea nicholasmccrea deleted the eng-7718-maven-cli-support-for-upload-of-arbitrary-files branch March 31, 2025 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants