mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-12 18:32:34 +02:00
Merge #17361: script: Lint Gitian descriptors with ShellCheck
17f81e9648
script: Enable SC2001 rule for Gitian scripts (Hennadii Stepanov)61bb21b418
script: Enable SC2155 rule for Gitian scripts (Hennadii Stepanov)577682d9e8
script: Enable SC2006 rule for Gitian scripts (Hennadii Stepanov)14aded46df
script: Lint Gitian descriptors with ShellCheck (Hennadii Stepanov) Pull request description: This PR extracts shell scripts from Gitian descriptors (`contrib/gitian-descriptors/`) and checks for ShellCheck warnings as any other one. Some non-controversial warnings are fixed. ACKs for top commit: practicalswift: ACK17f81e9648
-- diff looks correct Tree-SHA512: bdfa3d35bbb65ff634c90835d75c3df63e958b558599771d21366724f5cf64da83a68957d926e926a99c3704b9529e96a17697dc8d9ff3adf7154d9cb1999a8d
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (c) 2018 The Bitcoin Core developers
|
||||
# Copyright (c) 2018-2019 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#
|
||||
@ -16,16 +16,45 @@ if [ "$TRAVIS" = "true" ]; then
|
||||
unset LC_ALL
|
||||
fi
|
||||
|
||||
if ! command -v shellcheck > /dev/null; then
|
||||
echo "Skipping shell linting since shellcheck is not installed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Disabled warnings:
|
||||
disabled=(
|
||||
SC2046 # Quote this to prevent word splitting.
|
||||
SC2086 # Double quote to prevent globbing and word splitting.
|
||||
SC2162 # read without -r will mangle backslashes.
|
||||
)
|
||||
shellcheck -e "$(IFS=","; echo "${disabled[*]}")" \
|
||||
$(git ls-files -- "*.sh" | grep -vE 'src/(secp256k1|univalue)/')
|
||||
disabled_gitian=(
|
||||
SC2094 # Make sure not to read and write the same file in the same pipeline.
|
||||
SC2129 # Consider using { cmd1; cmd2; } >> file instead of individual redirects.
|
||||
SC2230 # which is non-standard. Use builtin 'command -v' instead.
|
||||
)
|
||||
|
||||
EXIT_CODE=0
|
||||
|
||||
if ! command -v shellcheck > /dev/null; then
|
||||
echo "Skipping shell linting since shellcheck is not installed."
|
||||
exit $EXIT_CODE
|
||||
fi
|
||||
|
||||
EXCLUDE="--exclude=$(IFS=','; echo "${disabled[*]}")"
|
||||
if ! shellcheck "$EXCLUDE" $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|univalue)/'); then
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
|
||||
if ! command -v yq > /dev/null; then
|
||||
echo "Skipping Gitian desriptor scripts checking since yq 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
|
||||
echo
|
||||
echo "$descriptor"
|
||||
# Use #!/bin/bash as gitian-builder/bin/gbuild does to complete a script.
|
||||
SCRIPT=$'#!/bin/bash\n'$(yq -r .script "$descriptor")
|
||||
if ! echo "$SCRIPT" | shellcheck "$EXCLUDE_GITIAN" -; then
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $EXIT_CODE
|
||||
|
Reference in New Issue
Block a user