From fd1e0641789f9bb6fa2bd551af10eec593f3945a Mon Sep 17 00:00:00 2001 From: Ben Grande Date: Mon, 6 Nov 2023 16:26:00 +0000 Subject: [PATCH] Fail --- .github/workflows/main.yaml | 5 ++++- .gitlint | 2 +- .pre-commit-config.yaml | 18 +++++++++--------- CONTRIBUTING.md | 1 + scripts/salt-lint.sh | 16 +++++++++++++++- scripts/shell-lint.sh | 21 +++++++++++++++++++++ 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 7047a35..d0a500b 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -17,7 +17,10 @@ jobs: - uses: pre-commit/action@v3.0.0 - name: Install dependencies - run: apt update -y && apt install -y gitlint + run: | + apt update -y + apt install -y python3-dev python3-pip gitlint shellcheck reuse + pip3 install salt-lint - name: Gitlint # yamllint disable-line rule:line-length run: gitlint --debug --commits ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} diff --git a/.gitlint b/.gitlint index 20e43a0..80dd9e0 100644 --- a/.gitlint +++ b/.gitlint @@ -14,7 +14,7 @@ ignore-squash-commits=false fail-without-commits=true regex-style-search=true debug=false -contrib=contrib-title-conventional-commits,contrib-body-requires-signed-off-by +contrib=contrib-title-conventional-commits [title-max-length] line-length=50 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b418a5..c83ff92 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,21 +10,14 @@ repos: name: salt-lint entry: scripts/salt-lint.sh language: script - pass_filenames: false + pass_filenames: true description: Lint Salt files - id: shellcheck name: shellcheck entry: scripts/shell-lint.sh language: script - pass_filenames: false + pass_filenames: true description: Lint Shellscripts - - id: gitlint - name: gitlint - language: python - entry: gitlint - args: [--staged, --msg-filename] - stages: [commit-msg] - description: Lint Git commits - id: reuse name: reuse entry: reuse @@ -32,3 +25,10 @@ repos: language: python pass_filenames: false description: Lint files to comply with the REUSE Specification + - id: gitlint + name: gitlint + language: python + entry: gitlint + args: [--staged, --msg-filename] + stages: [commit-msg] + description: Lint Git commits diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 452645b..37d83a4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,6 @@ # Contributing + ## Table of Contents * [Respect](#respect) diff --git a/scripts/salt-lint.sh b/scripts/salt-lint.sh index 8cf444d..b9e9ebc 100755 --- a/scripts/salt-lint.sh +++ b/scripts/salt-lint.sh @@ -24,9 +24,23 @@ elif command -v fdfind >/dev/null; then find_tool="fdfind" fi +if test -n "${1-}"; then + files="" + for f in "$@"; do + test -f "$f" || continue + extension="$(echo "$f" | awk -F '.' '{print $NF}')" + case "$extension" in + top|sls) files="$files $f";; + *) continue;; + esac + done + test -n "$files" || exit 0 + exec salt-lint ${conf} ${files} +fi + case "${find_tool}" in fd|fdfind) files="minion.d/qusal.conf $(${find_tool} . qusal/ --max-depth=2 --type=f --extension=sls --extension=top)";; find) files="minion.d/qusal.conf $(find qusal/* -maxdepth 2 -type f \( -name '*.sls' -o -name '*.top' \))";; esac -salt-lint ${conf} ${files} +exec salt-lint ${conf} ${files} diff --git a/scripts/shell-lint.sh b/scripts/shell-lint.sh index f7915a3..274c87f 100755 --- a/scripts/shell-lint.sh +++ b/scripts/shell-lint.sh @@ -26,6 +26,27 @@ elif command -v fdfind >/dev/null; then find_tool="fdfind" fi +if test -n "${1-}"; then + files="" + sh_files="" + for f in "$@"; do + test -f "$f" || continue + if test "${f##*/}" = "rc.local"; then + sh_files="$sh_files $f" + continue + fi + case $( file -bi "$f" ) in + (*/x-shellscript*) files="$files $f";; + esac + done + if test -n "$files" || test -n "$sh_files"; then + exit 0 + fi + test -z "$files" || shellcheck ${files} + test -z "$sh_files" || shellcheck -s sh ${sh_files} + exit +fi + case "${find_tool}" in fd|fdfind) # shellcheck disable=2016,2215