Skip to content
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

Clean up scripts with shellcheck #77376

Closed
wants to merge 11 commits into from
Closed

Clean up scripts with shellcheck #77376

wants to merge 11 commits into from

Conversation

pta2002
Copy link

@pta2002 pta2002 commented Sep 30, 2020

Should take care of #77290, but since there's a good chance I'll do a second pass through the scripts, I'm leaving this here to check with CI.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 30, 2020
@Mark-Simulacrum
Copy link
Member

I'm going to r? @pietroalbini in the hopes that you have time to take a look at this, I personally do not feel like I can dedicate bandwidth to being comfortable approving this

@pta2002
Copy link
Author

pta2002 commented Sep 30, 2020

That should be all changes necessary, as far as I know.

@pta2002 pta2002 changed the title [WIP] Clean up scripts with shellcheck Clean up scripts with shellcheck Sep 30, 2020
@jyn514 jyn514 added the T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. label Oct 1, 2020
@@ -31,35 +31,35 @@ exit 1
# First up, build a cross-compiler
git clone --depth=1 https://git.haiku-os.org/haiku
git clone --depth=1 https://git.haiku-os.org/buildtools
cd $BUILDTOOLS/jam
cd "$BUILDTOOLS/jam"
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, don't you also need to change lines 7 and 9 for this to do anything?

Copy link
Member

Choose a reason for hiding this comment

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

Hi @pta2002, you marked this as resolved but didn't change the lines. If they don't need to be changed, can you explain why?

src/test/run-make/thumb-none-qemu/script.sh Outdated Show resolved Hide resolved
src/tools/clippy/.github/driver.sh Outdated Show resolved Hide resolved
@@ -28,14 +28,14 @@ diff normalized.stderr tests/ui/cstring.stderr


# make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same
SYSROOT=`rustc --print sysroot`
SYSROOT=$(rustc --print sysroot)
diff <(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver --rustc --version --verbose) <(rustc --version --verbose)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
diff <(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver --rustc --version --verbose) <(rustc --version --verbose)
diff <(LD_LIBRARY_PATH="${SYSROOT}"/lib ./target/debug/clippy-driver --rustc --version --verbose) <(rustc --version --verbose)

diff <(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver --rustc --version --verbose) <(rustc --version --verbose)


echo "fn main() {}" > target/driver_test.rs
# we can't run 2 rustcs on the same file at the same time
CLIPPY=`LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc`
RUSTC=`rustc ./target/driver_test.rs`
CLIPPY=$(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
CLIPPY=$(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc)
CLIPPY=$(LD_LIBRARY_PATH="${SYSROOT}"/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc)

CLIPPY=`LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc`
RUSTC=`rustc ./target/driver_test.rs`
CLIPPY=$(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc)
RUSTC=$(rustc ./target/driver_test.rs)
diff <($CLIPPY) <($RUSTC)
Copy link
Member

Choose a reason for hiding this comment

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

This ... does not look right. Also this is a change to submodule so I'm not sure you should make it here, but clippy uses subtree so it might be special.

Copy link
Author

Choose a reason for hiding this comment

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

Is there any difference between `` and $()? I changed it because shellcheck warned about it and as far as I know they do the same thing.

Copy link
Member

Choose a reason for hiding this comment

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

Oh no your change is fine, I mean running eval on dynamically generated code. Normally I'd suggest to add quotes around the $(...) but since I don't understand this code I'm afraid to change it.

@jyn514
Copy link
Member

jyn514 commented Oct 1, 2020

Updating submodule src/doc/nomicon
error: could not lock config file .git/config: Read-only file system
error: could not lock config file .git/config: Read-only file system
fatal: Failed to register url for submodule path 'src/doc/nomicon'

I think this might be because you made the PR from the master branch? Not sure what's going on here.

@jyn514 jyn514 added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Oct 1, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 1, 2020

r? @jyn514

I'm positive that pietro doesn't have time ;)

@rust-highfive rust-highfive assigned jyn514 and unassigned pietroalbini Oct 1, 2020
Copy link
Contributor

@sekineh sekineh left a comment

Choose a reason for hiding this comment

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

I added suggestions.

src/test/run-make/thumb-none-qemu/script.sh Outdated Show resolved Hide resolved
src/test/run-make/thumb-none-qemu/script.sh Outdated Show resolved Hide resolved
@pta2002
Copy link
Author

pta2002 commented Oct 1, 2020

Updating submodule src/doc/nomicon
error: could not lock config file .git/config: Read-only file system
error: could not lock config file .git/config: Read-only file system
fatal: Failed to register url for submodule path 'src/doc/nomicon'

I think this might be because you made the PR from the master branch? Not sure what's going on here.

No idea either, the only thing I added to that file was #!/usr/bin/env bash, don't know how it could've made it fail.

@pta2002
Copy link
Author

pta2002 commented Oct 1, 2020

I'll get to work on these suggestions once I get home by the way, can probably finish this today still

src/ci/docker/scripts/android-start-emulator.sh Outdated Show resolved Hide resolved
src/ci/init_repo.sh Outdated Show resolved Hide resolved
src/test/run-make/git_clone_sha1.sh Outdated Show resolved Hide resolved
@pta2002
Copy link
Author

pta2002 commented Oct 2, 2020

Alright, done - I still have no idea why CI is failing with .git being read only

src/ci/init_repo.sh Outdated Show resolved Hide resolved
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
@jyn514
Copy link
Member

jyn514 commented Oct 2, 2020

error: could not lock config file .git/config: Read-only file system
error: could not lock config file .git/config: Read-only file system

Hmm, not sure what would cause this, let me take another look at the changes.

@@ -31,35 +31,35 @@ exit 1
# First up, build a cross-compiler
git clone --depth=1 https://git.haiku-os.org/haiku
git clone --depth=1 https://git.haiku-os.org/buildtools
cd $BUILDTOOLS/jam
cd "$BUILDTOOLS/jam"
Copy link
Member

Choose a reason for hiding this comment

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

Hi @pta2002, you marked this as resolved but didn't change the lines. If they don't need to be changed, can you explain why?

src/ci/docker/run.sh Outdated Show resolved Hide resolved
src/ci/docker/scripts/musl.sh Outdated Show resolved Hide resolved
Comment on lines 51 to 53
modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
modules=($modules)
read -ra modules <<< "$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
use_git=""
urls="$(git config --file .gitmodules --get-regexp '\.url$' | cut -d' ' -f2)"
urls=($urls)
for i in ${!modules[@]}; do
module=${modules[$i]}
read -ra urls <<< "$(git config --file .gitmodules --get-regexp '\.url$' | cut -d' ' -f2)"

for i in "${!modules[@]}"; do
Copy link
Member

Choose a reason for hiding this comment

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

If I had to guess, this is what's causing CI to fail. I would revert the changes for now I think.

@pta2002
Copy link
Author

pta2002 commented Oct 2, 2020

Let's see if this works

@pta2002
Copy link
Author

pta2002 commented Oct 2, 2020

Seems like now it's failing due to not finding a cached build

@pta2002
Copy link
Author

pta2002 commented Oct 2, 2020

Hm from what I can tell, somewhere a .tar.gz got dropped in that URL, but where I have no idea, because I didn't remove any in my changes.

src/ci/run.sh Outdated
CARGO_INCREMENTAL=0 $PYTHON ../x.py check
rm -f config.toml
rm -rf build
fi

$SRC/configure $RUST_CONFIGURE_ARGS
"$SRC"/configure "$RUST_CONFIGURE_ARGS"
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look correct. This used to be many different arguments, like --set x --set y; now it's one argument all at once. I think you should change it back to how it was before. If you want to silence the shellcheck warning you could trying using an array instead but I'd revert it for now just to make sure it works.

@pta2002
Copy link
Author

pta2002 commented Oct 3, 2020 via email

@pta2002
Copy link
Author

pta2002 commented Oct 3, 2020

Well that took a while, looks like it's fixed now though, at least CI has gone off to actually compile rust.

@jyn514
Copy link
Member

jyn514 commented Oct 3, 2020

I personally do not feel like I can dedicate bandwidth to being comfortable approving this

@Mark-Simulacrum I'm reasonably happy with the current code, but I wouldn't stake my life on there being no regressions. How do you want to move forward?

@jyn514
Copy link
Member

jyn514 commented Oct 3, 2020

oh and while we're at it, let's try and catch more issues early

@bors try

@bors
Copy link
Contributor

bors commented Oct 3, 2020

⌛ Trying commit c640a44 with merge a8d42c75c152f5994caaffca294da2b534eade44...

@Mark-Simulacrum
Copy link
Member

I don't have the time/bandwidth to invest in figuring out the shell script changes here, it's very error prone (as you have already seen) and I have no good ideas on avoiding regressions. IMO, it is questionable whether the improvements in this PR are worth it given the possibility of regressions and likelihood of reintroducing shellcheck-warned code over time.

Largely I just don't know that we get value out of this that outweighs the downsides.

That said, we have already branched beta, so it's as early in the cycle as it's going to get.

@@ -59,7 +58,7 @@ if command -v "g${GREPPER}"; then
fi

LOG=$(mktemp -t cgrep.XXXXXX)
trap "rm -f $LOG" EXIT
trap 'rm -f $LOG' EXIT
Copy link
Member

Choose a reason for hiding this comment

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

Please revert this change in behavior.

CLIPPY=`LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc`
RUSTC=`rustc ./target/driver_test.rs`
CLIPPY=$(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc)
RUSTC=$(rustc ./target/driver_test.rs)
diff <($CLIPPY) <($RUSTC)

# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest that clippy CI changes are not done in this PR, as you really can't test them without running Clippy's CI. It should be fairly easily to port these to a Clippy PR though.

Copy link
Author

Choose a reason for hiding this comment

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

That makes sense, I'll take these off and submit them to clippy separately

@camelid camelid added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 23, 2020
@Dylan-DPC-zz
Copy link

Closing this as it doesn't look likely it will be approved in this state. If you have a better way of handling this, you can submit a new pull request. Thanks

@Dylan-DPC-zz Dylan-DPC-zz added S-inactive S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-inactive labels Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants