-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable --test
flag when publishing package using Sui client
#13786
Disable --test
flag when publishing package using Sui client
#13786
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
49d2d5f
to
fb583fe
Compare
fb583fe
to
338e18c
Compare
@tzakian Hey, two questions
Thanks! |
Thank you for the PR @rockbmb! I will take a look at this and may add some other reviewers as well :) In terms of release notes just describing what this prevents is good enough (and will get picked up). E.g., "Added error to Sui CLI when trying to publish a package compiled in test mode" |
@@ -732,6 +732,17 @@ impl SuiClientCommands { | |||
serialize_signed_transaction, | |||
lint, | |||
} => { | |||
if build_config.test_mode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the solution presented in this PR works, a user running sui client publish --help
will still see --test
in the list of available flags.
In order to remove this entirely, I can see two solutions:
BuildConfig
is duplicated into astruct
without atest_mode
field, and used here- The
test_mode
flag is extracted into a different structureBuildConfigNoTest
that two fields: it, and athe originalBuildConfig
Both feel like overengineering, so I chose this approach instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me as well -- agreed that the other options feel a bit like overengineering as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR (and thank you for the additional test too!).
Only minor nit is on the exact wording of the error message and removing the example, but otherwise this looks great to me! Once that's fixed I think this can go in.
@@ -732,6 +732,17 @@ impl SuiClientCommands { | |||
serialize_signed_transaction, | |||
lint, | |||
} => { | |||
if build_config.test_mode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me as well -- agreed that the other options feel a bit like overengineering as well.
crates/sui/src/client_commands.rs
Outdated
return Err(SuiError::ModulePublishFailure { | ||
error: "The `publish` subcommand should not be used with the `--test` flag\n\ | ||
\n\ | ||
Library code in published packages must not depend on test code.\n\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Library code in published packages must not depend on test code.\n\ | |
Code in published packages must not depend on test code.\n\ |
crates/sui/src/client_commands.rs
Outdated
In order to fix this and publish the package without `--test`, search for, and remove \ | ||
instances of e.g. test modules declared as `friend`s of modules from `sources/`.".to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would most likely rephrase the last part of this a bit as the way tests can be defined (and how modules could depend on other test-only code) can differ, e.g., you can have test-only modules under sources/
, and even though this is an example at the end I worry it may put blinders on folks and how they look at fixing this issue.
What do you think of maybe something like:
In order to fix this and publish the package without `--test` remove any non-test dependencies on test-only code. You can ensure all test-only dependencies have been removed by compiling the package normally with `sui move build`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me.
7620a8b
to
420a4a6
Compare
420a4a6
to
8b388e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Thank you for the fix, and following up with the changes!
Description
This PR disables the use of the
--test
flag when executingsui client publish
.It closes #13679, following discussion in that thread.
Test Plan
I've added a test to
./crates/sui/tests/cli_tests.rs
that verifies the--test
flag will no longer be accepted withclient publish
, along with an error message explaining why.Type of Change (Check all that apply)
Release notes
The Sui CLI now returns a new error message if you try to compile and publish a package in test mode using the
sui client publish --test
command.