diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 17e17712ff86..91320b8988ff 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -373,10 +373,6 @@ - ".dockerignore" - "qa/**/*" -.code-shell-patterns: &code-shell-patterns - - "bin/**/*" - - "tooling/**/*" - # .code-backstage-qa-patterns + .workhorse-patterns .setup-test-env-patterns: &setup-test-env-patterns - "{package.json,yarn.lock}" @@ -1779,13 +1775,6 @@ - changes: *code-backstage-qa-patterns - changes: *startup-css-patterns -############### -# Shell rules # -############### -.shell:rules: - rules: - - changes: *code-shell-patterns - ####################### # Test metadata rules # ####################### diff --git a/.gitlab/ci/static-analysis.gitlab-ci.yml b/.gitlab/ci/static-analysis.gitlab-ci.yml index 82c11cb8009c..8824d3d753f5 100644 --- a/.gitlab/ci/static-analysis.gitlab-ci.yml +++ b/.gitlab/ci/static-analysis.gitlab-ci.yml @@ -107,15 +107,3 @@ feature-flags-usage: when: always paths: - tmp/feature_flags/ - -shellcheck: - extends: - - .default-retry - - .shell:rules - stage: lint - needs: [] - image: - name: koalaman/shellcheck-alpine - entrypoint: [""] - script: - - tooling/bin/shellcheck diff --git a/bin/background_jobs b/bin/background_jobs index f301bb46ca90..d8929881f127 100755 --- a/bin/background_jobs +++ b/bin/background_jobs @@ -1,12 +1,12 @@ #!/usr/bin/env bash -cd "$(dirname "$0")/.." || exit - +cd $(dirname $0)/.. app_root=$(pwd) sidekiq_workers=${SIDEKIQ_WORKERS:-1} sidekiq_queues=${SIDEKIQ_QUEUES:-*} # Queues to listen to; default to `*` (all) sidekiq_pidfile="$app_root/tmp/pids/sidekiq-cluster.pid" sidekiq_logfile="$app_root/log/sidekiq.log" +gitlab_user=$(ls -l config.ru | awk '{print $3}') trap cleanup EXIT @@ -17,26 +17,26 @@ warn() get_sidekiq_pid() { - if [ ! -f "$sidekiq_pidfile" ]; then + if [ ! -f $sidekiq_pidfile ]; then warn "No pidfile found at $sidekiq_pidfile; is Sidekiq running?" return fi - cat "$sidekiq_pidfile" + cat $sidekiq_pidfile } stop() { sidekiq_pid=$(get_sidekiq_pid) - if [ "$sidekiq_pid" ]; then - kill -TERM "$sidekiq_pid" + if [ $sidekiq_pid ]; then + kill -TERM $sidekiq_pid fi } restart() { - if [ -f "$sidekiq_pidfile" ]; then + if [ -f $sidekiq_pidfile ]; then stop fi @@ -53,12 +53,12 @@ start_sidekiq() fi # sidekiq-cluster expects an argument per process. - for (( i=1; i<=sidekiq_workers; i++ )) + for (( i=1; i<=$sidekiq_workers; i++ )) do processes_args+=("${sidekiq_queues}") done - ${cmd} bin/sidekiq-cluster "${processes_args[@]}" -P "$sidekiq_pidfile" -e "$RAILS_ENV" "$@" 2>&1 | tee -a "$sidekiq_logfile" + ${cmd} bin/sidekiq-cluster "${processes_args[@]}" -P $sidekiq_pidfile -e $RAILS_ENV "$@" 2>&1 | tee -a $sidekiq_logfile } cleanup() diff --git a/bin/mail_room b/bin/mail_room index 3717e49e37ff..cf9d422909e0 100755 --- a/bin/mail_room +++ b/bin/mail_room @@ -1,6 +1,6 @@ #!/bin/sh -cd "$(dirname "$0")/.." || exit 1 +cd $(dirname $0)/.. || exit 1 app_root=$(pwd) mail_room_pidfile="$app_root/tmp/pids/mail_room.pid" @@ -9,7 +9,8 @@ mail_room_config="$app_root/config/mail_room.yml" get_mail_room_pid() { - pid=$(cat "$mail_room_pidfile") + local pid + pid=$(cat $mail_room_pidfile) if [ -z "$pid" ] ; then echo "Could not find a PID in $mail_room_pidfile" exit 1 @@ -19,13 +20,13 @@ get_mail_room_pid() start() { - bin/daemon_with_pidfile "$mail_room_pidfile" bundle exec mail_room --log-exit-as json -q -c "$mail_room_config" >> "$mail_room_logfile" 2>&1 + bin/daemon_with_pidfile $mail_room_pidfile bundle exec mail_room --log-exit-as json -q -c $mail_room_config >> $mail_room_logfile 2>&1 } stop() { get_mail_room_pid - kill -TERM "$mail_room_pid" + kill -TERM $mail_room_pid } restart() diff --git a/bin/parallel-rsync-repos b/bin/parallel-rsync-repos index bd8493717669..21921148fa09 100755 --- a/bin/parallel-rsync-repos +++ b/bin/parallel-rsync-repos @@ -32,20 +32,20 @@ if [ -z "$RSYNC" ] ; then RSYNC=rsync fi -if ! cd "$SRC" ; then +if ! cd $SRC ; then echo "cd $SRC failed" exit 1 fi rsyncjob() { - relative_dir="./${1#"$SRC"}" + relative_dir="./${1#$SRC}" if ! $RSYNC --delete --relative -a "$relative_dir" "$DEST" ; then echo "rsync $1 failed" return 1 fi - echo "$1" >> "$LOGFILE" + echo "$1" >> $LOGFILE } export LOGFILE SRC DEST RSYNC diff --git a/bin/web b/bin/web index 4d2a16f66659..c1ab4718f0da 100755 --- a/bin/web +++ b/bin/web @@ -2,7 +2,7 @@ set -e -cd "$(dirname "$0")/.." +cd $(dirname $0)/.. app_root=$(pwd) puma_pidfile="$app_root/tmp/pids/puma.pid" @@ -25,12 +25,12 @@ get_puma_pid() start() { - spawn_puma "$@" & + spawn_puma & } start_foreground() { - spawn_puma "$@" + spawn_puma } stop() @@ -46,10 +46,10 @@ reload() case "$1" in start) - start "$@" + start ;; start_foreground) - start_foreground "$@" + start_foreground ;; stop) stop diff --git a/bin/with_env b/bin/with_env index b0647a50e274..e678fa2f0cc2 100755 --- a/bin/with_env +++ b/bin/with_env @@ -10,7 +10,6 @@ shift # Use set -a to export all variables defined in env_file. set -a -# shellcheck disable=SC1090 . "${env_file}" set +a diff --git a/tooling/bin/shellcheck b/tooling/bin/shellcheck deleted file mode 100755 index b499bfa3e5e0..000000000000 --- a/tooling/bin/shellcheck +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -root="$(cd "$(dirname "$0")/../.." || exit ; pwd -P)" - -if [ $# -ne 0 ]; then - shellcheck --exclude=SC1071 --external-sources "$@" -else - find \ - "${root}/bin" \ - "${root}/tooling" \ - -type f \ - -not -path "*.swp" \ - -not -path "*.rb" \ - -not -path "*.js" \ - -not -path "*.md" \ - -not -path "*.haml" \ - -not -path "*/Gemfile*" \ - -not -path '*/.bundle*' \ - -not -path '*/Makefile*' \ - -print0 \ - | xargs -0 shellcheck --exclude=SC1071 --external-sources -- -fi