diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index e8d9afd141..4ae512d2bd 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -49,11 +49,12 @@ jobs: # --- - name: Run Shellcheck run: | + rm -f ./some_scripts_have_failed_shellcheck set +e find ./*/ -type f | sort | while read -r sh; do if [ "$(file --brief --mime-type "$sh")" == 'text/x-shellscript' ]; then echo "shellcheck'ing $sh" - if ! shellcheck-stable/shellcheck --color=always --severity=warning --exclude=SC1091,SC1090 "$sh"; then + if ! shellcheck-stable/shellcheck --color=always --severity=warning "$sh"; then touch some_scripts_have_failed_shellcheck fi fi diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000000..85957a1b29 --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1 @@ +disable=SC1091,SC1090 diff --git a/Makefile b/Makefile index 86d96afa42..8f65ee0829 100644 --- a/Makefile +++ b/Makefile @@ -66,8 +66,7 @@ all: help: @echo -e "Relax-and-Recover make targets:\n\ \n\ - test - Shellcheck source code\n\ - validate - Check source code\n\ + validate - Shellchecking scripts and Validating scripts and configuration\n\ install - Install Relax-and-Recover (may replace files)\n\ uninstall - Uninstall Relax-and-Recover (may remove files)\n\ dist - Create tar file in dist/\n\ @@ -89,6 +88,21 @@ clean: ### You can call 'make validate' directly from your .git/hooks/pre-commit script validate: + @echo -e "\033[1m== Shellchecking script files ==\033[0;0m" + type -p shellcheck || { echo "ERROR: shellcheck not installed."; exit 1; } + find ./*/ -type f | sort | while read -r sh; do \ + if [ "$$(file --brief --mime-type "$$sh")" == 'text/x-shellscript' ]; then \ + echo "shellcheck'ing $$sh" ; \ + if ! shellcheck --color=always --severity=warning --exclude=SC1091,SC1090 "$$sh"; then \ + touch ./some_scripts_have_failed_shellcheck ; \ + fi \ + fi \ + done + if [ -f ./some_scripts_have_failed_shellcheck ]; then \ + echo "Shellcheck failed for one or more shellscript(s)"; \ + rm ./some_scripts_have_failed_shellcheck ; \ + exit 1 ; \ + fi @echo -e "\033[1m== Validating scripts and configuration ==\033[0;0m" find etc/ usr/share/rear/conf/ -name '*.conf' | xargs -n 1 bash -n bash -n $(rearbin) @@ -114,23 +128,6 @@ doc: @echo -e "\033[1m== Prepare documentation ==\033[0;0m" $(MAKE) -C doc docs -test: - @echo -e "\033[1m== Shellchecking script files ==\033[0;0m" - type -p shellcheck || { echo "ERROR: shellcheck not installed."; exit 1; } - find ./*/ -type f | sort | while read -r sh; do \ - if [ "$$(file --brief --mime-type "$$sh")" == 'text/x-shellscript' ]; then \ - echo "shellcheck'ing $$sh" ; \ - if ! shellcheck --color=always --severity=warning --exclude=SC1091,SC1090 "$$sh"; then \ - touch ./some_scripts_have_failed_shellcheck ; \ - fi \ - fi \ - done - if [ -f ./some_scripts_have_failed_shellcheck ]; then \ - echo "Shellcheck failed for one or more shellscript(s)"; \ - rm ./some_scripts_have_failed_shellcheck ; \ - exit 1 ; \ - fi - install-config: @echo -e "\033[1m== Installing configuration ==\033[0;0m" install -d -m0700 $(DESTDIR)$(sysconfdir)/rear/ diff --git a/tests/setup1/tcase7.sh b/tests/setup1/tcase7.sh index e929eb4066..f4db57ec9b 100755 --- a/tests/setup1/tcase7.sh +++ b/tests/setup1/tcase7.sh @@ -1,5 +1,6 @@ #!/bin/bash -# removed due to SC2034: CONFIG_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +CONFIG_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +export CONFIG_DIR . "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/run.sh diff --git a/tests/setup1/tcase8.sh b/tests/setup1/tcase8.sh index d5403c0ab7..07ad1fb7ab 100755 --- a/tests/setup1/tcase8.sh +++ b/tests/setup1/tcase8.sh @@ -1,6 +1,7 @@ #!/bin/bash -# removed due to SC2034: CONFIG_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +CONFIG_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +export CONFIG_DIR export SIMPLIFY_BONDING=y export SIMPLIFY_BRIDGE=y diff --git a/tests/setup2/tcase7.sh b/tests/setup2/tcase7.sh index e929eb4066..f4db57ec9b 100755 --- a/tests/setup2/tcase7.sh +++ b/tests/setup2/tcase7.sh @@ -1,5 +1,6 @@ #!/bin/bash -# removed due to SC2034: CONFIG_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +CONFIG_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +export CONFIG_DIR . "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/run.sh diff --git a/tests/setup2/tcase8.sh b/tests/setup2/tcase8.sh index d5403c0ab7..07ad1fb7ab 100755 --- a/tests/setup2/tcase8.sh +++ b/tests/setup2/tcase8.sh @@ -1,6 +1,7 @@ #!/bin/bash -# removed due to SC2034: CONFIG_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +CONFIG_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +export CONFIG_DIR export SIMPLIFY_BONDING=y export SIMPLIFY_BRIDGE=y