-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[ci] fix some shellcheck warnings in package-building scripts #6641
Conversation
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 working on this!
Left a first round of comments for your consideration.
No worries! We'll squash all of the history when this is merged anyway. |
That is a prompt review @jameslamb Thanks, will amend soonish! |
Co-authored-by: James Lamb <[email protected]>
Co-authored-by: James Lamb <[email protected]>
Co-authored-by: James Lamb <[email protected]>
…o shellcheck_fixes
Co-authored-by: James Lamb <[email protected]>
@jameslamb thanks for the review and code suggestions about the more extent quotemarks! Do you mind if I start a new PR soon with changes for the files you had asked my to postpone from #6621 :
|
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 working on this.
I'm confused by several of these changes. As I've asked in previous reviews... please explain the reasoning for your proposes changes here. Several of these are not obvious at all, and it's difficult to review without knowing the underlying shellcheck
warnings you're trying to address.
build-python.sh
Outdated
@@ -352,26 +356,26 @@ if test "${BUILD_WHEEL}" = true; then | |||
python -m build \ | |||
--wheel \ | |||
--outdir ../dist \ | |||
${BUILD_ARGS} \ | |||
${BUILD_ARGS:+${BUILD_ARGS}} \ |
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.
Please, explain this. What specifically is shellcheck
complaining about that led to this change?
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.
https://www.shellcheck.net/wiki/SC2086 The problem comes from BUILD_ARGS
being empty and interpolated, it passes an argument (which is the empty string, and the command fail.s We need a ternary check for this case.
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, but I just pushed commits reverting this for the reasons mentioned in #6641 (comment).
The claim you've made here that this being empty would result in the command failing is simply not true. You can try this yourself:
sh build-python.sh bdist_wheel
That will reach this line with BUILD_ARGS
empty, and nothing will fail. We even intentionally set BUILD_ARGS
to the empty string when --precompile
is passed.
Lines 295 to 299 in 668bf5d
if test "${INSTALL}" = true; then | |
if test "${PRECOMPILE}" = true; then | |
BUILD_SDIST=true | |
BUILD_WHEEL=false | |
BUILD_ARGS="" |
And I use sh build-python.sh install --precompile
every time I develop on LightGBM's Python package.
build-python.sh
Outdated
fi | ||
# ref for use of '--find-links': https://stackoverflow.com/a/52481267/3986677 | ||
pip install \ | ||
${PIP_INSTALL_ARGS} \ | ||
${PIP_INSTALL_ARGS:+ -o "$PIP_INSTALL_ARGS"} \ |
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.
What is the purpose of this change?
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 had explained it here-above. I cannot get a link, so pasting:
This one used to raise https://www.shellcheck.net/wiki/SC2086
Here using "$BUILD_ARGS" breaks down if it's empty. It seems to suggest using an array to group all arguments possibly appended to BUILD_ARGS. So we have this ternary expression checking for string emptiness if yes, the return is null. That's the way I understand it. Per the shellcheck docs:
This is better than an unquoted value because the alternative value can be properly quoted, e.g. wget ${output:+ -o "$output"}.
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 had explained it here-above
I see. I had not seen #6641 (comment) when I wrote this, maybe it's another one that wasn't published originally because it was part of an unpublished review (as you mentioned in #6641 (comment)).
I've pushed commits reverting this, for the reasons explained in #6641 (comment)
@vnherdeiro will you have time in the next week to come back and work with us on this? If not, I'll close this and fix the remaining |
@jameslamb I am back and willing to continue working on this. |
Alright thanks. You can start here: #6641 (comment) |
@jameslamb I am still figuring out how github review works, I had input comments and responses to your own but missed the submit review action, hence they were not visitble to you (or anyone but me). Completed that now. |
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've pushed commits to finish this up.
Now that I have commits on here, my approval shouldn't count toward a merge. Hopefully another reviewer will be able to look soon and we can merge this.
After that, I'll put up a PR to start running shellcheck
in LightGBM's CI. Thanks for your help with this project, @vnherdeiro !
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.
LGTM!
Contributes to #6498 continues from #6621
Now I am tackling
./build-python.sh
and./build-cran-package.sh
All feedback is welcome!
Please forgive the polluted commit history.