From facb95f0b963375b53ab7b00b45a2f818fe02105 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 10 Feb 2020 22:09:31 +0100 Subject: [PATCH] Fix linting and static analysis Set linter and formatter to *only* run when files it works for are actually detected. Uses moreutils' ifne to detect the status of stdin before sending an empty string to the test suite. --- .gitlab-ci.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36dcf8b..363350b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,29 +1,30 @@ --- -# This file is a template, and might need editing before it works on your project. -# see https://docs.gitlab.com/ce/ci/yaml/README.html for all available options - -# you can delete this line if you're not using Docker +# install moreutils to enable ifne (if not empty) +# will only run the respective analyzers when files to test +# are acutally found image: fnichol/check-shell:latest analyze: stage: test before_script: + - apk add moreutils - shellcheck --version script: - echo "--------- CHECKING POSIX SHELLSCRIPTS -------------" - - find . -type f -name '*.sh' | xargs shellcheck -Calways + - find . -type f -name '*.sh' | ifne xargs shellcheck -Calways - echo "--------- CHECKING ZSH SHELLSCRIPTS -------------" - - find . -type f -name '*.zsh' | xargs shellcheck -Calways -s bash -e SC2034 + - find . -type f -name '*.zsh' | ifne xargs shellcheck -Calways -s bash -e SC2034 lint: stage: test before_script: + - apk add moreutils - shfmt -version script: - echo "--------- CHECKING POSIX SHELLSCRIPTS -------------" - - find . -type f -name '*.sh' | xargs shfmt -d -i 2 + - find . -type f -name '*.sh' | ifne xargs shfmt -d -i 2 - echo "--------- CHECKING ZSH SHELLSCRIPTS -------------" - - find . -type f -name '*.zsh' | xargs shfmt -d -i 2 + - find . -type f -name '*.zsh' | ifne xargs shfmt -d -i 2 test: stage: test