Skip to content
Snippets Groups Projects
Unverified Commit 982c68fd authored by Craig Miskell's avatar Craig Miskell
Browse files

fix: Ensure COMMON_TASK_VALIDATIONS_EXCLUDES_REGEXP works for shfmt

The COMMON_TASK_VALIDATIONS_EXCLUDES_REGEXP values in projects expect to filter the output of 'find', which generally will start with a ./ in the way we use it in this project.  For example, Instrumentor uses "^\.(/get|/metrics-catalog|/test/lib/shunit2)".  But shfmt does *not* have the ./ prefix, so those sorts of expressions will fail to match and exclude necessary files.  Because this variable is also still used to filter the output of find in other tasks (e.g. tflint) we can't change the expectations of what it will be filtering.

Therefore, this:
1. Inserts the leading ./ on each line from shfmt --find ., so as to maintain the API.
2. Fixes the first filter to not exclude anything starting with ., which is now a problem
parent 4c4e66b0
No related branches found
No related tags found
No related merge requests found
Pipeline #15483405 passed
Loading
Loading
@@ -4,7 +4,8 @@ shellcheck:
image: registry.gitlab.com/gitlab-com/gl-infra/common-ci-tasks-images/shellcheck:${GL_ASDF_SHELLCHECK_VERSION}
script:
- shfmt --find . |
grep -vE "(^|/)(node_modules/|\.)" |
xargs -I {} echo "./{}" |
grep -vE "(^|/)(node_modules/)" |
grep -vE "${COMMON_TASK_VALIDATIONS_EXCLUDES_REGEXP:-__ignored__}" |
xargs shellcheck $SHELLCHECK_ARGS
after_script: |
Loading
Loading
Loading
Loading
@@ -7,7 +7,8 @@ shfmt:
script:
# Find all *.sh files, and any executable script files
- shfmt --find . |
grep -vE "(^|/)(node_modules/|\.)" |
xargs -I {} echo "./{}" |
grep -vE "(^|/)(node_modules/)" |
grep -vE "${COMMON_TASK_VALIDATIONS_EXCLUDES_REGEXP:-__ignored__}" |
xargs shfmt -w -l -s -i 2 -d
after_script: |
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment