Skip to content

Commit

Permalink
✨ add a GitHub Action for shellcheck'ing on every PR and push to mast…
Browse files Browse the repository at this point in the history
…er branch + shellcheck'ed script
  • Loading branch information
thomasmerz committed Jun 7, 2024
1 parent 3a43179 commit fd0a76b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 5 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Shellcheck Lint

on:
push:
paths:
# Run workflow on every push
# only if a file within the specified paths has been changed:
- 'lsix'

pull_request:
paths:
# Run workflow on every push
# only if a file within the specified paths has been changed:
- 'lsix'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
name: Shellcheck Lint

# This job runs on Linux
runs-on: ubuntu-latest

steps:
# Required to access files of this repository
- uses: actions/checkout@v4

# Download Shellcheck and add it to the workflow path
- name: Download Shellcheck
run: |
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv
chmod +x shellcheck-stable/shellcheck
# Verify that Shellcheck can be executed
- name: Check Shellcheck Version
run: |
shellcheck-stable/shellcheck --version
# Run Shellcheck on repository
# ---
# https://github.com/koalaman/shellcheck
# ---
# Excluded checks:
# https://www.shellcheck.net/wiki/SC1091 -- Not following: /etc/rc.status was...
# https://www.shellcheck.net/wiki/SC1090 -- Can't follow non-constant source. ..
# ---
- name: Run Shellcheck
run: |
set +e
find ./*/ -type f | while read -r sh; do
if [ "$(file --brief --mime-type "$sh")" == 'text/x-shellscript' ]; then
echo "shellcheck'ing $sh"
if ! shellcheck-stable/shellcheck --color=always --severity=warning --exclude=SC1091,SC1090 "$sh"; then
touch some_scripts_have_failed_shellcheck
fi
fi
done
if [ -f ./some_scripts_have_failed_shellcheck ]; then
echo "Shellcheck failed for one or more shellscript(s)"
exit 1
fi
10 changes: 5 additions & 5 deletions lsix
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fi
if [[ "$COMSPEC" ]]; then
alias convert="magick convert" # Shun MS Windows' "convert" command.
fi

cleanup() {
echo -n $'\e\\' # Escape sequence to stop SIXEL.
stty echo # Reset terminal to show characters.
Expand Down Expand Up @@ -193,7 +193,7 @@ main() {
readarray -t < <(printf "%s\n" "$@" | sort)

# Only show first frame of animated GIFs if filename not specified.
for x in ${!MAPFILE[@]}; do
for x in "${!MAPFILE[@]}"; do
if [[ ${MAPFILE[$x]} =~ (gif|webp)$ ]]; then
MAPFILE[$x]="${MAPFILE[$x]}[0]"
fi
Expand All @@ -205,7 +205,7 @@ main() {
for arg; do
if [ -d "$arg" ]; then
echo Recursing on $arg
(cd "$arg"; $lsix)
(cd "$arg" || exit; $lsix)
else
nodirs+=("$arg")
fi
Expand All @@ -215,7 +215,7 @@ main() {


# Resize on load: Save memory by appending this suffix to every filename.
resize="[${tilewidth}x${tileheight}]"
#resize="[${tilewidth}x${tileheight}]" ### DONE: SC2034 (warning): resize appears unused. Verify use (or export if used externally).

imoptions="-tile ${numtiles}x1" # Each montage is 1 row x $numtiles columns
imoptions+=" -geometry ${tilewidth}x${tileheight}>+${tilexspace}+${tileyspace}" # Size of each tile and spacing
Expand All @@ -234,7 +234,7 @@ main() {
# While we still have images to process...
onerow=()
goal=$(($# - numtiles)) # How many tiles left after this row
while [ $# -gt 0 -a $# -gt $goal ]; do
while [ $# -gt 0 ] && [ $# -gt $goal ]; do
len=${#onerow[@]}
onerow[len++]="-label"
onerow[len++]=$(processlabel "$1")
Expand Down

0 comments on commit fd0a76b

Please sign in to comment.