dotfiles/.gitlab-ci.yml
Marty Oehme facb95f0b9
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.
2020-02-10 22:24:38 +01:00

37 lines
1.1 KiB
YAML

---
# 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' | ifne xargs shellcheck -Calways
- echo "--------- CHECKING ZSH SHELLSCRIPTS -------------"
- 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' | ifne xargs shfmt -d -i 2
- echo "--------- CHECKING ZSH SHELLSCRIPTS -------------"
- find . -type f -name '*.zsh' | ifne xargs shfmt -d -i 2
test:
stage: test
image: alpine
before_script:
- apk add git bash
- git clone https://github.com/bats-core/bats-core.git /bats
- /bats/bin/bats --version
script:
- /bats/bin/bats -r .