From 77b2cfc3748c69ad60e6ff189dddf39de0743161 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 11 Oct 2021 00:41:20 +0300 Subject: [PATCH] ci/lint: Fix lint-shell.sh in CI (#4489) * lint: Skip shell linting if gawk is not installed * lint: Skip Gitian descriptor scripts checking if jq is not installed * ci: Install gawk and jq `yq` requires `jq` * Fix shellcheck warnings --- ci/Dockerfile.builder | 2 +- contrib/gitian-descriptors/gitian-osx.yml | 2 +- contrib/gitian-descriptors/gitian-win.yml | 2 +- depends/config.site.in | 2 +- test/lint/lint-shell.sh | 10 ++++++++++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ci/Dockerfile.builder b/ci/Dockerfile.builder index 8a45a6d500..4de34e6d69 100644 --- a/ci/Dockerfile.builder +++ b/ci/Dockerfile.builder @@ -40,7 +40,7 @@ RUN apt-get update && apt-get install $APT_ARGS g++-arm-linux-gnueabihf && rm -r RUN apt-get update && apt-get install $APT_ARGS g++-mingw-w64-x86-64 && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install $APT_ARGS wine-stable wine32 wine64 bc nsis xorriso && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install $APT_ARGS python3-zmq && rm -rf /var/lib/apt/lists/* -RUN apt-get update && apt-get install $APT_ARGS cppcheck && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install $APT_ARGS cppcheck gawk jq && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install $APT_ARGS imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools && rm -rf /var/lib/apt/lists/* ARG SHELLCHECK_VERSION=v0.7.1 diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml index 7da7273082..3fc7c33c72 100644 --- a/contrib/gitian-descriptors/gitian-osx.yml +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -180,7 +180,7 @@ script: | find . -name "lib*.la" -delete find . -name "lib*.a" -delete rm -rf ${DISTNAME}/lib/pkgconfig - find .. -name *.dSYM -exec cp -ra {} ${DISTNAME}/bin \; + find .. -name "*.dSYM" -exec cp -ra {} ${DISTNAME}/bin \; find ${DISTNAME} -not -path '*.dSYM*' | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}.tar.gz find ${DISTNAME} -path '*.dSYM*' | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}-debug.tar.gz cd ../../ diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index cdd503d77c..36627154a2 100755 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -180,7 +180,7 @@ script: | make ${MAKEOPTS} -C src check-security make deploy make install DESTDIR=${INSTALLPATH} - rename 's/-setup\.exe$/-setup-unsigned.exe/' *-setup.exe + rename 's/-setup\.exe$/-setup-unsigned.exe/' "*-setup.exe" cp -f dashcore-*setup*.exe $OUTDIR/ cd installed mv ${DISTNAME}/bin/*.dll ${DISTNAME}/lib/ diff --git a/depends/config.site.in b/depends/config.site.in index 8bea246944..5cada6865d 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -47,7 +47,7 @@ if test -n "@debug@" && test -z "@no_qt@" && test "x$with_gui" != xno; then with_gui=qt5_debug fi -if test x@host_os@ = xdarwin; then +if test "@host_os@" = darwin; then BREW=no PORT=no fi diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index ca971456eb..38d42e412e 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -50,6 +50,11 @@ if ! command -v shellcheck > /dev/null; then exit $EXIT_CODE fi +if ! command -v gawk > /dev/null; then + echo "Skipping shell linting since gawk is not installed." + exit $EXIT_CODE +fi + EXCLUDE="--exclude=$(IFS=','; echo "${disabled[*]}")" SOURCED_FILES=$(git ls-files | xargs gawk '/^# shellcheck shell=/ {print FILENAME} {nextfile}') # Check shellcheck directive used for sourced files if ! shellcheck "$EXCLUDE" $SOURCED_FILES $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|univalue)/'); then @@ -61,6 +66,11 @@ if ! command -v yq > /dev/null; then exit $EXIT_CODE fi +if ! command -v jq > /dev/null; then + echo "Skipping Gitian descriptor scripts checking since jq is not installed." + exit $EXIT_CODE +fi + EXCLUDE_GITIAN=${EXCLUDE}",$(IFS=','; echo "${disabled_gitian[*]}")" for descriptor in $(git ls-files -- 'contrib/gitian-descriptors/*.yml') do