mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
ci: Fix the reporting in ci_lint.sh
The variable `CI_LINT_COUNTER` was incremented inside subshells, but remained unchanged in the main shell process. The errors detected by the internal linters remained unreported by the main script. (Oopsie!) Besides fixing this defect, considering that only a pass/fail status is needed, we are replacing `CI_LINT_COUNTER` with `CI_LINT_STATUS`.
This commit is contained in:
parent
72c4520d3c
commit
dddaf0c625
@ -17,8 +17,8 @@ CI_SHELLCHECK="${CI_SHELLCHECK:-shellcheck}"
|
||||
CI_EDITORCONFIG_CHECKER="${CI_EDITORCONFIG_CHECKER:-editorconfig-checker}"
|
||||
CI_YAMLLINT="${CI_YAMLLINT:-yamllint}"
|
||||
|
||||
# Initialize the global lint counter.
|
||||
CI_LINT_COUNTER=0
|
||||
# Initialize the global lint status.
|
||||
CI_LINT_STATUS=0
|
||||
|
||||
function ci_init_lint {
|
||||
ci_info "## START OF LINTING ##"
|
||||
@ -45,14 +45,13 @@ function ci_init_lint {
|
||||
|
||||
function ci_finish_lint {
|
||||
ci_info "## END OF LINTING ##"
|
||||
if [[ $CI_LINT_COUNTER -eq 0 ]]
|
||||
if [[ $CI_LINT_STATUS -eq 0 ]]
|
||||
then
|
||||
ci_info "## SUCCESS ##"
|
||||
return 0
|
||||
else
|
||||
ci_info "linting failed"
|
||||
return 1
|
||||
fi
|
||||
return "$CI_LINT_STATUS"
|
||||
}
|
||||
|
||||
function ci_lint_ci_scripts {
|
||||
@ -61,15 +60,17 @@ function ci_lint_ci_scripts {
|
||||
return 0
|
||||
}
|
||||
ci_info "## LINTING: CI scripts ##"
|
||||
{
|
||||
local my_file
|
||||
ci_spawn "$CI_SHELLCHECK" --version
|
||||
find ./ci -maxdepth 1 -name "*.sh" |
|
||||
find ./ci -name "*.sh" -perm +111 | {
|
||||
local my_file
|
||||
while IFS="" read -r my_file
|
||||
do
|
||||
ci_spawn "$CI_SHELLCHECK" -x "$my_file"
|
||||
ci_spawn "$CI_SHELLCHECK" -x "$my_file" || {
|
||||
# Linting failed.
|
||||
return 1
|
||||
}
|
||||
done
|
||||
} || CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
|
||||
}
|
||||
}
|
||||
|
||||
function ci_lint_text_files {
|
||||
@ -80,7 +81,8 @@ function ci_lint_text_files {
|
||||
ci_info "## LINTING: text files ##"
|
||||
ci_spawn "$CI_EDITORCONFIG_CHECKER" --version
|
||||
ci_spawn "$CI_EDITORCONFIG_CHECKER" || {
|
||||
CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
|
||||
# Linting failed.
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,22 +92,24 @@ function ci_lint_yaml_files {
|
||||
return 0
|
||||
}
|
||||
ci_info "## LINTING: YAML files ##"
|
||||
{
|
||||
local my_file
|
||||
ci_spawn "$CI_YAMLLINT" --version
|
||||
find . \( -iname "*.yml" -o -iname "*.yaml" \) -not -path "./out/*" |
|
||||
find . \( -iname "*.yml" -o -iname "*.yaml" \) -not -path "./out/*" | {
|
||||
local my_file
|
||||
while IFS="" read -r my_file
|
||||
do
|
||||
ci_spawn "$CI_YAMLLINT" --strict "$my_file"
|
||||
ci_spawn "$CI_YAMLLINT" --strict "$my_file" || {
|
||||
# Linting failed.
|
||||
return 1
|
||||
}
|
||||
done
|
||||
} || CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
|
||||
}
|
||||
}
|
||||
|
||||
function ci_lint {
|
||||
ci_init_lint
|
||||
ci_lint_ci_scripts
|
||||
ci_lint_text_files
|
||||
ci_lint_yaml_files
|
||||
ci_lint_ci_scripts || CI_LINT_STATUS=1
|
||||
ci_lint_text_files || CI_LINT_STATUS=1
|
||||
ci_lint_yaml_files || CI_LINT_STATUS=1
|
||||
# TODO: ci_lint_png_files, etc.
|
||||
ci_finish_lint
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user