enable shell linter for more scripts (#3748)

This commit is contained in:
Nikita Korolev 2025-06-14 02:50:26 +03:00 committed by GitHub
parent 2b6bd5f9e8
commit 66c057b4e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 29 additions and 17 deletions

View File

@ -23,12 +23,16 @@ jobs:
- name: Run ShellCheck
run: |
git diff --name-only -z `git merge-base origin/master HEAD` -- \
'install/_lib.sh' \
install/_lib.sh \
'optional-modifications/**.sh' \
'scripts/**.sh' \
unit-test.sh \
'workstation/**.sh' \
| xargs -0 -r -- \
shellcheck \
--shell=bash \
--exclude=SC1090,SC1091 \
--format=json1 \
--external-sources \
| jq -r '
.comments
| map(.level |= if ([.] | inside(["info", "style"])) then "notice" else . end)

View File

@ -7,7 +7,7 @@ if [ -n "${DEBUG:-}" ]; then
fi
function confirm() {
read -p "$1 [y/n] " confirmation
read -r -p "$1 [y/n] " confirmation
if [ "$confirmation" != "y" ]; then
echo "Canceled. 😅"
exit
@ -26,8 +26,7 @@ function reset() {
# we're targeting a valid tag here. Do this early in order to fail fast.
if [ -n "$version" ]; then
set +e
git rev-parse --verify --quiet "refs/tags/$version" >/dev/null
if [ $? -gt 0 ]; then
if ! git rev-parse --verify --quiet "refs/tags/$version" >/dev/null; then
echo "Bad version: $version"
exit
fi
@ -43,12 +42,15 @@ function reset() {
echo "Okay ... good luck! 😰"
fi
# assert that commands are defined
: "${dc:?}" "${cmd:?}"
# Hit the reset button.
$dc down --volumes --remove-orphans --rmi local
# Remove any remaining (likely external) volumes with name matching 'sentry-.*'.
for volume in $(docker volume list --format '{{ .Name }}' | grep '^sentry-'); do
docker volume remove $volume >/dev/null &&
docker volume remove "$volume" >/dev/null &&
echo "Removed volume: $volume" ||
echo "Skipped volume: $volume"
done
@ -60,30 +62,34 @@ function reset() {
}
function backup() {
local type
type=${1:-"global"}
touch $(pwd)/sentry/backup.json
chmod 666 $(pwd)/sentry/backup.json
$dc run -v $(pwd)/sentry:/sentry-data/backup --rm -T -e SENTRY_LOG_LEVEL=CRITICAL web export $type /sentry-data/backup/backup.json
touch "${PWD}/sentry/backup.json"
chmod 666 "${PWD}/sentry/backup.json"
$dc run -v "${PWD}/sentry:/sentry-data/backup" --rm -T -e SENTRY_LOG_LEVEL=CRITICAL web export "$type" /sentry-data/backup/backup.json
}
function restore() {
type=${1:-"global"}
$dc run --rm -T web import $type /etc/sentry/backup.json
local type
type="${1:-global}"
$dc run --rm -T web import "$type" /etc/sentry/backup.json
}
# Needed variables to source error-handling script
MINIMIZE_DOWNTIME="${MINIMIZE_DOWNTIME:-}"
STOP_TIMEOUT=60
export STOP_TIMEOUT=60
# Save logs in order to send envelope to Sentry
log_file=sentry_"${cmd%% *}"_log-$(date +'%Y-%m-%d_%H-%M-%S').txt
log_file="sentry_${cmd%% *}_log-$(date +%Y-%m-%d_%H-%M-%S).txt"
exec &> >(tee -a "$log_file")
version=""
while (($#)); do
case "$1" in
--report-self-hosted-issues) REPORT_SELF_HOSTED_ISSUES=1 ;;
--no-report-self-hosted-issues) REPORT_SELF_HOSTED_ISSUES=0 ;;
--report-self-hosted-issues) export REPORT_SELF_HOSTED_ISSUES=1 ;;
--no-report-self-hosted-issues) export REPORT_SELF_HOSTED_ISSUES=0 ;;
*) version=$1 ;;
esac
shift

View File

@ -7,4 +7,5 @@ NEW_VERSION="$2"
sed -i -e "s/^\(SENTRY\|SNUBA\|RELAY\|SYMBOLICATOR\|TASKBROKER\|VROOM\)_IMAGE=\([^:]\+\):.\+\$/\1_IMAGE=\2:$NEW_VERSION/" .env
sed -i -e "s/^\# Self-Hosted Sentry .*/# Self-Hosted Sentry $NEW_VERSION/" README.md
[ -z "$OLD_VERSION" ] || echo "Previous version: $OLD_VERSION"
echo "New version: $NEW_VERSION"

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash
cmd="restore $1"
source scripts/_lib.sh
$cmd

View File

@ -5,7 +5,7 @@ export REPORT_SELF_HOSTED_ISSUES=0 # will be over-ridden in the relevant test
FORCE_CLEAN=1 "./scripts/reset.sh"
fail=0
for test_file in _unit-test/*-test.sh; do
if [ "$1" -a "$1" != "$test_file" ]; then
if [ -n "$1" ] && [ "$1" != "$test_file" ]; then
echo "🙊 Skipping $test_file ..."
continue
fi

View File

@ -1,5 +1,5 @@
#!/bin/bash
#
set -eo pipefail
# Create getsentry folder and enter.
mkdir /home/user/getsentry