Skip to content

Commit

Permalink
馃毟 Disable some checks for local as well as for GH action runs:
Browse files Browse the repository at this point in the history
   .github/workflows/shellcheck.yml
 file:   .shellcheckrc

馃毟 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
  • Loading branch information
thomasmerz committed Feb 21, 2022
1 parent 6e8c10b commit 3f759fc
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/shellcheck.yml
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .shellcheckrc
@@ -0,0 +1 @@
disable=SC1091,SC1090
35 changes: 16 additions & 19 deletions Makefile
Expand Up @@ -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\
Expand All @@ -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)
Expand All @@ -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/
Expand Down
3 changes: 2 additions & 1 deletion 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
3 changes: 2 additions & 1 deletion 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
Expand Down
3 changes: 2 additions & 1 deletion 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
3 changes: 2 additions & 1 deletion 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
Expand Down

0 comments on commit 3f759fc

Please sign in to comment.