Skip to content

Commit

Permalink
Merge pull request #14 from zstyblik/check_bash_shell
Browse files Browse the repository at this point in the history
Add checkbashisms and shellcheck as part of CI
  • Loading branch information
zstyblik authored Jul 15, 2024
2 parents fa531fe + 3b8c43b commit b7c8f80
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ii_wrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Git checkout
uses: actions/checkout@v4
- name: Install linters
uses: awalsh128/[email protected]
with:
packages: devscripts shellcheck
- name: Run checkbashisms
run: |
./ci/run-checkbashisms.sh
- name: Run shellcheck
run: |
./ci/run-shellcheck.sh
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
Expand Down
14 changes: 6 additions & 8 deletions ci/run-black.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ set -u

MODE=${1:?Mode must be given.}

if [ "${MODE}" == "check" ]; then
if [ "${MODE}" = "check" ]; then
black_arg=" --check"
elif [ "${MODE}" == "diff" ]; then
elif [ "${MODE}" = "diff" ]; then
black_arg=" --diff"
elif [ "${MODE}" == "format" ]; then
elif [ "${MODE}" = "format" ]; then
black_arg=""
else
printf "Mode '%s' is not supported.\n" "${MODE}" 1>&2
exit 1
fi

python3 \
-m black \
${black_arg} \
-l 80 \
`find . ! -path '*/\.*' -name '*.py'`
# shellcheck disable=SC2086
find . ! -path '*/\.*' -name '*.py' -print0 | \
xargs -0 -- python3 -m black ${black_arg} -l 80
6 changes: 6 additions & 0 deletions ci/run-checkbashisms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e
set -u

find . \( -name '*.sh' -or -name iibot-ng \) -print0 | \
xargs -0 -- checkbashisms --newline --force --lint --extra
3 changes: 2 additions & 1 deletion ci/run-reorder-python-imports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
set -e
set -u

reorder-python-imports `find . ! -path '*/\.*' -name '*.py'`
find . ! -path '*/\.*' -name '*.py' -print0 | \
xargs -0 -- reorder-python-imports
6 changes: 6 additions & 0 deletions ci/run-shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e
set -u

find . \( -name '*.sh' -or -name iibot-ng \) -print0 | \
xargs -0 -- shellcheck
4 changes: 4 additions & 0 deletions iibot-ng
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set -u

monitor()
{
# shellcheck disable=SC3043
local iipid="${1}"
tail -f -n1 --pid="${iipid}" "${ircdir}/${network}/${channel}/out" | \
# NOTE: format of output changed in v1.8
Expand All @@ -24,6 +25,8 @@ monitor()
if [ "$nick" = '-!-' ]; then
continue
fi
# shellcheck disable=SC2034
nixtime_is_unused="${nixtime}"
# strip < and >. if msg is by ourself ignore it
nick=$(printf -- "%s" "${nick}" | sed -e 's@^<@@' | sed -e 's@>$@@')
if [ "${nick}" = "${nickname}" ]; then
Expand Down Expand Up @@ -62,6 +65,7 @@ monitor()

monitor_link()
{
# shellcheck disable=SC3043
local iipid="${1}"
IFS='
'
Expand Down

0 comments on commit b7c8f80

Please sign in to comment.