mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
provision: Avoid shelling out to clean caches.
Yes, it's slightly janky to create an argparse.Namespace object like this, but it saves us from shelling out to a script whose only real value-add is parsing a single `threshold_days` argument. This saves about 130ms for a no-op provision.
This commit is contained in:
@@ -56,6 +56,7 @@ def overwrite_symlink(src: str, dst: str) -> None:
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
def parse_cache_script_args(description: str) -> argparse.Namespace:
|
def parse_cache_script_args(description: str) -> argparse.Namespace:
|
||||||
|
# Keep this in sync with clean_unused_caches in provision_inner.py
|
||||||
parser = argparse.ArgumentParser(description=description)
|
parser = argparse.ArgumentParser(description=description)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|||||||
@@ -168,6 +168,20 @@ def need_to_run_configure_rabbitmq(settings_list: List[str]) -> bool:
|
|||||||
except Exception:
|
except Exception:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def clean_unused_caches() -> None:
|
||||||
|
args = argparse.Namespace(
|
||||||
|
threshold_days=6,
|
||||||
|
# The defaults here should match parse_cache_script_args in zulip_tools.py
|
||||||
|
dry_run=False,
|
||||||
|
verbose=False,
|
||||||
|
no_headings=True,
|
||||||
|
)
|
||||||
|
from scripts.lib import clean_venv_cache, clean_node_cache, clean_emoji_cache
|
||||||
|
clean_venv_cache.main(args)
|
||||||
|
clean_node_cache.main(args)
|
||||||
|
clean_emoji_cache.main(args)
|
||||||
|
|
||||||
def main(options: argparse.Namespace) -> int:
|
def main(options: argparse.Namespace) -> int:
|
||||||
setup_bash_profile()
|
setup_bash_profile()
|
||||||
setup_shell_profile('~/.zprofile')
|
setup_shell_profile('~/.zprofile')
|
||||||
@@ -264,7 +278,7 @@ def main(options: argparse.Namespace) -> int:
|
|||||||
if destroyed:
|
if destroyed:
|
||||||
print("Dropped %s stale test databases!" % (destroyed,))
|
print("Dropped %s stale test databases!" % (destroyed,))
|
||||||
|
|
||||||
run(["scripts/lib/clean-unused-caches", "--threshold=6"])
|
clean_unused_caches()
|
||||||
|
|
||||||
# Keeping this cache file around can cause eslint to throw
|
# Keeping this cache file around can cause eslint to throw
|
||||||
# random TypeErrors when new/updated dependencies are added
|
# random TypeErrors when new/updated dependencies are added
|
||||||
|
|||||||
Reference in New Issue
Block a user