Add shellcheck lint
Run shellcheck [1] on the bash files. [1]: https://www.shellcheck.net/ Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
623d3ce8ab
commit
7205f1a49e
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -16,6 +16,9 @@ jobs:
|
||||
- name: Check formatting
|
||||
run: ./scripts/lint/02-clang-format.sh
|
||||
|
||||
- name: Check shell scripts
|
||||
run: ./scripts/lint/03-shellcheck.sh
|
||||
|
||||
tool:
|
||||
strategy:
|
||||
matrix:
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
FILES=($(git ls-files '*.[ch]'))
|
||||
readarray -t FILES < <(git ls-files '*.c' '*.h')
|
||||
|
||||
FMT_OPTS=(
|
||||
"-style=file"
|
||||
|
@ -29,6 +29,7 @@ if [[ "${ID}" =~ "debian" ]] || [[ "${ID_LIKE}" =~ "debian" ]]; then
|
||||
make \
|
||||
pkgconf \
|
||||
sdcc \
|
||||
shellcheck \
|
||||
xxd
|
||||
elif [[ "${ID}" =~ "fedora" ]] || [[ "${ID_LIKE}" =~ "fedora" ]]; then
|
||||
sudo dnf install \
|
||||
@ -41,6 +42,7 @@ elif [[ "${ID}" =~ "fedora" ]] || [[ "${ID_LIKE}" =~ "fedora" ]]; then
|
||||
gcc \
|
||||
make \
|
||||
sdcc \
|
||||
ShellCheck \
|
||||
systemd-devel \
|
||||
vim-common
|
||||
elif [[ "${ID}" =~ "arch" ]] || [[ "${ID_LIKE}" =~ "arch" ]]; then
|
||||
@ -55,6 +57,7 @@ elif [[ "${ID}" =~ "arch" ]] || [[ "${ID_LIKE}" =~ "arch" ]]; then
|
||||
make \
|
||||
pkgconf \
|
||||
sdcc \
|
||||
shellcheck \
|
||||
systemd-libs \
|
||||
vim
|
||||
else
|
||||
|
36
scripts/lint/03-shellcheck.sh
Executable file
36
scripts/lint/03-shellcheck.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
# Check if any shell scripts have issues.
|
||||
|
||||
LINT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
||||
. "$LINT_DIR/util.sh"
|
||||
|
||||
echo -n "Checking shell scripts..."
|
||||
|
||||
if ! command -v shellcheck > /dev/null; then
|
||||
skipped "shellcheck not found"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
readarray -t FILES < <(git ls-files '*.sh')
|
||||
needs_formatting=()
|
||||
|
||||
for file in "${FILES[@]}"; do
|
||||
# SC1091: Ignore external scripts
|
||||
if ! shellcheck -f quiet --exclude=SC1091 "$file"; then
|
||||
needs_formatting+=("$file")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "${#needs_formatting[@]}" != "0" ]]; then
|
||||
failed
|
||||
|
||||
for file in "${needs_formatting[@]}"; do
|
||||
echo "- $file"
|
||||
done
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
passed
|
@ -60,7 +60,7 @@ do
|
||||
else
|
||||
F="$(date "+%T")"
|
||||
|
||||
last_E="$(sudo cat /sys/class/powercap/intel-rapl\:0/energy_uj)"
|
||||
last_E="$(sudo cat '/sys/class/powercap/intel-rapl:0/energy_uj')"
|
||||
sleep 1
|
||||
|
||||
if [ "${has_bat}" == "1" ]
|
||||
@ -73,15 +73,15 @@ do
|
||||
F="${F}\t$(printf "%.2f" "${bat_W}")"
|
||||
fi
|
||||
|
||||
E="$(sudo cat /sys/class/powercap/intel-rapl\:0/energy_uj)"
|
||||
E="$(sudo cat '/sys/class/powercap/intel-rapl:0/energy_uj')"
|
||||
W="$(echo "(${E} - ${last_E})/1000000" | bc -lq)"
|
||||
F="${F}\t$(printf "%.1f" "${W}")"
|
||||
|
||||
PL1_uW="$(sudo cat /sys/class/powercap/intel-rapl\:0/constraint_0_power_limit_uw)"
|
||||
PL1_uW="$(sudo cat '/sys/class/powercap/intel-rapl:0/constraint_0_power_limit_uw')"
|
||||
PL1_W="$(echo "${PL1_uW}/1000000" | bc -lq)"
|
||||
F="${F}\t$(printf "%.1f" "${PL1_W}")"
|
||||
|
||||
PL2_uW="$(sudo cat /sys/class/powercap/intel-rapl\:0/constraint_1_power_limit_uw)"
|
||||
PL2_uW="$(sudo cat '/sys/class/powercap/intel-rapl:0/constraint_1_power_limit_uw')"
|
||||
PL2_W="$(echo "${PL2_uW}/1000000" | bc -lq)"
|
||||
F="${F}\t$(printf "%.1f" "${PL2_W}")"
|
||||
|
||||
|
Reference in New Issue
Block a user