Skip to content

Commit

Permalink
Merge pull request #1460 from p-l-/lint-agent
Browse files Browse the repository at this point in the history
lint: use shellcheck against the agent
  • Loading branch information
p-l- committed Dec 13, 2022
2 parents 2644a89 + 8af418f commit c7f2871
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ jobs:
- run: sphinx-lint -e all -d line-too-long -d default-role ./doc/

- run: shellcheck .github/actions/install/install*.sh pkg/builddockers pkg/builddocs pkg/buildrpm pkg/runchecks

- run: FNAME=`mktemp`; ivre runscans --output Agent > "$FNAME"; shellcheck "$FNAME"; rm -f "$FNAME"
18 changes: 11 additions & 7 deletions ivre/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@
"$CURDIR/$fname.xml.bz2"; then
# find screenshots
OIFS="$IFS"
IFS=$'\n'
set -- `_get_screenshots "$CURDIR/$fname.xml.bz2"`
IFS='\n'
# shellcheck disable=SC2046
set -- $(_get_screenshots "$CURDIR/$fname.xml.bz2")
IFS="$OIFS"
tar cf "$DATADIR/$fname.tar" "$@" 2>/dev/null
rm -f -- "$@"
Expand All @@ -91,7 +92,7 @@
pids=$1
for pid in $pids; do
# Is $pid alive?
kill -0 $pid 2> /dev/null && return 0
kill -0 "$pid" 2> /dev/null && return 0
done
# Everyone is dead
Expand All @@ -105,20 +106,22 @@
master_prompt="[master ] "
# clean children on exit
# shellcheck disable=SC2064
trap "trap - TERM INT EXIT; echo '${master_prompt}shutting down' >&2;\\
pkill -g 0; exit" TERM INT EXIT
echo "${master_prompt}spawning $THREADS workers" >&2
export IVRE_WORKER=1
worker_pids=""
for i in `seq 1 $THREADS`; do
worker_prompt="[worker `printf %%-4d $i`] "
for i in $(seq 1 $THREADS); do
worker_prompt="[worker $(printf %%-4d "$i")] "
("$0" "$@" 2>&1 | sed -u "s/^/$worker_prompt/") &
worker_pids="$! $worker_pids"
done
unset IVRE_WORKER
# handle wait interruptions (any non terminating signal)
# shellcheck disable=SC2086
while someone_alive $worker_pids; do
wait
done
Expand All @@ -131,7 +134,8 @@
while true; do
[ -f "want_down" ] && break
fname=`ls -rt "$INDIR" | head -1`
# shellcheck disable=SC2012
fname="$(ls -rt "$INDIR" | head -1)"
if [ -z "$fname" ]; then
$SLEEP
continue
Expand All @@ -150,7 +154,7 @@
if ! ($scan < "$CURDIR/$fname.targets" | bzip2 > "$CURDIR/$fname.xml.bz2");
then
now="`date +%%s`"
now="$(date +%%s)"
mv "$CURDIR/$fname.xml.bz2" "$ERRORDIR/$fname-$now.xml.bz2"
cp "$CURDIR/$fname" "$ERRORDIR/$fname-$now"
mv "$CURDIR/$fname" "$INDIR/"
Expand Down
6 changes: 6 additions & 0 deletions pkg/runchecks
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ if ! find ./doc/ -type f -name '*.rst' -print0 | xargs -0 grep '[[:space:]]$'; t
sphinx-lint -e all -d line-too-long -d default-role ./doc/ && echo "sphinx-lint OK"

shellcheck .github/actions/install/install*.sh pkg/builddockers pkg/builddocs pkg/buildrpm pkg/runchecks && echo "shellcheck OK"

FNAME="$(mktemp)"
ivre runscans --output Agent > "$FNAME"
shellcheck "$FNAME" && echo "shellcheck agent.sh OK"
rm -f "$FNAME"
unset FNAME

0 comments on commit c7f2871

Please sign in to comment.