do.sh 1.0 KB

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. # This script is an interface to any of the methods of lib.sh
  3. # Call this script as "do.sh method_from_lib" to execute any function from that library
  4. set -eu
  5. HERE="$(
  6. cd "$(dirname "${BASH_SOURCE[0]}")"
  7. pwd -P
  8. )"
  9. # shellcheck disable=SC1090
  10. source "${HERE}/lib.sh"
  11. # This guarantees that we're within a venv. A caller that is not within
  12. # a venv can avoid enabling this by setting SENTRY_NO_VENV_CHECK
  13. [ -z "${SENTRY_NO_VENV_CHECK+x}" ] && eval "${HERE}/ensure-venv.sh"
  14. # If you call this script
  15. start=`date +%s`
  16. "$@"
  17. end=`date +%s`
  18. duration=$(($end-$start))
  19. # If we're not in CI, send a metric of the script's execution time
  20. if [ -z "${CI+x}" ]; then
  21. configure-sentry-cli
  22. # DSN for `sentry-devservices` project in the Sentry SDKs org. Used as authentication for sentry-cli.
  23. export SENTRY_DSN=https://8ae521d2441786bb405b3b3705bb9dc1@o447951.ingest.us.sentry.io/4507346183716864
  24. "${venv_name}"/bin/sentry-cli send-metric distribution -n script_execution_time -v $duration -u second -t script:$1
  25. fi