Browse Source

dev: Skip starting devservices when `SENTRY_DEVENV_FRONTEND_ONLY` env var is set (#68712)

Billy Vong 11 months ago
parent
commit
8a27279f67
1 changed files with 13 additions and 1 deletions
  1. 13 1
      devenv/sync.py

+ 13 - 1
devenv/sync.py

@@ -69,6 +69,10 @@ def main(context: dict[str, str]) -> int:
     repo = context["repo"]
     reporoot = context["reporoot"]
 
+    FRONTEND_ONLY = os.environ.get("SENTRY_DEVENV_FRONTEND_ONLY") is not None
+
+    # venv's still needed for frontend because repo-local devenv and pre-commit
+    # exist inside it
     venv_dir, python_version, requirements, editable_paths, bins = venv.get(reporoot, repo)
     url, sha256 = config.get_python(reporoot, python_version)
     print(f"ensuring {repo} venv at {venv_dir}...")
@@ -113,6 +117,8 @@ def main(context: dict[str, str]) -> int:
         venv_dir,
         (
             ("javascript dependencies", ("make", "install-js-dev")),
+            # could opt out of syncing python if FRONTEND_ONLY but only if repo-local devenv
+            # and pre-commit were moved to inside devenv and not the sentry venv
             ("python dependencies", ("make", "install-py-dev")),
         ),
     ):
@@ -125,7 +131,7 @@ def main(context: dict[str, str]) -> int:
         (
             (
                 "git and precommit",
-                # this can't be done in paralell with python dependencies
+                # this can't be done in parallel with python dependencies
                 # as multiple pips cannot act on the same venv
                 ("make", "setup-git"),
             ),
@@ -138,6 +144,12 @@ def main(context: dict[str, str]) -> int:
     ):
         proc.run((f"{venv_dir}/bin/sentry", "init", "--dev"))
 
+    # Frontend engineers don't necessarily always have devservices running and
+    # can configure to skip them to save on local resources
+    if FRONTEND_ONLY:
+        print("Skipping python migrations since SENTRY_DEVENV_FRONTEND_ONLY is set.")
+        return 0
+
     # TODO: check healthchecks for redis and postgres to short circuit this
     proc.run(
         (