diff --git a/.drone.yml b/.drone.yml index dd34f73..e3a3de1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -94,6 +94,12 @@ steps: commands: - ./tools/ci/static_analysis/cmake_format.sh +- name: shell format + image: ci:latest + pull: if-not-exists + commands: + - ./tools/ci/static_analysis/shell_format.sh + --- kind: pipeline type: docker diff --git a/tools/ci/static_analysis/shell_format.sh b/tools/ci/static_analysis/shell_format.sh new file mode 100755 index 0000000..9464830 --- /dev/null +++ b/tools/ci/static_analysis/shell_format.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -euo pipefail +cd "$(git rev-parse --show-toplevel)/" + +has_fomatting_issues=0 + +while IFS= read -r -d '' file; do + echo "Checking format for $file" + + if ! shfmt -i 4 -ci -d "$file"; then + echo "❌ Formatting issue detected in $file" + has_fomatting_issues=1 + fi +done < <(find ./modules ./tools -name '*.sh' -print0) + +if [ "$has_fomatting_issues" -eq 0 ]; then + echo "✅ All files are properly formatted! Well done! ^~^" +fi + +exit ${has_fomatting_issues}