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

Add shellcheck to pre-commit and make helper scripts clean #980

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yarikoptic
Copy link

@yarikoptic yarikoptic commented Jan 4, 2024

What do these changes do?

Fix up found helper shell scripts so they become more robust and shellcheck clean.

Adds shellcheck to pre-commit

Are there changes in behavior for the user?

no

Checklist

  • Fix remaining fails
I left following ones not fixed to see if CI would run pre-commit to ensure that nothing sneaks in
❯ pre-commit run --all shellcheck
ShellCheck v0.9.0........................................................Failed
- hook id: shellcheck
- exit code: 1

In tools/build-wheels.sh line 61:
for whl in ${ORIG_WHEEL_DIR}/*/${package_name}-*-linux_${arch}.whl; do
           ^---------------^ SC2231 (info): Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt .
                               ^-------------^ SC2231 (info): Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt .
                                                       ^-----^ SC2231 (info): Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt .


In tools/run_docker.sh line 35:
    docker run --rm -v $(pwd):/io "${manylinux1_image_prefix}${arch}" $dock_ext_args /io/tools/build-wheels.sh "$package_name"
                       ^----^ SC2046 (warning): Quote this to prevent word splitting.

For more information:
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
  https://www.shellcheck.net/wiki/SC2231 -- Quote expansions in this for loop...

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "shellcheck -f diff tools/*.sh | patch -p 1",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^
@yarikoptic
Copy link
Author

hm, it did fail but non-informatively

ShellCheck v0.9.0............................................................Failed
- hook id: shellcheck
- exit code: 1

Executable `docker` not found

apparently that pre-commit action relies on docker :-/

❯ cat pre-commit-hooks.yaml.template
- id: shellcheck
  name: ShellCheck $VERSION
  description: Static analysis tool for shell scripts
  language: docker_image
  entry: $DOCKERHOST/$DOCKERHUB:$VERSION
  types: [shell]
❯ git grep DOCKER
autoupdate:export DOCKERHOST="docker.io"
autoupdate:export DOCKERHUB="koalaman/shellcheck"
autoupdate:  curl "https://registry.hub.docker.com/v2/repositories/$DOCKERHUB/tags" |
pre-commit-hooks.yaml.template:  entry: $DOCKERHOST/$DOCKERHUB:$VERSION

shellcheck seems written in haskell and has linux and OSX builds provided from github releases, but no windows...

anyways -- given above, I just want first to check if you want to keep it or should I drop it and just leave the fixes to scripts? (meanwhile I will push fixup for those remaining issues)

Should work even with globs, tested on

    *$> echo $BASH_VERSION; var1=pac var2=__; ls -l "${var1}"*/pep*/*"${var2}".py
    5.2.21(1)-release
    4 -rw------- 1 yoh yoh  64 Jan  4 14:27 packaging/pep517_backend/__init__.py
    4 -rw------- 1 yoh yoh 108 Jan  4 14:27 packaging/pep517_backend/__main__.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant