From 882a67b9d29688a2e3a8305087a879742fdf79f9 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 3 Aug 2021 00:47:26 +0200 Subject: [PATCH 1/9] Add shellcheck Add shellcheck CI and shellcheck in Makefile (bash-check rule) Signed-off-by: Bensuperpc --- .github/workflows/shellcheck.yml | 26 ++++++++++++++++++++++++++ Makefile | 11 +++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..9f47530 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,26 @@ +name: Shellcheck CI + +on: + push: + branches: + - '*' + paths-ignore: + - '**/README.md' + pull_request: + branches: + - '*' + paths-ignore: + - '**/README.md' + workflow_dispatch: + +jobs: + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + severity: warning + format: gcc \ No newline at end of file diff --git a/Makefile b/Makefile index 23eb6e4..8b48621 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,12 @@ endif # Tag images with date and Git short hash in addition to revision TAG := $(shell date '+%Y%m%d')-$(shell git rev-parse --short HEAD) +# shellcheck executable +SHELLCHECK := shellcheck + +# Defines the level of verification (error, warning, info...) +SHELLCHECK_SEVERITY_LEVEL := error + # # images: This target builds all IMAGES (because it is the first one, it is built by default) # @@ -275,6 +281,11 @@ purge: clean # Remove all images with organization (ex dockcross/*) $(DOCKER) images --filter=reference='$(ORG)/*' --format='{{.Repository}}:{{.Tag}}' | xargs -r $(DOCKER) rmi -f +# Check bash syntax +bash-check: + find . -type f \( -name "*.sh" -o -name "*.bash" \) -print0 | xargs -0 -P"$(shell nproc)" -I{} \ + $(SHELLCHECK) --check-sourced --color=auto --format=gcc --severity=error --shell=bash --enable=all "{}" + # # testing implicit rule # From 84e12b0f66cab77964465833bda38a8eecefe8a1 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 3 Aug 2021 00:51:25 +0200 Subject: [PATCH 2/9] Reduce shellcheck to error only (Will be changed later) Reduce shellcheck to error only (Will be changed later) Signed-off-by: Bensuperpc --- .github/workflows/shellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 9f47530..c7376bf 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -22,5 +22,5 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master with: - severity: warning + severity: error format: gcc \ No newline at end of file From 92efe118b3c78bff5fea26463049530619fe1439 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 3 Aug 2021 00:52:33 +0200 Subject: [PATCH 3/9] Revert "Reduce shellcheck to error only (Will be changed later)" This reverts commit 84e12b0f66cab77964465833bda38a8eecefe8a1. --- .github/workflows/shellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index c7376bf..9f47530 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -22,5 +22,5 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master with: - severity: error + severity: warning format: gcc \ No newline at end of file From d02099ad95d02e958752cadcf9cf5d8d27bb6354 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 3 Aug 2021 01:03:00 +0200 Subject: [PATCH 4/9] Change to bash in shellcheck and rename dockcross script to dockcross.sh Change to bash in shellcheck and rename dockcross script to dockcross.sh Signed-off-by: Bensuperpc --- .github/workflows/shellcheck.yml | 6 ++++-- imagefiles/{dockcross => dockcross.sh} | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) rename imagefiles/{dockcross => dockcross.sh} (99%) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 9f47530..a9a749f 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -22,5 +22,7 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master with: - severity: warning - format: gcc \ No newline at end of file + severity: error + format: gcc + env: + SHELLCHECK_OPTS: bash \ No newline at end of file diff --git a/imagefiles/dockcross b/imagefiles/dockcross.sh similarity index 99% rename from imagefiles/dockcross rename to imagefiles/dockcross.sh index a6dc199..5d7bedd 100755 --- a/imagefiles/dockcross +++ b/imagefiles/dockcross.sh @@ -6,11 +6,11 @@ DEFAULT_DOCKCROSS_IMAGE=dockcross/base # DO NOT MOVE THIS LINE (see entrypoint. # Helpers # err() { - echo -e >&2 ERROR: $@\\n + echo -e >&2 "ERROR: $*\n" } die() { - err $@ + err "$*" exit 1 } From 8ce154f1b24add811ebbac6829b930f27d8f5a9c Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 3 Aug 2021 01:07:09 +0200 Subject: [PATCH 5/9] Remove bash in env Remove bash in env Signed-off-by: Bensuperpc --- .github/workflows/shellcheck.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index a9a749f..c7376bf 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -23,6 +23,4 @@ jobs: uses: ludeeus/action-shellcheck@master with: severity: error - format: gcc - env: - SHELLCHECK_OPTS: bash \ No newline at end of file + format: gcc \ No newline at end of file From 50b57169e7c82c3fce0950a238766cf3fca83f72 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 3 Aug 2021 01:08:52 +0200 Subject: [PATCH 6/9] Revert "Remove bash in env" This reverts commit 8ce154f1b24add811ebbac6829b930f27d8f5a9c. --- .github/workflows/shellcheck.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index c7376bf..a9a749f 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -23,4 +23,6 @@ jobs: uses: ludeeus/action-shellcheck@master with: severity: error - format: gcc \ No newline at end of file + format: gcc + env: + SHELLCHECK_OPTS: bash \ No newline at end of file From 55eb3b7c96a39327f0c9443ea0ecdb23fa457931 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 3 Aug 2021 01:09:09 +0200 Subject: [PATCH 7/9] Fix bash error in shellcheck Fix bash error in shellcheck Signed-off-by: Bensuperpc --- .github/workflows/shellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index a9a749f..1451f7a 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -25,4 +25,4 @@ jobs: severity: error format: gcc env: - SHELLCHECK_OPTS: bash \ No newline at end of file + SHELLCHECK_OPTS: -s bash \ No newline at end of file From cc5961492e7fe3798184ceef8c13cb811547dddd Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 3 Aug 2021 01:12:43 +0200 Subject: [PATCH 8/9] Fix wrong file name Fix wrong file name Signed-off-by: Bensuperpc --- common/common.dockcross | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/common.dockcross b/common/common.dockcross index f2513dc..01d969b 100644 --- a/common/common.dockcross +++ b/common/common.dockcross @@ -13,4 +13,4 @@ RUN \ rm -rf /buildscripts # Runtime scripts -COPY imagefiles/entrypoint.sh imagefiles/dockcross /dockcross/ +COPY imagefiles/entrypoint.sh imagefiles/dockcross.sh /dockcross/ From 04f84bc4edf19729acce16fc77135d885b5eefb4 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Tue, 3 Aug 2021 15:08:31 +0200 Subject: [PATCH 9/9] Fix end file Fix end file Signed-off-by: Bensuperpc --- .github/workflows/shellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 1451f7a..2e183f9 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -25,4 +25,4 @@ jobs: severity: error format: gcc env: - SHELLCHECK_OPTS: -s bash \ No newline at end of file + SHELLCHECK_OPTS: -s bash