-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-scripts
More file actions
executable file
·37 lines (30 loc) · 1.39 KB
/
check-scripts
File metadata and controls
executable file
·37 lines (30 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# @description Run the combined shellcheck and check-shdoc-headers gate over shell scripts in the repo. When invoked with no paths, checks every in-scope script. The shdoc-header audit always runs over the full in-scope set regardless of per-file args, since header presence is a whole-repo property. Aggregates exit codes so a failure in either tool fails the whole run.
# @arg $@ paths Optional file or directory paths to check; omit to check the full in-scope set.
# @exitcode 0 All files pass shellcheck, and the shdoc header audit is clean.
# @exitcode 1 One or more files failed shellcheck, or check-shdoc-headers.
set -Eeuo pipefail
IFS=$'\n\t'
#shellcheck disable=SC1091
source "${SCRIPTS_DIR}/.functions.bash"
log::enable_err_trap
args::handle_help_flag "$@"
system::require_bash_version 4 3
shell_scripts::assert_paths_exist "$@"
files::create_temp candidates_tmp
# shellcheck disable=SC2154 # candidates_tmp set via nameref inside files::create_temp
shell_scripts::find "$@" > "${candidates_tmp}"
mapfile -t candidates < "${candidates_tmp}"
if [[ "${#candidates[@]}" -eq 0 ]]; then
exit 0
fi
files=()
shell_scripts::filter files "${candidates[@]}"
if [[ "${#files[@]}" -eq 0 ]]; then
exit 0
fi
rc=0
shellcheck "${files[@]}" || rc=1
# Always audit the full in-scope set — partial runs would let regressions slip in.
"${SCRIPTS_DIR}/.ci/check-shdoc-headers" || rc=1
exit "${rc}"