From 3f759fcc6a0da6c301384aa4b9ec0e5de3456665 Mon Sep 17 00:00:00 2001 From: Thomas Merz Date: Mon, 21 Feb 2022 11:50:24 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Disable=20some=20checks=20for=20?= =?UTF-8?q?local=20as=20well=20as=20for=20GH=20action=20runs:=20=20=20=20.?= =?UTF-8?q?github/workflows/shellcheck.yml=20=20file:=20=20=20.shellcheckr?= =?UTF-8?q?c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🚸 Use only 'validate' for 'test' and 'validate' in one step: Makefile 🚑 Fix incorrectly deleted CONFIG_DIR: tests/setup1/tcase7.sh tests/setup1/tcase8.sh tests/setup2/tcase7.sh tests/setup2/tcase8.sh --- .github/workflows/shellcheck.yml | 3 ++- .shellcheckrc | 1 + Makefile | 35 +++++++++++++++----------------- tests/setup1/tcase7.sh | 3 ++- tests/setup1/tcase8.sh | 3 ++- tests/setup2/tcase7.sh | 3 ++- tests/setup2/tcase8.sh | 3 ++- 7 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 .shellcheckrc 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