luizm / action-sh-checker

A GitHub action that performs static analysis for shell scripts using shellcheck, shfmt and checkbashisms.
MIT License
132 stars 12 forks source link

shellcheck not reporting issues, shfmt works #36

Closed itspngu closed 3 years ago

itspngu commented 3 years ago

Hi, I have a problem getting this to work. The shfmt portion works fine, but shellcheck does not report any problems.

I'm using luizm/action-sh-checker@v0.1.10 as any prior version fails with a tar error. Tried a few different combinations of actions/checkout@v1/v2 and purposedly-placed bad lines in shell scripts in various locations.

I kind of dumped a minimal reproducible occurance of shellcheck not seeming to do anything into the Repository I was working on, if that's not good enough I'll go and make a separate one. It's not picking up anything regardless of file location, extension and shebang.

Excerpt from my Github workflow file:

# .github/workflows/ci.yml

on:
  ...
jobs:
  lint-shell:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: luizm/action-sh-checker@v0.1.10
  build-and-test:
    needs: lint-shell
    ...

These lines are taken straight from the shellcheck readme as examples of things that'd cause its checks to fail:

#!/bin/bash

echo $@
rm "~/my file.txt"
time --format=%s sleep 10
echo "$(date)"

My Repository's structure is as follows:

project:
- test        # placed to trigger shellcheck failure
- test.bash   # placed to trigger shellcheck failure
- test.sh     # placed to trigger shellcheck failure
- bin:        # errors in these files are not detected either
  - download
  - install
  - list-all

Action output can be found here: https://github.com/itspngu/asdf-mongo-tools/runs/1756792955#step:4:5

/usr/bin/docker run --name ab6e4131b5d1414baaf756b12a7fe50d_ada86f --label 442333 --workdir /github/workspace --rm -e INPUT_SH_CHECKER_EXCLUDE -e INPUT_SH_CHECKER_SHFMT_DISABLE -e INPUT_SH_CHECKER_SHELLCHECK_DISABLE -e INPUT_SH_CHECKER_CHECKBASHISMS_ENABLE -e INPUT_SH_CHECKER_COMMENT -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/asdf-mongo-tools/asdf-mongo-tools":"/github/workspace" 442333:ab6e4131b5d1414baaf756b12a7fe50d
Validating shell scripts files using shellcheck

Validating shell scripts files using shfmt

--- bin/install.orig
+++ bin/install
@@ -1,36 +1,36 @@
 #!/usr/bin/env bash

 set -e

 [ -n "$ASDF_INSTALL_PATH" ] || (
   echo "Missing ASDF_INSTALL_PATH" 1>&2 &&
     exit 1
 )

 [ "$ASDF_INSTALL_TYPE" == "version" ] || (
   echo "asdf-mongo-tools supports release installs only" 1>&2 &&
     exit 1
 )

 # shellcheck source=bin/download
 [ -x "$ASDF_DOWNLOAD_PATH/src/github.com/mongodb/mongo-tools/build.sh" ] || . "$(dirname "$0")/download"

 GOBIN="$ASDF_INSTALL_PATH/bin"
 [ -n "$GOROOT" ] || GOROOT="$(go env GOROOT)"

 export GOBIN GOROOT

 echo $@

 (
-  mkdir -p "$ASDF_INSTALL_PATH/bin" && \
-  cd "$ASDF_DOWNLOAD_PATH/src/github.com/mongodb/mongo-tools" && \
-  ./build.sh ssl sasl && \
-  echo "mongo-tools have been installed."
+  mkdir -p "$ASDF_INSTALL_PATH/bin" &&
+    cd "$ASDF_DOWNLOAD_PATH/src/github.com/mongodb/mongo-tools" &&
+    ./build.sh ssl sasl &&
+    echo "mongo-tools have been installed."

 ) || (
   rm -rf "$ASDF_INSTALL_PATH" "$ASDF_DOWNLOAD_PATH" &&
     echo "An error ocurred while installing mongo-tools $ASDF_INSTALL_VERSION" 1>&2 &&
     exit 1
 )

The files above have some formatting problems, you can use `shfmt -w` to fix them

Would appreciate any help, I'm 99% sure I'm missing something obvious, but neither the readme for your action nor entrypoint.sh got me any further.

Cheers

luizm commented 3 years ago

it's a bug @itspngu in the shellcheck return code..

Thank you for the report.. I gonna work on it asap

luizm commented 3 years ago

@itspngu could you get a try the v0.1.11 version?

itspngu commented 3 years ago

That totally fixed it! Awesome. Thank you for being so quick on this :)

https://github.com/itspngu/asdf-mongo-tools/runs/1758036675#step:4:4