Make use of caching for speeding up tags generation
See coop-cloud/abra#129.
This commit is contained in:
parent
3720ef838d
commit
be5383b164
@ -9,7 +9,7 @@
|
|||||||
from json import dump
|
from json import dump
|
||||||
from logging import DEBUG, basicConfig, getLogger
|
from logging import DEBUG, basicConfig, getLogger
|
||||||
from os import chdir, listdir, mkdir
|
from os import chdir, listdir, mkdir
|
||||||
from os.path import exists, expanduser
|
from os.path import basename, exists, expanduser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from re import findall, search
|
from re import findall, search
|
||||||
from shlex import split
|
from shlex import split
|
||||||
@ -85,6 +85,7 @@ def clone_all_apps():
|
|||||||
def generate_apps_json():
|
def generate_apps_json():
|
||||||
"""Generate the abra-apps.json application versions file."""
|
"""Generate the abra-apps.json application versions file."""
|
||||||
apps_json = {}
|
apps_json = {}
|
||||||
|
cached_apps_json = get_published_apps_json()
|
||||||
|
|
||||||
for app in listdir(CLONES_PATH):
|
for app in listdir(CLONES_PATH):
|
||||||
if app in REPOS_TO_SKIP:
|
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
|
# users believe X feature is available under Y version but it is
|
||||||
# not.
|
# not.
|
||||||
"features": get_app_features(app_path),
|
"features": get_app_features(app_path),
|
||||||
"versions": get_app_versions(app_path),
|
"versions": get_app_versions(app_path, cached_apps_json),
|
||||||
}
|
}
|
||||||
|
|
||||||
return apps_json
|
return apps_json
|
||||||
@ -140,7 +141,7 @@ def get_app_features(app_path):
|
|||||||
return features
|
return features
|
||||||
|
|
||||||
|
|
||||||
def get_app_versions(app_path):
|
def get_app_versions(app_path, cached_apps_json):
|
||||||
versions = {}
|
versions = {}
|
||||||
|
|
||||||
chdir(app_path)
|
chdir(app_path)
|
||||||
@ -153,7 +154,14 @@ def get_app_versions(app_path):
|
|||||||
|
|
||||||
initial_branch = _run_cmd("git rev-parse --abbrev-ref HEAD")
|
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:
|
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}")
|
_run_cmd(f"git checkout {tag}")
|
||||||
|
|
||||||
services_cmd = "yq e '.services | keys | .[]' compose*.yml"
|
services_cmd = "yq e '.services | keys | .[]' compose*.yml"
|
||||||
|
Reference in New Issue
Block a user