Skip to content
Snippets Groups Projects
Commit cd8325af authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'fix/issue-13' into 'master'

fix: issue #13 add find to manage more pattern

Closes #13

See merge request to-be-continuous/bash!39
parents 47049b53 4fee4c72
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,7 @@ This job performs a static analysis of your shell scripts using [ShellCheck](htt ...@@ -46,7 +46,7 @@ This job performs a static analysis of your shell scripts using [ShellCheck](htt
| ----------------------- | -------------------------------------- | ----------------- | | ----------------------- | -------------------------------------- | ----------------- |
| `shellcheck-disabled` / `BASH_SHELLCHECK_DISABLED` | Set to `true` to disable ShellCheck | _none_ (enabled) | | `shellcheck-disabled` / `BASH_SHELLCHECK_DISABLED` | Set to `true` to disable ShellCheck | _none_ (enabled) |
| `shellcheck-image` / `BASH_SHELLCHECK_IMAGE` | The Docker image used to run [ShellCheck](https://github.com/koalaman/shellcheck) | `registry.hub.docker.com/koalaman/shellcheck-alpine:stable` | | `shellcheck-image` / `BASH_SHELLCHECK_IMAGE` | The Docker image used to run [ShellCheck](https://github.com/koalaman/shellcheck) | `registry.hub.docker.com/koalaman/shellcheck-alpine:stable` |
| `shellcheck-files` / `BASH_SHELLCHECK_FILES` | Shell file(s) pattern to analyse | `**/*.sh` | | `shellcheck-files` / `BASH_SHELLCHECK_FILES` | Shell file(s) or pattern(s) to analyse | `**/*.sh` |
| `shellcheck-opts` / `BASH_SHELLCHECK_OPTS` | ShellCheck [options](https://github.com/koalaman/shellcheck/blob/master/shellcheck.1.md) | _none_ | | `shellcheck-opts` / `BASH_SHELLCHECK_OPTS` | ShellCheck [options](https://github.com/koalaman/shellcheck/blob/master/shellcheck.1.md) | _none_ |
### `bash-bats` job ### `bash-bats` job
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
}, },
{ {
"name": "BASH_SHELLCHECK_FILES", "name": "BASH_SHELLCHECK_FILES",
"description": "Shell file(s) pattern to analyse", "description": "Shell file(s) or pattern(s) to analyse",
"default": "**/*.sh" "default": "**/*.sh"
}, },
{ {
......
...@@ -23,7 +23,7 @@ spec: ...@@ -23,7 +23,7 @@ spec:
description: The Docker image used to run [ShellCheck](https://github.com/koalaman/shellcheck) description: The Docker image used to run [ShellCheck](https://github.com/koalaman/shellcheck)
default: registry.hub.docker.com/koalaman/shellcheck-alpine:stable default: registry.hub.docker.com/koalaman/shellcheck-alpine:stable
shellcheck-files: shellcheck-files:
description: Shell file(s) pattern to analyse description: Shell file(s) or pattern(s) to analyse
default: '**/*.sh' default: '**/*.sh'
shellcheck-opts: shellcheck-opts:
description: ShellCheck [options](https://github.com/koalaman/shellcheck/blob/master/shellcheck.1.md) description: ShellCheck [options](https://github.com/koalaman/shellcheck/blob/master/shellcheck.1.md)
...@@ -132,15 +132,15 @@ stages: ...@@ -132,15 +132,15 @@ stages:
set -e set -e
function log_info() { function log_info() {
echo -e "[\\e[1;94mINFO\\e[0m] $*" >&2 echo -e "[\\e[1;94mINFO\\e[0m] $*"
} }
function log_warn() { function log_warn() {
echo -e "[\\e[1;93mWARN\\e[0m] $*" >&2 echo -e "[\\e[1;93mWARN\\e[0m] $*"
} }
function log_error() { function log_error() {
echo -e "[\\e[1;91mERROR\\e[0m] $*" >&2 echo -e "[\\e[1;91mERROR\\e[0m] $*"
} }
function install_ca_certs() { function install_ca_certs() {
...@@ -354,6 +354,20 @@ stages: ...@@ -354,6 +354,20 @@ stages:
ls -lart "$BATS_LIBRARIES_DIR" ls -lart "$BATS_LIBRARIES_DIR"
} }
function glob_expand() {
for f in "$@"; do
if [[ "$f" == *[*?[]* ]]; then
# expand pattern with * or ? or [
find . -path "$f" -type f
elif [[ -f "$f" ]]; then
echo "$f"
else
log_error "File not found: $f"
exit 1
fi
done
}
unscope_variables unscope_variables
eval_all_secrets eval_all_secrets
...@@ -375,7 +389,8 @@ bash-shellcheck: ...@@ -375,7 +389,8 @@ bash-shellcheck:
entrypoint: [""] entrypoint: [""]
script: script:
- export LC_ALL=C.UTF-8 - export LC_ALL=C.UTF-8
- shellcheck $BASH_SHELLCHECK_OPTS $BASH_SHELLCHECK_FILES - shellcheck $BASH_SHELLCHECK_OPTS $(glob_expand $BASH_SHELLCHECK_FILES)
rules: rules:
- if: '$BASH_SHELLCHECK_DISABLED == "true"' - if: '$BASH_SHELLCHECK_DISABLED == "true"'
when: never when: never
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment