mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 08:33:43 +00:00
kandra: Add a hook to notify of local schema drift from merge-base.
This commit is contained in:
committed by
Tim Abbott
parent
3ead4c06f0
commit
ce34ebdfed
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
source "$(dirname "$0")/../common/zulip_notify.sh"
|
||||
|
||||
if ! ref=$(crudini --get /etc/zulip/zulip.conf push_git_ref ref); then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
diffstat=$(git diff --stat "$ZULIP_NEW_MERGE_BASE_COMMIT" ./*/migrations/)
|
||||
|
||||
if [ -z "$diffstat" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "zulip_notify_schema_diff: Found schema differences from merge-base!"
|
||||
|
||||
zulip_send "${deploy_environment} deploy on $(hostname) found differences in schema from merge-base:
|
||||
|
||||
\`\`\`
|
||||
${diffstat}
|
||||
\`\`\`
|
||||
|
||||
Please manually adjust the \`${ref}\` ref.
|
||||
"
|
||||
14
puppet/kandra/manifests/hooks/file.pp
Normal file
14
puppet/kandra/manifests/hooks/file.pp
Normal file
@@ -0,0 +1,14 @@
|
||||
# @summary Install a static hook file
|
||||
#
|
||||
define kandra::hooks::file() {
|
||||
include zulip::hooks::base
|
||||
|
||||
file { "/etc/zulip/hooks/${title}":
|
||||
ensure => file,
|
||||
mode => '0755',
|
||||
owner => 'zulip',
|
||||
group => 'zulip',
|
||||
source => "puppet:///modules/kandra/hooks/${title}",
|
||||
tag => ['hooks'],
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# @summary Install hook that checks for schema drift from published ref
|
||||
#
|
||||
class kandra::hooks::zulip_notify_schema_diff {
|
||||
include zulip::hooks::base
|
||||
include zulip::hooks::zulip_common
|
||||
|
||||
kandra::hooks::file { 'post-deploy.d/zulip_notify_schema_diff.hook': }
|
||||
}
|
||||
@@ -2,6 +2,7 @@ class kandra::prod_app_frontend_once {
|
||||
include zulip::app_frontend_once
|
||||
include zulip::hooks::push_git_ref
|
||||
include zulip::hooks::zulip_notify
|
||||
include kandra::hooks::zulip_notify_schema_diff
|
||||
|
||||
zulip::cron { 'update-first-visible-message-id':
|
||||
hour => '7',
|
||||
|
||||
@@ -26,10 +26,9 @@ fi
|
||||
from=${ZULIP_OLD_MERGE_BASE_COMMIT:-$ZULIP_OLD_VERSION}
|
||||
to=${ZULIP_NEW_MERGE_BASE_COMMIT:-$ZULIP_NEW_VERSION}
|
||||
deploy_environment=$(crudini --get /etc/zulip/zulip.conf machine deploy_type || echo "development")
|
||||
# shellcheck disable=SC2034
|
||||
commit_count=$(git rev-list "${from}..${to}" | wc -l)
|
||||
|
||||
echo "zulip_notify: Sending notify of $from .. $to ($commit_count commits) for $deploy_environment to $zulip_notify_server"
|
||||
|
||||
zulip_send() {
|
||||
./zulip-py3-venv/bin/zulip-send \
|
||||
--site "$zulip_notify_server" \
|
||||
|
||||
@@ -5,4 +5,6 @@ set -u
|
||||
|
||||
source "$(dirname "$0")/../common/zulip_notify.sh"
|
||||
|
||||
echo "zulip_notify: Sending notify of $from .. $to ($commit_count commits) for $deploy_environment to $zulip_notify_server"
|
||||
|
||||
zulip_send "Finished ${deploy_environment} deploy of [${commit_count} new commits](https://github.com/zulip/zulip/compare/${from}...${to}) on $(hostname)"
|
||||
|
||||
@@ -5,4 +5,6 @@ set -u
|
||||
|
||||
source "$(dirname "$0")/../common/zulip_notify.sh"
|
||||
|
||||
echo "zulip_notify: Sending notify of $from .. $to ($commit_count commits) for $deploy_environment to $zulip_notify_server"
|
||||
|
||||
zulip_send "Starting ${deploy_environment} deploy of [${commit_count} new commits](https://github.com/zulip/zulip/compare/${from}...${to}) on $(hostname)"
|
||||
|
||||
7
puppet/zulip/manifests/hooks/zulip_common.pp
Normal file
7
puppet/zulip/manifests/hooks/zulip_common.pp
Normal file
@@ -0,0 +1,7 @@
|
||||
# @summary zulip_notify common file
|
||||
#
|
||||
class zulip::hooks::zulip_common {
|
||||
include zulip::hooks::base
|
||||
|
||||
zulip::hooks::file { 'common/zulip_notify.sh': }
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
#
|
||||
class zulip::hooks::zulip_notify {
|
||||
include zulip::hooks::base
|
||||
include zulip::hooks::zulip_common
|
||||
|
||||
zulip::hooks::file { [
|
||||
'common/zulip_notify.sh',
|
||||
'pre-deploy.d/zulip_notify.hook',
|
||||
'post-deploy.d/zulip_notify.hook',
|
||||
]: }
|
||||
|
||||
Reference in New Issue
Block a user