check_changelog_last_modification.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. #
  3. # This scriptlet validates nightlies age and notifies is if it gets too old
  4. #
  5. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  6. #
  7. # Author : Pavlos Emm. Katsoulakis (paul@netdata.cloud)
  8. set -e
  9. # If we are not in netdata git repo, at the top level directory, fail
  10. TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
  11. CWD=$(git rev-parse --show-cdup || echo "")
  12. if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
  13. echo "Run as .travis/$(basename "$0") from top level directory of netdata git repository"
  14. echo "Changelog age checker exited abnormally"
  15. exit 1
  16. fi
  17. source tests/installer/slack.sh || echo "I could not load slack library"
  18. LAST_MODIFICATION="$(git log -1 --pretty="format:%at" CHANGELOG.md)"
  19. CURRENT_TIME="$(date +"%s")"
  20. TWO_DAYS_IN_SECONDS=172800
  21. DIFF=$((CURRENT_TIME - LAST_MODIFICATION))
  22. echo "Checking CHANGELOG.md last modification time on GIT.."
  23. echo "CHANGELOG.md timestamp: ${LAST_MODIFICATION}"
  24. echo "Current timestamp: ${CURRENT_TIME}"
  25. echo "Diff: ${DIFF}"
  26. if [ ${DIFF} -gt ${TWO_DAYS_IN_SECONDS} ]; then
  27. echo "CHANGELOG.md is more than two days old!"
  28. post_message "TRAVIS_MESSAGE" "Hi <!here>, CHANGELOG.md was found more than two days old (Diff: ${DIFF} seconds)" "${NOTIF_CHANNEL}"
  29. else
  30. echo "CHANGELOG.md is less than two days old, fine"
  31. fi