Merge pull request #417 from mlocati/shfmt

Always use shfmt 3.3.1, test all POSIX scripts
pull/419/head 1.2.54
Michele Locati 2021-08-12 18:00:57 +02:00 committed by GitHub
commit 61114671c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 34 deletions

View File

@ -3,28 +3,38 @@
set -o errexit set -o errexit
set -o nounset set -o nounset
PARAMS='-s -ln posix -i 0 -ci -kp' . ./scripts/common
# -s Simplify the code
# -ln posix Language variant: POSIX
# -i 0 Use TAB to indent
# -ci Switch cases will be indented
# -kp Keep column alignment paddings
DPEI_PARAMS='-s -ln posix -i 0 -ci -kp'
case "${1:-}" in case "${1:-}" in
check) check)
PARAMS="$PARAMS -d" DPEI_PARAMS="$DPEI_PARAMS -d"
;; ;;
fix) fix)
PARAMS="$PARAMS -w" DPEI_PARAMS="$DPEI_PARAMS -w"
;; ;;
*) *)
printf 'Syntax: %s <check|fix>' "$0" >&2 printf 'Syntax: %s <check|fix>\n' "$0" >&2
exit 1 exit 1
;; ;;
esac esac
shfmt $PARAMS \ DPEI_FILES=install-php-extensions
install-php-extensions \
scripts/ci-filter-supported-extensions \ IFS='
scripts/ci-retrieve-recent-extensions \ '
scripts/ci-test-extensions \ for DPEI_FILE in $(find scripts -type f); do
scripts/common \ if test "$(head -n1 $DPEI_FILE)" = '#!/bin/sh'; then
scripts/invoke-shfmt \ DPEI_FILES="$DPEI_FILES $DPEI_FILE"
scripts/lint \ fi
scripts/test-restore-apt \ done
scripts/update-readme
resetIFS
FORCE_COLOR=true shfmt $DPEI_PARAMS -- $DPEI_FILES

View File

@ -11,7 +11,7 @@ echo '# Linting shell scripts'
if ! docker --version >/dev/null 2>/dev/null; then if ! docker --version >/dev/null 2>/dev/null; then
echo 'Docker is not installed, or it is not running.' >&2 echo 'Docker is not installed, or it is not running.' >&2
rc=1 rc=1
elif ! docker run --rm -v "$SRC_DIR:/src" -w /src --entrypoint /src/scripts/invoke-shfmt mvdan/shfmt:v3.0.1 fix; then elif ! docker run --rm -v "$SRC_DIR:/src" -w /src --entrypoint /src/scripts/invoke-shfmt mvdan/shfmt:v3.3.1 fix; then
echo 'ERROR!' >&2 echo 'ERROR!' >&2
rc=1 rc=1
fi fi

View File

@ -16,7 +16,7 @@ if errorlevel 1 (
echo Docker is not installed, or it's not running >&2 echo Docker is not installed, or it's not running >&2
set rc=1 set rc=1
) else ( ) else (
docker run --rm -v "%SRC_DIR%:/src" -w /src --entrypoint /src/scripts/invoke-shfmt mvdan/shfmt:v3.0.1 fix docker run --rm -v "%SRC_DIR%:/src" -w /src --entrypoint /src/scripts/invoke-shfmt mvdan/shfmt:v3.3.1 fix
if errorlevel 1 ( if errorlevel 1 (
echo ERROR! >&2 echo ERROR! >&2
set rc=1 set rc=1

View File

@ -7,24 +7,24 @@ set -o nounset
WANTED_VERSION="${1:-}" WANTED_VERSION="${1:-}"
INSTALLME=@composer INSTALLME=@composer
if test -n "$WANTED_VERSION"; then if test -n "$WANTED_VERSION"; then
INSTALLME="$INSTALLME-$1" INSTALLME="$INSTALLME-$1"
fi fi
CI=true ./install-php-extensions "$INSTALLME" CI=true ./install-php-extensions "$INSTALLME"
INSTALLED_VERSION="$(composer --version | sed -E 's/^.*[Vv]ersion\s*(\S+).*$/\1/')" INSTALLED_VERSION="$(composer --version | sed -E 's/^.*[Vv]ersion\s*(\S+).*$/\1/')"
if test -z "$WANTED_VERSION"; then if test -z "$WANTED_VERSION"; then
echo 'Installing the latest version worked' echo 'Installing the latest version worked'
elif printf '%s' "$WANTED_VERSION" | grep -Eq '^[0-9]+$'; then elif printf '%s' "$WANTED_VERSION" | grep -Eq '^[0-9]+$'; then
if test "${INSTALLED_VERSION#$WANTED_VERSION.}" = "$INSTALLED_VERSION"; then if test "${INSTALLED_VERSION#$WANTED_VERSION.}" = "$INSTALLED_VERSION"; then
printf 'Installing major version %s DID NOT worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" printf 'Installing major version %s DID NOT worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION"
exit 1 exit 1
fi fi
printf 'Installing major version %s worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" printf 'Installing major version %s worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION"
else else
if test "$INSTALLED_VERSION" != "$WANTED_VERSION"; then if test "$INSTALLED_VERSION" != "$WANTED_VERSION"; then
printf 'Installing specific version %s DID NOT worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" printf 'Installing specific version %s DID NOT worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION"
exit 1 exit 1
fi fi
printf 'Installing specific version %s worked\n' "$INSTALLED_VERSION" printf 'Installing specific version %s worked\n' "$INSTALLED_VERSION"
fi fi

View File

@ -8,19 +8,19 @@ WANTED_VERSION="${1:-}"
WANTED_VERSION_AFTERCARET="${1#^}" WANTED_VERSION_AFTERCARET="${1#^}"
INSTALLME=xdebug INSTALLME=xdebug
if test -n "$WANTED_VERSION"; then if test -n "$WANTED_VERSION"; then
INSTALLME="$INSTALLME-$1" INSTALLME="$INSTALLME-$1"
fi fi
CI=true ./install-php-extensions "$INSTALLME" CI=true ./install-php-extensions "$INSTALLME"
INSTALLED_VERSION="$(php --ri xdebug | grep -Ei 'Version\s*=>\s*' | sed -E 's/^.*?=>\s*//')" INSTALLED_VERSION="$(php --ri xdebug | grep -Ei 'Version\s*=>\s*' | sed -E 's/^.*?=>\s*//')"
if test -z "$WANTED_VERSION"; then if test -z "$WANTED_VERSION"; then
printf 'Installing the default version worked (we installed version %s)\n' "$INSTALLED_VERSION" printf 'Installing the default version worked (we installed version %s)\n' "$INSTALLED_VERSION"
elif test "$WANTED_VERSION" = "$INSTALLED_VERSION"; then elif test "$WANTED_VERSION" = "$INSTALLED_VERSION"; then
printf 'Installing specific version %s worked\n' "$WANTED_VERSION" printf 'Installing specific version %s worked\n' "$WANTED_VERSION"
elif test "$WANTED_VERSION" != "$WANTED_VERSION_AFTERCARET" && test "${INSTALLED_VERSION#$WANTED_VERSION_AFTERCARET.}" != "$INSTALLED_VERSION"; then elif test "$WANTED_VERSION" != "$WANTED_VERSION_AFTERCARET" && test "${INSTALLED_VERSION#$WANTED_VERSION_AFTERCARET.}" != "$INSTALLED_VERSION"; then
printf 'Installing version compatible with %s worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" printf 'Installing version compatible with %s worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION"
else else
printf 'We wanted to install version %s, but we installed %s\n' "$WANTED_VERSION" "$INSTALLED_VERSION" >&2 printf 'We wanted to install version %s, but we installed %s\n' "$WANTED_VERSION" "$INSTALLED_VERSION" >&2
exit 1 exit 1
fi fi