Browse Source

fix: envrc + add shellcheck (#61073)

Joshua Li 1 year ago
parent
commit
6b3c219125
2 changed files with 21 additions and 14 deletions
  1. 14 14
      .envrc
  2. 7 0
      .pre-commit-config.yaml

+ 14 - 14
.envrc

@@ -61,7 +61,7 @@ report_to_sentry() {
     fi
     # Report to sentry-dev-env project
     SENTRY_DSN="https://9bdb053cb8274ea69231834d1edeec4c@o1.ingest.sentry.io/5723503" \
-        sentry-cli send-event -m "$error_message" --logfile "$_SENTRY_LOG_FILE" --level $log_level
+        sentry-cli send-event -m "$error_message" --logfile "$_SENTRY_LOG_FILE" --level "$log_level"
     rm "$_SENTRY_LOG_FILE"
 }
 
@@ -189,28 +189,28 @@ make setup-git-config
 
 ### Python ###
 
+venv_name=".venv"
+
 # Use requirements-dev.txt to decide when to cut over to `devenv` tooling.
 # This also provides us with a clean-cut rollback procedure.
-if ! grep -Eq "^devenv($|>)" requirements-dev.txt; then
-    # Old and busted. (but currently working)
-    venv_name=".venv"
-    if [ ! -f "${venv_name}/bin/activate" ]; then
-        prompt_python_venv_creation
-        # This is time consuming but it has to be done
-        source "${SENTRY_ROOT}/scripts/bootstrap-py3-venv"
-    fi
-else
+if [ -n "$SENTRY_DEVENV_BETA" ] || grep -Eq "^devenv($|>)" requirements-dev.txt; then
     # The new hotness. (but not ready yet)
+    echo "Using devenv."
     export SENTRY_DEVENV_HOME="${SENTRY_DEVENV_HOME:-$XDG_DATA_HOME/sentry-devenv}"
     PATH_add "${SENTRY_DEVENV_HOME}/bin"
-    venv_name="${SENTRY_DEVENV_HOME}/virtualenvs/sentry"
     if ! command -v devenv >/dev/null; then
       die '
-Please install the `devenv` tool:
+Please install the devenv tool:
     https://github.com/getsentry/devenv#install
 '
-    elif [ ! -f "${venv_name}/bin/activate" ]; then
-        devenv sync
+    fi
+    devenv sync
+else
+    # Old and busted. (but currently working)
+    if [ ! -f "${venv_name}/bin/activate" ]; then
+        prompt_python_venv_creation
+        # This is time consuming but it has to be done
+        source "${SENTRY_ROOT}/scripts/bootstrap-py3-venv"
     fi
 fi
 

+ 7 - 0
.pre-commit-config.yaml

@@ -138,3 +138,10 @@ repos:
             |static/app/utils/profiling/profile/formats/node/trace\.json
             |static/app/utils/profiling/profile/formats/typescript/trace\.json
           )$
+  - repo: https://github.com/shellcheck-py/shellcheck-py
+    rev: v0.9.0.6
+    hooks:
+      - id: shellcheck
+        types: [file]
+        files: ^\.envrc$
+        args: [--external-sources]