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.
This commit is contained in:
parent
a29ce0aabf
commit
facb95f0b9
1 changed files with 9 additions and 8 deletions
|
@ -1,29 +1,30 @@
|
||||||
---
|
---
|
||||||
# This file is a template, and might need editing before it works on your project.
|
# install moreutils to enable ifne (if not empty)
|
||||||
# see https://docs.gitlab.com/ce/ci/yaml/README.html for all available options
|
# will only run the respective analyzers when files to test
|
||||||
|
# are acutally found
|
||||||
# you can delete this line if you're not using Docker
|
|
||||||
image: fnichol/check-shell:latest
|
image: fnichol/check-shell:latest
|
||||||
|
|
||||||
analyze:
|
analyze:
|
||||||
stage: test
|
stage: test
|
||||||
before_script:
|
before_script:
|
||||||
|
- apk add moreutils
|
||||||
- shellcheck --version
|
- shellcheck --version
|
||||||
script:
|
script:
|
||||||
- echo "--------- CHECKING POSIX SHELLSCRIPTS -------------"
|
- 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 -------------"
|
- 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:
|
lint:
|
||||||
stage: test
|
stage: test
|
||||||
before_script:
|
before_script:
|
||||||
|
- apk add moreutils
|
||||||
- shfmt -version
|
- shfmt -version
|
||||||
script:
|
script:
|
||||||
- echo "--------- CHECKING POSIX SHELLSCRIPTS -------------"
|
- 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 -------------"
|
- 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:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
|
|
Loading…
Reference in a new issue