diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..2e183f9 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,28 @@ +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: error + format: gcc + env: + SHELLCHECK_OPTS: -s bash 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 # 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/ 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 }