Skip to content

Commit 91980ff

Browse files
authored
Merge pull request #17513 from MinaProtocol/dkijania/fix_all_shellcheck_warnings
Fixed lints for scripts and buildkite/scripts folder
2 parents 0eb4f90 + 03b5e12 commit 91980ff

File tree

16 files changed

+232
-190
lines changed

16 files changed

+232
-190
lines changed

buildkite/scripts/debian/install.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fi
88

99
if [ -z $MINA_DEB_CODENAME ]; then
1010
echo "MINA_DEB_CODENAME env var is not defined"
11-
exit -1
11+
exit 1
1212
fi
1313

1414
DEBS=$1
@@ -29,8 +29,9 @@ source ./buildkite/scripts/export-git-env-vars.sh
2929
# Download required debians from bucket locally
3030
if [ -z "$DEBS" ]; then
3131
echo "DEBS env var is empty. It should contains comma delimitered names of debians to install"
32-
exit -1
32+
exit 1
3333
else
34+
# shellcheck disable=SC2206
3435
debs=(${DEBS//,/ })
3536
for i in "${debs[@]}"; do
3637
case $i in

buildkite/scripts/release/manager.sh

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ mkdir -p $DEBIAN_CACHE_FOLDER
8383
################################################################################
8484
# imports
8585
################################################################################
86+
# shellcheck disable=SC1090
8687
. $SCRIPTPATH/../../../scripts/debian/reversion-helper.sh
8788

8889

@@ -188,7 +189,8 @@ function calculate_debian_version() {
188189
local __codename=$3
189190
local __network=$4
190191

191-
local __network_suffix=$(get_suffix $__artifact $__network)
192+
local __network_suffix
193+
__network_suffix=$(get_suffix $__artifact $__network)
192194
echo "$__artifact:$__target_version-$__codename$__network_suffix"
193195
}
194196

@@ -200,7 +202,8 @@ function calculate_docker_tag() {
200202
local __codename=$4
201203
local __network=$5
202204

203-
local __network_suffix=$(get_suffix $__artifact $__network)
205+
local __network_suffix
206+
__network_suffix=$(get_suffix $__artifact $__network)
204207

205208
if [[ $__publish_to_docker_io == 1 ]]; then
206209
echo "$DOCKER_IO_REPO/$__artifact:$__target_version-$__codename$__network_suffix"
@@ -323,17 +326,21 @@ function get_cached_debian_or_download() {
323326
local codename=$3
324327
local network=$4
325328

326-
local artifact_full_name=$(get_artifact_with_suffix "$artifact" "$network")
327-
local remote_path="$(storage_root "$backend")/$BUILDKITE_BUILD_ID/debians/$codename/${artifact_full_name}_*"
328-
329-
local check=$(storage_list "$backend" "$remote_path")
329+
local artifact_full_name
330+
artifact_full_name=$(get_artifact_with_suffix "$artifact" "$network")
331+
local remote_path
332+
remote_path="$(storage_root "$backend")/$BUILDKITE_BUILD_ID/debians/$codename/${artifact_full_name}_*"
333+
334+
local check
335+
check=$(storage_list "$backend" "$remote_path")
330336

331337
if [[ -z "$check" ]]; then
332338
echo -e "${RED} !! No debian package found using $artifact_full_name. Are you sure ($BUILDKITE_BUILD_ID) buildkite build is correct? Exiting.${CLEAR}\n"
333339
exit 1
334340
fi
335341

336-
local target_hash=$(storage_md5 "$backend" "$remote_path")
342+
local target_hash
343+
target_hash=$(storage_md5 "$backend" "$remote_path")
337344

338345
mkdir -p "$DEBIAN_CACHE_FOLDER/$codename"
339346

@@ -362,7 +369,8 @@ function publish_debian() {
362369
local __debian_sign_key=${11}
363370

364371
get_cached_debian_or_download $__backend $__artifact $__codename "$__network"
365-
local __artifact_full_name=$(get_artifact_with_suffix $__artifact $__network)
372+
local __artifact_full_name
373+
__artifact_full_name=$(get_artifact_with_suffix $__artifact $__network)
366374
local __deb=$DEBIAN_CACHE_FOLDER/$__codename/"${__artifact_full_name}"
367375

368376
if [[ $__debian_sign_key != "" ]]; then
@@ -422,8 +430,8 @@ function promote_and_verify_docker() {
422430
local __publish_to_docker_io=$6
423431
local __verify=$7
424432
local __dry_run=$8
425-
426-
local __network_suffix=$(get_suffix $__artifact $__network)
433+
local __network_suffix
434+
__network_suffix=$(get_suffix $__artifact $__network)
427435

428436
local __artifact_full_source_version=$__source_version-$__codename${__network_suffix}
429437
local __artifact_full_target_version=$__target_version-$__codename${__network_suffix}
@@ -489,23 +497,22 @@ function promote_debian() {
489497

490498
echo " 🍥 Promoting $__artifact debian from $__source_channel to $__target_channel, from $__source_version to $__target_version"
491499
echo " 📦 Target debian version: $(calculate_debian_version $__artifact $__target_version $__codename "$__network")"
500+
501+
local __artifact_full_name
502+
__artifact_full_name=$(get_artifact_with_suffix $__artifact $__network)
492503

493-
local __artifact_full_name=$(get_artifact_with_suffix $__artifact $__network)
494504
local __deb=$DEBIAN_CACHE_FOLDER/$__codename/"${__artifact_full_name}"
495505

496506
if [[ $__dry_run == 0 ]]; then
497507
echo " 🗃️ Promoting $__artifact debian from $__codename/$__source_version to $__codename/$__target_version"
498508
prefix_cmd "$SUBCOMMAND_TAB" $SCRIPTPATH/../../../scripts/debian/reversion.sh \
499509
--deb ${__artifact_full_name} \
500510
--version ${__source_version} \
501-
--release ${__source_channel} \
502511
--new-version ${__target_version} \
503512
--suite ${__source_channel} \
504513
--repo ${__debian_repo} \
505514
--new-suite ${__target_channel} \
506-
--new-name ${__artifact_full_name} \
507-
--new-release ${__target_channel} \
508-
--codename ${__codename}
515+
--new-name ${__artifact_full_name}
509516

510517
if [[ $__verify == 1 ]]; then
511518
echo " 📋 Verifying: $__artifact debian to $__target_channel channel with $__target_version version"
@@ -1237,8 +1244,9 @@ function verify(){
12371244
read -r -a __artifacts_arr <<< "$__artifacts"
12381245
read -r -a __networks_arr <<< "$__networks"
12391246
read -r -a __codenames_arr <<< "$__codenames"
1240-
1241-
local __repo=$(get_repo $__docker_io)
1247+
1248+
local __repo
1249+
__repo=$(get_repo $__docker_io)
12421250

12431251
for artifact in "${__artifacts_arr[@]}"; do
12441252
for __codename in "${__codenames_arr[@]}"; do
@@ -1279,7 +1287,8 @@ function verify(){
12791287
fi
12801288

12811289
if [[ $__only_debians == 0 ]]; then
1282-
local __artifact_full_name=$(get_artifact_with_suffix $artifact "")
1290+
local __artifact_full_name
1291+
__artifact_full_name=$(get_artifact_with_suffix $artifact "")
12831292

12841293
local __suffix_arg=""
12851294
if [[ -n "$__docker_suffix" ]]; then
@@ -1300,12 +1309,14 @@ function verify(){
13001309
;;
13011310
mina-rosetta)
13021311
for network in "${__networks_arr[@]}"; do
1303-
local __artifact_full_name=$(get_artifact_with_suffix $artifact $network)
1312+
local __artifact_full_name
1313+
__artifact_full_name=$(get_artifact_with_suffix $artifact $network)
13041314

1305-
local __docker_suffix_combined=$(combine_docker_suffixes "$network" "$__docker_suffix")
1315+
local __docker_suffix_combined
1316+
__docker_suffix_combined=$(combine_docker_suffixes "$network" "$__docker_suffix")
13061317

1318+
if [[ $__only_dockers == 0 ]]; then
13071319

1308-
if [[ $__only_dockers == 0 ]]; then
13091320
echo " 📋 Verifying: $__artifact_full_name debian on $__channel channel with $__version version for $__codename codename"
13101321
echo ""
13111322

@@ -1338,10 +1349,14 @@ function verify(){
13381349
;;
13391350
mina-daemon)
13401351
for network in "${__networks_arr[@]}"; do
1341-
local __artifact_full_name=$(get_artifact_with_suffix $artifact $network)
1342-
local __docker_suffix_combined=$(combine_docker_suffixes "$network" "$__docker_suffix")
1352+
local __artifact_full_name
1353+
__artifact_full_name=$(get_artifact_with_suffix $artifact $network)
13431354

1344-
if [[ $__only_dockers == 0 ]]; then
1355+
local __docker_suffix_combined
1356+
__docker_suffix_combined=$(combine_docker_suffixes "$network" "$__docker_suffix")
1357+
1358+
1359+
if [[ $__only_dockers == 0 ]]; then
13451360
echo " 📋 Verifying: $__artifact_full_name debian on $__channel channel with $__version version for $__codename codename"
13461361
echo ""
13471362
prefix_cmd "$SUBCOMMAND_TAB" $SCRIPTPATH/../../../scripts/debian/verify.sh \

buildkite/scripts/tests/archive-node-unit-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if [[ -z "$user" || -z "$password" || -z "$db" || -z "$command_key" ]]; then
1717
exit 1
1818
fi
1919

20-
eval $(opam config env)
20+
eval "$(opam config env)"
2121

2222
echo "Setting up database for archive node tests..."
2323

buildkite/src/Jobs/Lint/Bash.dhall

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
let B = ../../External/Buildkite.dhall
2-
31
let S = ../../Lib/SelectFiles.dhall
42

53
let Pipeline = ../../Pipeline/Dsl.dhall
@@ -16,8 +14,6 @@ let Size = ../../Command/Size.dhall
1614

1715
let RunInToolchain = ../../Command/RunInToolchain.dhall
1816

19-
let B/SoftFail = B.definitions/commandStep/properties/soft_fail/Type
20-
2117
in Pipeline.build
2218
Pipeline.Config::{
2319
, spec = JobSpec::{
@@ -47,7 +43,6 @@ in Pipeline.build
4743
, label = "Bash: shellcheck"
4844
, key = "check-bash"
4945
, target = Size.Multi
50-
, soft_fail = Some (B/SoftFail.Boolean True)
5146
, docker = None Docker.Type
5247
}
5348
]

scripts/archive/missing-blocks-guardian.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ download_block() {
133133
fi
134134
}
135135

136-
HASH='map(select(.metadata.parent_hash != null and .metadata.parent_height != null)) | .[0].metadata.parent_hash'
137136
# Bootstrap finds every missing state hash in the database and imports them from a bucket of precomputed .json blocks
138137
bootstrap() {
139138
echo "[BOOTSTRAP] Top 10 blocks before bootstrapping the archiveDB:"

scripts/debian/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if [[ -n "$BRANCH_NAME" ]]; then
1212
# shellcheck disable=SC1090
1313
BRANCH_NAME="$BRANCH_NAME" source "${SCRIPTPATH}/../export-git-env-vars.sh"
1414
else
15+
# shellcheck disable=SC1090
1516
source "${SCRIPTPATH}"/../export-git-env-vars.sh
1617
fi
1718

scripts/debian/publish.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ do
127127

128128
counter=$((counter+1))
129129
if [[ $((counter)) == $((tries)) ]]; then
130+
# shellcheck disable=SC2046
130131
echo "❌ Error: Some Debians are still not correctly published : "$(join_by " " "${debs[@]}")
131132
echo "ℹ️ You may still try to rerun job as debian repository is known from imperfect performance"
132133
exit 1

scripts/debian/reversion-helper.sh

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ function reversion() {
1010
local __suite
1111
local __new_suite
1212
local __new_name
13-
local __new_release
14-
local __codename
1513

1614
while [[ "$#" -gt 0 ]]; do
1715
case "${1}" in
@@ -43,14 +41,6 @@ function reversion() {
4341
__new_name=${2}
4442
shift
4543
;;
46-
--new-release)
47-
__new_release=${2}
48-
shift
49-
;;
50-
--codename)
51-
__codename=${2}
52-
shift
53-
;;
5444
*)
5545
echo "$0 Unknown parameter in reversion() : ${1}" >&2
5646
exit 1
@@ -63,15 +53,21 @@ function reversion() {
6353
done
6454

6555
local __new_deb="${__new_name}_${__new_version}"
66-
local __parent_dir=$(dirname "${__deb}_${__source_version}.deb")
67-
56+
local __parent_dir
57+
__parent_dir=$(dirname "${__deb}_${__source_version}.deb")
58+
6859
rm -rf "${__new_deb}"
60+
# shellcheck disable=SC2140
6961
rm -rf "${__parent_dir}"/"${__new_deb}.deb"
7062

7163
dpkg-deb -R "${__deb}_${__source_version}.deb" "${__new_deb}"
64+
# shellcheck disable=SC2140
7265
sed -i 's/Version: '"${__source_version}"'/Version: '"${__new_version}"'/g' "${__new_deb}/DEBIAN/control"
66+
# shellcheck disable=SC2140
7367
sed -i 's/Package: '"${__package}"'/Package: '"${__new_name}"'/g' "${__new_deb}/DEBIAN/control"
68+
# shellcheck disable=SC2140
7469
sed -i 's/Suite: '"${__suite}"'/Suite: '"${__new_suite}"'/g' "${__new_deb}/DEBIAN/control"
70+
# shellcheck disable=SC2140
7571
dpkg-deb --build "${__new_name}_${__new_version}" "${__parent_dir}"/"${__new_deb}.deb"
7672

7773
rm -rf "${__new_deb}"

scripts/debian/reversion.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ function usage() {
1010
fi
1111
echo "Usage: $0 [-d deb-name] [-v new-version] "
1212
echo " -d, --deb The Debian name"
13-
echo " -c, --codename The Debian codename"
14-
echo " --release The Current Debian release"
15-
echo " --new-release The New Debian release"
1613
echo " --version The Current Debian version"
1714
echo " --new-version The New Debian version"
1815
echo " --suite The Current Debian suite"
@@ -26,14 +23,11 @@ function usage() {
2623

2724
while [[ "$#" -gt 0 ]]; do case $1 in
2825
-d|--deb) DEB="$2"; shift;;
29-
-c|--codename) CODENAME="$2"; shift;;
3026
--new-name) NEW_NAME="$2"; shift;;
31-
--new-release) NEW_RELEASE="$2"; shift;;
3227
--new-version) NEW_VERSION="$2"; shift;;
3328
--new-suite) NEW_SUITE="$2"; shift;;
3429
--new-repo) NEW_REPO="$2"; shift;;
3530
--suite) SUITE="$2"; shift;;
36-
--release) RELEASE="$2"; shift;;
3731
--version) VERSION="$2"; shift;;
3832
--repo) REPO="$2"; shift;;
3933
--sign) SIGN="$2"; shift;;

scripts/docker/build.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ fi
1212
CLEAR='\033[0m'
1313
RED='\033[0;31m'
1414

15-
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
16-
source ${SCRIPTPATH}/helper.sh
15+
SCRIPTPATH="$( cd "$(dirname "$0")" || exit ; pwd -P )"
16+
# shellcheck disable=SC1090
17+
source "${SCRIPTPATH}"/helper.sh
1718

1819
function usage() {
1920
if [[ -n "$1" ]]; then
@@ -51,7 +52,9 @@ while [[ "$#" -gt 0 ]]; do case $1 in
5152
--deb-profile) DEB_PROFILE="$2"; shift;;
5253
--deb-repo) INPUT_REPO="$2"; shift;;
5354
--deb-build-flags) DEB_BUILD_FLAGS="$2"; shift;;
54-
--deb-repo-key) DEB_REPO_KEY="$2"; shift;;
55+
--deb-repo-key)
56+
# shellcheck disable=SC2034
57+
DEB_REPO_KEY="$2"; shift;;
5558
*) echo "Unknown parameter passed: $1"; exit 1;;
5659
esac; shift; done
5760

@@ -121,7 +124,7 @@ if [[ -z "$INPUT_REPO" ]]; then
121124
DEB_REPO="--build-arg deb_repo=http://localhost:8080"
122125
fi
123126

124-
if [[ $(echo ${VALID_SERVICES[@]} | grep -o "$SERVICE" - | wc -w) -eq 0 ]]; then usage "Invalid service!"; fi
127+
if [[ $(echo "${VALID_SERVICES[@]}" | grep -o "$SERVICE" - | wc -w) -eq 0 ]]; then usage "Invalid service!"; fi
125128

126129
export_base_image
127130

0 commit comments

Comments
 (0)