Skip to content
Open
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
6 changes: 6 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pylint
source dependency/bash-lint.sh
echo "$(dirname $SHELLCHECK_EXE)" > $GITHUB_PATH

- name: Analysing the code with pylint
run: |
pylint .

- name: Analysing the code with shellchecker
run: |
shellcheck **/*.sh

# TODO: Add more linters here
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ venv
.ci/micromamba/bin/
.ci/micromamba/micromamba/

# Ignore installed dependencies
dependency/bin/

# Ignore FOSS project clone dirs
/test/foss/*/test-proj/

Expand Down
48 changes: 48 additions & 0 deletions dependency/bash-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "Error: This script must be run using 'source'"
echo "Usage: source $0 [clean|force]"
exit 1
fi

THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
TARGET_DIR="$THIS_DIR/bin"
TARGET_PATH="$TARGET_DIR/shellcheck"

VERSION="v0.11.0"
URL="https://github.com/koalaman/shellcheck/releases/download/${VERSION}/shellcheck-${VERSION}.linux.x86_64.tar.xz"

case "$1" in
clean)
echo "Cleaning shellcheck installation..."
rm -f "$TARGET_PATH"
unalias shellcheck 2>/dev/null
unset SHELLCHECK_EXE
return 0
;;
force)
echo "Force flag detected. Removing existing binary..."
rm -f "$TARGET_PATH"
;;
*)
# Default behavior
;;
esac

if [ ! -f "$TARGET_PATH" ]; then
echo "Installing spellcheck to $TARGET_DIR ..."
mkdir -p "$TARGET_DIR"
if wget -qO "$TARGET_PATH.tar.xz" "$URL"; then
tar -xf "$TARGET_PATH.tar.xz" -C "$TARGET_DIR" --strip-components=1 "shellcheck-${VERSION}/shellcheck"
rm "$TARGET_PATH.tar.xz"
echo "spellcheck installed successfully."
else
echo "Error: Failed to download spellcheck."
return 1
fi
else
echo "spellcheck already installed"
fi

export SHELLCHECK_EXE="$TARGET_PATH"
alias shellcheck='$SHELLCHECK_EXE'
2 changes: 1 addition & 1 deletion test/test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
python3 -m unittest discover unit $@
python3 -m unittest discover unit "$@"