mirror of
https://github.com/getsentry/self-hosted.git
synced 2026-02-06 10:57:17 +00:00
EditorConfig and indentation fixes (#650)
EditorConfig based on conversation in https://github.com/getsentry/onpremise/pull/615#discussion_r477338006, and with the indentation fixes. This PR will probably conflict with everything, but at least the code is a little bit more consistent :-D
This commit is contained in:
parent
61bc028a17
commit
1a9b45fb9f
16
.editorconfig
Normal file
16
.editorconfig
Normal file
@ -0,0 +1,16 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
|
||||
[*.sh]
|
||||
indent_size = 2
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
|
||||
[nginx/*.conf]
|
||||
indent_style = tab
|
||||
76
.github/workflows/release.yml
vendored
76
.github/workflows/release.yml
vendored
@ -27,41 +27,41 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: "Release a new version"
|
||||
steps:
|
||||
- id: killswitch
|
||||
if: ${{ !github.event.inputs.force }}
|
||||
run: |
|
||||
if curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY/issues?state=open&labels=release-blocker" | grep -Pzvo '\[[\s\n\r]*\]'; then
|
||||
echo "Open release-blocking issues found, cancelling release...";
|
||||
curl -sf -X POST -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/$GITHUB_REPOSITORY/actions/runs/${{ github.run_id }}/cancel;
|
||||
fi
|
||||
- id: calver
|
||||
if: ${{ !github.event.inputs.version }}
|
||||
run: |
|
||||
DATE_PART=$(date +'%y.%-m')
|
||||
declare -i PATCH_VERSION=0
|
||||
while curl -sf -o /dev/null "https://api.github.com/repos/$GITHUB_REPOSITORY/git/ref/tags/$DATE_PART.$PATCH_VERSION"; do
|
||||
PATCH_VERSION+=1
|
||||
done
|
||||
echo "::set-output name=version::$DATE_PART.$PATCH_VERSION"
|
||||
- uses: actions/checkout@v2
|
||||
- uses: getsentry/craft@master
|
||||
if: ${{ !github.event.inputs.skip_prepare }}
|
||||
with:
|
||||
action: prepare
|
||||
version: ${{ github.event.inputs.version || steps.calver.outputs.version }}
|
||||
env:
|
||||
DRY_RUN: ${{ github.event.inputs.dry_run }}
|
||||
GIT_COMMITTER_NAME: getsentry-bot
|
||||
GIT_AUTHOR_NAME: getsentry-bot
|
||||
EMAIL: bot@getsentry.com
|
||||
- uses: getsentry/craft@master
|
||||
with:
|
||||
action: publish
|
||||
version: ${{ github.event.inputs.version || steps.calver.outputs.version }}
|
||||
keep_branch: '--keep-branch'
|
||||
no_merge: '--no-merge'
|
||||
env:
|
||||
DRY_RUN: ${{ github.event.inputs.dry_run }}
|
||||
GIT_COMMITTER_NAME: getsentry-bot
|
||||
GIT_AUTHOR_NAME: getsentry-bot
|
||||
EMAIL: bot@getsentry.com
|
||||
- id: killswitch
|
||||
if: ${{ !github.event.inputs.force }}
|
||||
run: |
|
||||
if curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY/issues?state=open&labels=release-blocker" | grep -Pzvo '\[[\s\n\r]*\]'; then
|
||||
echo "Open release-blocking issues found, cancelling release...";
|
||||
curl -sf -X POST -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/$GITHUB_REPOSITORY/actions/runs/${{ github.run_id }}/cancel;
|
||||
fi
|
||||
- id: calver
|
||||
if: ${{ !github.event.inputs.version }}
|
||||
run: |
|
||||
DATE_PART=$(date +'%y.%-m')
|
||||
declare -i PATCH_VERSION=0
|
||||
while curl -sf -o /dev/null "https://api.github.com/repos/$GITHUB_REPOSITORY/git/ref/tags/$DATE_PART.$PATCH_VERSION"; do
|
||||
PATCH_VERSION+=1
|
||||
done
|
||||
echo "::set-output name=version::$DATE_PART.$PATCH_VERSION"
|
||||
- uses: actions/checkout@v2
|
||||
- uses: getsentry/craft@master
|
||||
if: ${{ !github.event.inputs.skip_prepare }}
|
||||
with:
|
||||
action: prepare
|
||||
version: ${{ github.event.inputs.version || steps.calver.outputs.version }}
|
||||
env:
|
||||
DRY_RUN: ${{ github.event.inputs.dry_run }}
|
||||
GIT_COMMITTER_NAME: getsentry-bot
|
||||
GIT_AUTHOR_NAME: getsentry-bot
|
||||
EMAIL: bot@getsentry.com
|
||||
- uses: getsentry/craft@master
|
||||
with:
|
||||
action: publish
|
||||
version: ${{ github.event.inputs.version || steps.calver.outputs.version }}
|
||||
keep_branch: '--keep-branch'
|
||||
no_merge: '--no-merge'
|
||||
env:
|
||||
DRY_RUN: ${{ github.event.inputs.dry_run }}
|
||||
GIT_COMMITTER_NAME: getsentry-bot
|
||||
GIT_AUTHOR_NAME: getsentry-bot
|
||||
EMAIL: bot@getsentry.com
|
||||
|
||||
@ -9,7 +9,7 @@ declare -p | grep -Ev 'BASHOPTS|BASH_VERSINFO|EUID|PPID|SHELLOPTS|UID' > /contai
|
||||
{ for cron_job in "$@"; do echo -e "SHELL=/bin/bash
|
||||
BASH_ENV=/container.env
|
||||
${cron_job} > /proc/1/fd/1 2>/proc/1/fd/2"; done } \
|
||||
| sed --regexp-extended 's/\\(.)/\1/g' \
|
||||
| crontab -
|
||||
| sed --regexp-extended 's/\\(.)/\1/g' \
|
||||
| crontab -
|
||||
crontab -l
|
||||
exec cron -f -l -L 15
|
||||
|
||||
74
install.sh
74
install.sh
@ -26,11 +26,11 @@ MINIMIZE_DOWNTIME=
|
||||
load_options() {
|
||||
while [[ -n "$@" ]]; do
|
||||
case "$1" in
|
||||
-h | --help) show_help; exit;;
|
||||
--no-user-prompt) SKIP_USER_PROMPT=1;;
|
||||
--minimize-downtime) MINIMIZE_DOWNTIME=1;;
|
||||
--) ;;
|
||||
*) echo "Unexpected argument: $1. Use --help for usage information."; exit 1;;
|
||||
-h | --help) show_help; exit;;
|
||||
--no-user-prompt) SKIP_USER_PROMPT=1;;
|
||||
--minimize-downtime) MINIMIZE_DOWNTIME=1;;
|
||||
--) ;;
|
||||
*) echo "Unexpected argument: $1. Use --help for usage information."; exit 1;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
@ -57,7 +57,7 @@ load_options $(getopt -n "$0" -o 'h' -l 'help,minimize-downtime' -- "$@")
|
||||
trap_with_arg() {
|
||||
func="$1" ; shift
|
||||
for sig ; do
|
||||
trap "$func $sig "'$LINENO' "$sig"
|
||||
trap "$func $sig "'$LINENO' "$sig"
|
||||
done
|
||||
}
|
||||
|
||||
@ -106,18 +106,18 @@ function ensure_file_from_example {
|
||||
}
|
||||
|
||||
if [ $(ver $DOCKER_VERSION) -lt $(ver $MIN_DOCKER_VERSION) ]; then
|
||||
echo "FAIL: Expected minimum Docker version to be $MIN_DOCKER_VERSION but found $DOCKER_VERSION"
|
||||
exit 1
|
||||
echo "FAIL: Expected minimum Docker version to be $MIN_DOCKER_VERSION but found $DOCKER_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $(ver $COMPOSE_VERSION) -lt $(ver $MIN_COMPOSE_VERSION) ]; then
|
||||
echo "FAIL: Expected minimum docker-compose version to be $MIN_COMPOSE_VERSION but found $COMPOSE_VERSION"
|
||||
exit 1
|
||||
echo "FAIL: Expected minimum docker-compose version to be $MIN_COMPOSE_VERSION but found $COMPOSE_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$RAM_AVAILABLE_IN_DOCKER" -lt "$MIN_RAM" ]; then
|
||||
echo "FAIL: Expected minimum RAM available to Docker to be $MIN_RAM MB but found $RAM_AVAILABLE_IN_DOCKER MB"
|
||||
exit 1
|
||||
echo "FAIL: Expected minimum RAM available to Docker to be $MIN_RAM MB but found $RAM_AVAILABLE_IN_DOCKER MB"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#SSE4.2 required by Clickhouse (https://clickhouse.yandex/docs/en/operations/requirements/)
|
||||
@ -149,14 +149,14 @@ ensure_file_from_example $SYMBOLICATOR_CONFIG_YML
|
||||
ensure_file_from_example $RELAY_CONFIG_YML
|
||||
|
||||
if grep -xq "system.secret-key: '!!changeme!!'" $SENTRY_CONFIG_YML ; then
|
||||
echo ""
|
||||
echo "Generating secret key..."
|
||||
# This is to escape the secret key to be used in sed below
|
||||
# Note the need to set LC_ALL=C due to BSD tr and sed always trying to decode
|
||||
# whatever is passed to them. Kudos to https://stackoverflow.com/a/23584470/90297
|
||||
SECRET_KEY=$(export LC_ALL=C; head /dev/urandom | tr -dc "a-z0-9@#%^&*(-_=+)" | head -c 50 | sed -e 's/[\/&]/\\&/g')
|
||||
sed -i -e 's/^system.secret-key:.*$/system.secret-key: '"'$SECRET_KEY'"'/' $SENTRY_CONFIG_YML
|
||||
echo "Secret key written to $SENTRY_CONFIG_YML"
|
||||
echo ""
|
||||
echo "Generating secret key..."
|
||||
# This is to escape the secret key to be used in sed below
|
||||
# Note the need to set LC_ALL=C due to BSD tr and sed always trying to decode
|
||||
# whatever is passed to them. Kudos to https://stackoverflow.com/a/23584470/90297
|
||||
SECRET_KEY=$(export LC_ALL=C; head /dev/urandom | tr -dc "a-z0-9@#%^&*(-_=+)" | head -c 50 | sed -e 's/[\/&]/\\&/g')
|
||||
sed -i -e 's/^system.secret-key:.*$/system.secret-key: '"'$SECRET_KEY'"'/' $SENTRY_CONFIG_YML
|
||||
echo "Secret key written to $SENTRY_CONFIG_YML"
|
||||
fi
|
||||
|
||||
replace_tsdb() {
|
||||
@ -253,7 +253,7 @@ CLICKHOUSE_CLIENT_MAX_RETRY=5
|
||||
until clickhouse_query 'SELECT 1' > /dev/null; do
|
||||
((CLICKHOUSE_CLIENT_MAX_RETRY--))
|
||||
[[ CLICKHOUSE_CLIENT_MAX_RETRY -eq 0 ]] && echo "Clickhouse server failed to come up in 5 tries." && exit 1;
|
||||
echo "Trying again. Remaining tries #$CLICKHOUSE_CLIENT_MAX_RETRY"
|
||||
echo "Trying again. Remaining tries #$CLICKHOUSE_CLIENT_MAX_RETRY"
|
||||
sleep 0.5;
|
||||
done
|
||||
set -e
|
||||
@ -279,23 +279,23 @@ echo ""
|
||||
|
||||
# Very naively check whether there's an existing sentry-postgres volume and the PG version in it
|
||||
if [[ $(docker volume ls -q --filter name=sentry-postgres) && $(docker run --rm -v sentry-postgres:/db busybox cat /db/PG_VERSION 2>/dev/null) == "9.5" ]]; then
|
||||
docker volume rm sentry-postgres-new || true
|
||||
# If this is Postgres 9.5 data, start upgrading it to 9.6 in a new volume
|
||||
docker run --rm \
|
||||
-v sentry-postgres:/var/lib/postgresql/9.5/data \
|
||||
-v sentry-postgres-new:/var/lib/postgresql/9.6/data \
|
||||
tianon/postgres-upgrade:9.5-to-9.6
|
||||
docker volume rm sentry-postgres-new || true
|
||||
# If this is Postgres 9.5 data, start upgrading it to 9.6 in a new volume
|
||||
docker run --rm \
|
||||
-v sentry-postgres:/var/lib/postgresql/9.5/data \
|
||||
-v sentry-postgres-new:/var/lib/postgresql/9.6/data \
|
||||
tianon/postgres-upgrade:9.5-to-9.6
|
||||
|
||||
# Get rid of the old volume as we'll rename the new one to that
|
||||
docker volume rm sentry-postgres
|
||||
docker volume create --name sentry-postgres
|
||||
# There's no rename volume in Docker so copy the contents from old to new name
|
||||
# Also append the `host all all all trust` line as `tianon/postgres-upgrade:9.5-to-9.6`
|
||||
# doesn't do that automatically.
|
||||
docker run --rm -v sentry-postgres-new:/from -v sentry-postgres:/to alpine ash -c \
|
||||
"cd /from ; cp -av . /to ; echo 'host all all all trust' >> /to/pg_hba.conf"
|
||||
# Finally, remove the new old volume as we are all in sentry-postgres now
|
||||
docker volume rm sentry-postgres-new
|
||||
# Get rid of the old volume as we'll rename the new one to that
|
||||
docker volume rm sentry-postgres
|
||||
docker volume create --name sentry-postgres
|
||||
# There's no rename volume in Docker so copy the contents from old to new name
|
||||
# Also append the `host all all all trust` line as `tianon/postgres-upgrade:9.5-to-9.6`
|
||||
# doesn't do that automatically.
|
||||
docker run --rm -v sentry-postgres-new:/from -v sentry-postgres:/to alpine ash -c \
|
||||
"cd /from ; cp -av . /to ; echo 'host all all all trust' >> /to/pg_hba.conf"
|
||||
# Finally, remove the new old volume as we are all in sentry-postgres now
|
||||
docker volume rm sentry-postgres-new
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
@ -3,7 +3,7 @@ relay:
|
||||
host: 0.0.0.0
|
||||
port: 3000
|
||||
logging:
|
||||
level: WARN
|
||||
level: WARN
|
||||
processing:
|
||||
enabled: true
|
||||
kafka_config:
|
||||
|
||||
58
test.sh
58
test.sh
@ -8,10 +8,10 @@ COOKIE_FILE=$(mktemp)
|
||||
|
||||
# Courtesy of https://stackoverflow.com/a/2183063/90297
|
||||
trap_with_arg() {
|
||||
func="$1" ; shift
|
||||
for sig ; do
|
||||
trap "$func $sig "'$LINENO' "$sig"
|
||||
done
|
||||
func="$1" ; shift
|
||||
for sig ; do
|
||||
trap "$func $sig "'$LINENO' "$sig"
|
||||
done
|
||||
}
|
||||
|
||||
DID_CLEAN_UP=0
|
||||
@ -42,33 +42,33 @@ get_csrf_token () { awk '$6 == "sc" { print $7 }' $COOKIE_FILE; }
|
||||
sentry_api_request () { curl -s -H 'Accept: application/json; charset=utf-8' -H "Referer: $SENTRY_TEST_HOST" -H 'Content-Type: application/json' -H "X-CSRFToken: $(get_csrf_token)" -b "$COOKIE_FILE" -c "$COOKIE_FILE" "$SENTRY_TEST_HOST/api/0/$1" ${@:2}; }
|
||||
|
||||
login () {
|
||||
INITIAL_AUTH_REDIRECT=$(curl -sL -o /dev/null $SENTRY_TEST_HOST -w %{url_effective})
|
||||
if [ "$INITIAL_AUTH_REDIRECT" != "$SENTRY_TEST_HOST/auth/login/sentry/" ]; then
|
||||
echo "Initial /auth/login/ redirect failed, exiting..."
|
||||
echo "$INITIAL_AUTH_REDIRECT"
|
||||
exit -1
|
||||
fi
|
||||
INITIAL_AUTH_REDIRECT=$(curl -sL -o /dev/null $SENTRY_TEST_HOST -w %{url_effective})
|
||||
if [ "$INITIAL_AUTH_REDIRECT" != "$SENTRY_TEST_HOST/auth/login/sentry/" ]; then
|
||||
echo "Initial /auth/login/ redirect failed, exiting..."
|
||||
echo "$INITIAL_AUTH_REDIRECT"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
CSRF_TOKEN_FOR_LOGIN=$(curl $SENTRY_TEST_HOST -sL -c "$COOKIE_FILE" | awk -F "'" '
|
||||
/csrfmiddlewaretoken/ {
|
||||
print $4 "=" $6;
|
||||
exit;
|
||||
}')
|
||||
CSRF_TOKEN_FOR_LOGIN=$(curl $SENTRY_TEST_HOST -sL -c "$COOKIE_FILE" | awk -F "'" '
|
||||
/csrfmiddlewaretoken/ {
|
||||
print $4 "=" $6;
|
||||
exit;
|
||||
}')
|
||||
|
||||
curl -sL --data-urlencode 'op=login' --data-urlencode "username=$TEST_USER" --data-urlencode "password=$TEST_PASS" --data-urlencode "$CSRF_TOKEN_FOR_LOGIN" "$SENTRY_TEST_HOST/auth/login/sentry/" -H "Referer: $SENTRY_TEST_HOST/auth/login/sentry/" -b "$COOKIE_FILE" -c "$COOKIE_FILE";
|
||||
curl -sL --data-urlencode 'op=login' --data-urlencode "username=$TEST_USER" --data-urlencode "password=$TEST_PASS" --data-urlencode "$CSRF_TOKEN_FOR_LOGIN" "$SENTRY_TEST_HOST/auth/login/sentry/" -H "Referer: $SENTRY_TEST_HOST/auth/login/sentry/" -b "$COOKIE_FILE" -c "$COOKIE_FILE";
|
||||
}
|
||||
|
||||
LOGIN_RESPONSE=$(login);
|
||||
declare -a LOGIN_TEST_STRINGS=(
|
||||
'"isAuthenticated":true'
|
||||
'"username":"test@example.com"'
|
||||
'"isSuperuser":true'
|
||||
'"isAuthenticated":true'
|
||||
'"username":"test@example.com"'
|
||||
'"isSuperuser":true'
|
||||
)
|
||||
for i in "${LOGIN_TEST_STRINGS[@]}"
|
||||
do
|
||||
echo "Testing '$i'..."
|
||||
echo "$LOGIN_RESPONSE" | grep "$i[,}]" >& /dev/null
|
||||
echo "Pass."
|
||||
echo "Testing '$i'..."
|
||||
echo "$LOGIN_RESPONSE" | grep "$i[,}]" >& /dev/null
|
||||
echo "Pass."
|
||||
done
|
||||
|
||||
# Set up initial/required settings (InstallWizard request)
|
||||
@ -94,14 +94,14 @@ echo "";
|
||||
|
||||
EVENT_RESPONSE=$(sentry_api_request "$EVENT_PATH")
|
||||
declare -a EVENT_TEST_STRINGS=(
|
||||
'"eventID":"'"$TEST_EVENT_ID"'"'
|
||||
'"message":"a failure"'
|
||||
'"title":"a failure"'
|
||||
'"object":"42"'
|
||||
'"eventID":"'"$TEST_EVENT_ID"'"'
|
||||
'"message":"a failure"'
|
||||
'"title":"a failure"'
|
||||
'"object":"42"'
|
||||
)
|
||||
for i in "${EVENT_TEST_STRINGS[@]}"
|
||||
do
|
||||
echo "Testing '$i'..."
|
||||
echo "$EVENT_RESPONSE" | grep "$i[,}]" >& /dev/null
|
||||
echo "Pass."
|
||||
echo "Testing '$i'..."
|
||||
echo "$EVENT_RESPONSE" | grep "$i[,}]" >& /dev/null
|
||||
echo "Pass."
|
||||
done
|
||||
|
||||
Loading…
Reference in New Issue
Block a user