@@ -17,8 +17,8 @@ CI_SHELLCHECK="${CI_SHELLCHECK:-shellcheck}"
1717CI_EDITORCONFIG_CHECKER=" ${CI_EDITORCONFIG_CHECKER:- editorconfig-checker} "
1818CI_YAMLLINT=" ${CI_YAMLLINT:- yamllint} "
1919
20- # Initialize the global lint counter .
21- CI_LINT_COUNTER =0
20+ # Initialize the global lint status .
21+ CI_LINT_STATUS =0
2222
2323function ci_init_lint {
2424 ci_info " ## START OF LINTING ##"
@@ -45,14 +45,13 @@ function ci_init_lint {
4545
4646function ci_finish_lint {
4747 ci_info " ## END OF LINTING ##"
48- if [[ $CI_LINT_COUNTER -eq 0 ]]
48+ if [[ $CI_LINT_STATUS -eq 0 ]]
4949 then
5050 ci_info " ## SUCCESS ##"
51- return 0
5251 else
5352 ci_info " linting failed"
54- return 1
5553 fi
54+ return " $CI_LINT_STATUS "
5655}
5756
5857function ci_lint_ci_scripts {
@@ -61,15 +60,17 @@ function ci_lint_ci_scripts {
6160 return 0
6261 }
6362 ci_info " ## LINTING: CI scripts ##"
64- {
63+ ci_spawn " $CI_SHELLCHECK " --version
64+ find ./ci -name " *.sh" -perm +111 | {
6565 local my_file
66- ci_spawn " $CI_SHELLCHECK " --version
67- find ./ci -maxdepth 1 -name " *.sh" |
68- while IFS=" " read -r my_file
69- do
70- ci_spawn " $CI_SHELLCHECK " -x " $my_file "
71- done
72- } || CI_LINT_COUNTER=$(( CI_LINT_COUNTER + 1 ))
66+ while IFS=" " read -r my_file
67+ do
68+ ci_spawn " $CI_SHELLCHECK " -x " $my_file " || {
69+ # Linting failed.
70+ return 1
71+ }
72+ done
73+ }
7374}
7475
7576function ci_lint_text_files {
@@ -80,7 +81,8 @@ function ci_lint_text_files {
8081 ci_info " ## LINTING: text files ##"
8182 ci_spawn " $CI_EDITORCONFIG_CHECKER " --version
8283 ci_spawn " $CI_EDITORCONFIG_CHECKER " || {
83- CI_LINT_COUNTER=$(( CI_LINT_COUNTER + 1 ))
84+ # Linting failed.
85+ return 1
8486 }
8587}
8688
@@ -90,22 +92,24 @@ function ci_lint_yaml_files {
9092 return 0
9193 }
9294 ci_info " ## LINTING: YAML files ##"
93- {
95+ ci_spawn " $CI_YAMLLINT " --version
96+ find . \( -iname " *.yml" -o -iname " *.yaml" \) -not -path " ./out/*" | {
9497 local my_file
95- ci_spawn " $CI_YAMLLINT " --version
96- find . \( -iname " *.yml" -o -iname " *.yaml" \) -not -path " ./out/*" |
97- while IFS=" " read -r my_file
98- do
99- ci_spawn " $CI_YAMLLINT " --strict " $my_file "
100- done
101- } || CI_LINT_COUNTER=$(( CI_LINT_COUNTER + 1 ))
98+ while IFS=" " read -r my_file
99+ do
100+ ci_spawn " $CI_YAMLLINT " --strict " $my_file " || {
101+ # Linting failed.
102+ return 1
103+ }
104+ done
105+ }
102106}
103107
104108function ci_lint {
105109 ci_init_lint
106- ci_lint_ci_scripts
107- ci_lint_text_files
108- ci_lint_yaml_files
110+ ci_lint_ci_scripts || CI_LINT_STATUS=1
111+ ci_lint_text_files || CI_LINT_STATUS=1
112+ ci_lint_yaml_files || CI_LINT_STATUS=1
109113 # TODO: ci_lint_png_files, etc.
110114 ci_finish_lint
111115}
0 commit comments