From be5383b1644813a667d5b18cb9ba7d5ea43111a0 Mon Sep 17 00:00:00 2001
From: decentral1se <hi@decentral1.se>
Date: Sat, 3 Apr 2021 20:42:02 +0200
Subject: [PATCH] Make use of caching for speeding up tags generation
See https://git.autonomic.zone/coop-cloud/abra/issues/129.
---
bin/app-json.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/bin/app-json.py b/bin/app-json.py
index 97e967545bb..4995e6a818a 100755
--- a/bin/app-json.py
+++ b/bin/app-json.py
@@ -9,7 +9,7 @@
from json import dump
from logging import DEBUG, basicConfig, getLogger
from os import chdir, listdir, mkdir
-from os.path import exists, expanduser
+from os.path import basename, exists, expanduser
from pathlib import Path
from re import findall, search
from shlex import split
@@ -85,6 +85,7 @@ def clone_all_apps():
def generate_apps_json():
"""Generate the abra-apps.json application versions file."""
apps_json = {}
+ cached_apps_json = get_published_apps_json()
for app in listdir(CLONES_PATH):
if app in REPOS_TO_SKIP:
@@ -104,7 +105,7 @@ def generate_apps_json():
# users believe X feature is available under Y version but it is
# not.
"features": get_app_features(app_path),
- "versions": get_app_versions(app_path),
+ "versions": get_app_versions(app_path, cached_apps_json),
}
return apps_json
@@ -140,7 +141,7 @@ def get_app_features(app_path):
return features
-def get_app_versions(app_path):
+def get_app_versions(app_path, cached_apps_json):
versions = {}
chdir(app_path)
@@ -153,7 +154,14 @@ def get_app_versions(app_path):
initial_branch = _run_cmd("git rev-parse --abbrev-ref HEAD")
+ app_name = basename(app_path)
+ existing_tags = cached_apps_json[app_name]["versions"].keys()
+
for tag in tags:
+ if tag in existing_tags:
+ log.info(f"Skipping {tag} because we've already processed it")
+ continue
+
_run_cmd(f"git checkout {tag}")
services_cmd = "yq e '.services | keys | .[]' compose*.yml"