Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Integrate shellcheck #232

Merged
merged 3 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,18 @@ jobs:
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

shellcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run shellcheck
run: ./scripts/ci-run-shellcheck.sh

ci:
needs: [tag, clang-format, cppcheck]
needs: [tag, clang-format, cppcheck, shellcheck]

strategy:
matrix:
Expand Down Expand Up @@ -439,7 +449,7 @@ jobs:
run: ./scripts/ci-update-homebrew-tap.sh

ci-bsd:
needs: [tag, clang-format, cppcheck]
needs: [tag, clang-format, cppcheck, shellcheck]
runs-on: ubuntu-latest

permissions:
Expand Down
1 change: 1 addition & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable=SC2153
10 changes: 5 additions & 5 deletions app/test/select-quotebuff-gen.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh

i=0;
while [ $i -lt 2000 ] ; do
i=0
while [ $i -lt 2000 ]; do
j=0
while [ $j -lt 20 ] ; do
while [ $j -lt 20 ]; do
printf '"a,b",'
j=$(($j+1))
j=$((j + 1))
done

echo ''
i=$(($i+1))
i=$((i + 1))
done
2 changes: 1 addition & 1 deletion scripts/ci-create-debian-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mv -f "./$PREFIX/bin" "./$PREFIX/usr/"

echo "[INF] Creating control file [$DEBIAN_CONTROL_FILE]"

INSTALLED_SIZE="$(echo $(du -s -c $PREFIX/usr/* | grep 'total') | cut -d ' ' -f1)"
INSTALLED_SIZE="$(du -s -c "$PREFIX"/usr/* | grep 'total' | xargs | cut -d ' ' -f1)"
cat <<EOF >"$DEBIAN_CONTROL_FILE"
Package: zsv
Version: $VERSION
Expand Down
54 changes: 54 additions & 0 deletions scripts/ci-run-shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh

set -e

echo "[INF] Running $0"

VERSION=$(shellcheck --version | grep 'version:' | cut -d ' ' -f2)
if [ "$VERSION" = "" ]; then
echo "[ERR] shellcheck is not installed!"
exit 1
fi

echo "[INF] shellcheck version [$VERSION]"

echo "[INF] Running shellcheck..."

shellcheck --format=tty \
configure \
app/test/*.sh \
scripts/*.sh \
setup-action/scripts/*.bash || true

if [ "$CI" = true ]; then
{
echo "<details>"
echo "<summary>Shellcheck Summary (tty format)</summary>"
echo
echo '```'
shellcheck --format=tty \
configure \
app/test/*.sh \
scripts/*.sh \
setup-action/scripts/*.bash \
2>&1 || true
echo '```'
echo "</details>"
echo
echo "<details>"
echo "<summary>Shellcheck Summary (diff format)</summary>"
echo
echo '```diff'
shellcheck --format=diff \
configure \
app/test/*.sh \
scripts/*.sh \
setup-action/scripts/*.bash \
2>&1 || true
echo '```'
echo "</details>"
} >>"$GITHUB_STEP_SUMMARY"
fi

echo "[INF] shellcheck ran successfully!"
echo "[INF] --- [DONE] ---"