From 03902850a51bfeb8e21fbb99bc7e39559c33a8d0 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 12 Aug 2025 12:13:04 -0400 Subject: [PATCH 1/4] Add github action to shellcheck 3.x on push and PRs --- .github/workflows/shellcheck.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 000000000..661bee347 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,26 @@ +--- +name: Shellcheck + +on: + push: + branches: [3.x] + pull_request: + branches: [3.x] + +permissions: + contents: read + +jobs: + shellcheck: + name: Check shell scripts + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt update && sudo apt install -y shellcheck + - name: shellcheck + run: | + git grep -l '^#\( *shellcheck \|!\(/bin/\|/usr/bin/env \)\(sh\|bash\|dash\|ksh\)\)' | xargs shellcheck From ce211b8cd2a9e0637691625d81167373e4cca2b0 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 12 Aug 2025 12:14:05 -0400 Subject: [PATCH 2/4] [DATALAD RUNCMD] Auto-patch using shellcheck to robustify shell scripts === Do not change lines below === { "chain": [], "cmd": "shellcheckit autopatch", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^ --- scripts/build-public-docs.sh | 4 ++-- scripts/release.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/build-public-docs.sh b/scripts/build-public-docs.sh index 4eb06cb53..524f12095 100755 --- a/scripts/build-public-docs.sh +++ b/scripts/build-public-docs.sh @@ -26,11 +26,11 @@ fi if [ -n "${TAG_NAME}" ] && [[ "$TAG_NAME" =~ ^v[0-9]\.[0-9]+([\.a-z0-9]+)?$ ]]; then echo "Building ${BRANCH_NAME} docs for tag: ${TAG_NAME}" - env DOCS_VERSION=$BRANCH_NAME sphinx-build -a docs/ docs/public/en/$BRANCH_NAME/ + env DOCS_VERSION="$BRANCH_NAME" sphinx-build -a docs/ docs/public/en/"$BRANCH_NAME"/ if [ "${BRANCH_NAME}" = "${LATEST_BRANCH}" ]; then echo "Generating /page redirects" - env DOCS_VERSION=$BRANCH_NAME python scripts/generate_redirect_pages.py + env DOCS_VERSION="$BRANCH_NAME" python scripts/generate_redirect_pages.py fi fi diff --git a/scripts/release.sh b/scripts/release.sh index 734252f16..1333917fd 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -2,8 +2,8 @@ set -euo pipefail -VERSION=`python setup.py --version` -MAJOR_BRANCH="`python setup.py --version | cut -d'.' -f1`.x" +VERSION=$(python setup.py --version) +MAJOR_BRANCH="$(python setup.py --version | cut -d'.' -f1).x" echo "# Releasing pyinfra v${VERSION} (branch ${MAJOR_BRANCH})" From 1a0aef9de75338d6fc7103e941d80006f4b83e60 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 12 Aug 2025 12:18:33 -0400 Subject: [PATCH 3/4] Make release.sh to use bash since in POSIX sh pipefail is undefined --- scripts/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.sh b/scripts/release.sh index 1333917fd..2d2a4576d 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -euo pipefail From c297aa78873761dbbac14f073f2ade3df9ad8ac9 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 12 Aug 2025 12:18:55 -0400 Subject: [PATCH 4/4] Quote "$@" to correctly pass options into pytest to avoid splitting --- scripts/dev-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev-test.sh b/scripts/dev-test.sh index d24344460..9bed0b2cb 100755 --- a/scripts/dev-test.sh +++ b/scripts/dev-test.sh @@ -3,6 +3,6 @@ set -euo pipefail echo "Execute pytest..." -pytest $@ +pytest "$@" echo "Tests complete!"