Browse Source

Fix and update build scripts.

v1
Andrew Belt 5 years ago
parent
commit
ad78366900
3 changed files with 15 additions and 8 deletions
  1. +8
    -4
      scripts/common.py
  2. +1
    -1
      scripts/update.py
  3. +6
    -3
      scripts/update_cache.py

+ 8
- 4
scripts/common.py View File

@@ -1,6 +1,13 @@
import subprocess import subprocess




def system(cmd):
print(cmd)
result = subprocess.run(cmd, shell=True)
if result.returncode != 0:
raise Exception(f"Command failed with error {result.returncode}: {cmd}")


def system(cmd): def system(cmd):
print(cmd) print(cmd)
result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE) result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
@@ -10,7 +17,4 @@ def system(cmd):




def find(list, f): def find(list, f):
try:
return next(x for x in list if f(x))
except:
return None
return next((x for x in list if f(x)), None)

+ 1
- 1
scripts/update.py View File

@@ -143,7 +143,7 @@ common.system("cd ../screenshots && make upload")


# Commit repository # Commit repository
common.system("git add manifests") common.system("git add manifests")
common.system("git add manifest-cache.json ModularGrid-VCVLibrary.json")
common.system("git add manifests-cache.json ModularGrid-VCVLibrary.json")
common.system(f"git commit -m 'Update manifest for {built_slugs_str}'") common.system(f"git commit -m 'Update manifest for {built_slugs_str}'")
common.system("git push") common.system("git push")




+ 6
- 3
scripts/update_cache.py View File

@@ -22,19 +22,19 @@ def get_plugin_build(plugin):


# Get the timestamp of the earliest commit touching the manifest file # Get the timestamp of the earliest commit touching the manifest file
def get_plugin_creation(manifest_filename): def get_plugin_creation(manifest_filename):
stdout = common.system(f"git log --format=%ct -- {manifest_filename} | tail -1")
stdout = common.run(f"git log --format=%ct -- {manifest_filename} | tail -1")
return float(stdout.strip()) return float(stdout.strip())




# Get the timestamp of the earliest commit having the module slug # Get the timestamp of the earliest commit having the module slug
def get_module_creation(manifest_filename, module_slug): def get_module_creation(manifest_filename, module_slug):
stdout = common.system(f"git log --format='%H %ct' -- {manifest_filename}")
stdout = common.run(f"git log --format='%H %ct' -- {manifest_filename}")
# Use current time as a fallback because if there's no commit with the module, it was added just now. # Use current time as a fallback because if there's no commit with the module, it was added just now.
earliestTime = time.time() earliestTime = time.time()
for line in stdout.strip().split("\n"): for line in stdout.strip().split("\n"):
hash, timestamp = line.split(" ") hash, timestamp = line.split(" ")
try: try:
stdout = common.system(f"git show {hash}:{manifest_filename}")
stdout = common.run(f"git show {hash}:{manifest_filename}")
manifest = json.loads(stdout) manifest = json.loads(stdout)
# If the module exists in this commit, keep iterating # If the module exists in this commit, keep iterating
if not common.find(manifest.get('modules', []), lambda module: module['slug'] == module_slug): if not common.find(manifest.get('modules', []), lambda module: module['slug'] == module_slug):
@@ -65,6 +65,7 @@ def update():


# Get plugin build # Get plugin build
if 'buildTimestamp' not in cache_plugin: if 'buildTimestamp' not in cache_plugin:
print(f"Getting buildTimestamp for plugin {plugin_slug}")
try: try:
cache_plugin['buildTimestamp'] = get_plugin_build(plugin) cache_plugin['buildTimestamp'] = get_plugin_build(plugin)
except: except:
@@ -72,6 +73,7 @@ def update():


# Get plugin creation # Get plugin creation
if 'creationTimestamp' not in cache_plugin: if 'creationTimestamp' not in cache_plugin:
print(f"Getting creationTimestamp for plugin {plugin_slug}")
cache_plugin['creationTimestamp'] = get_plugin_creation(manifest_filename) cache_plugin['creationTimestamp'] = get_plugin_creation(manifest_filename)


# Iterate modules in plugin # Iterate modules in plugin
@@ -82,6 +84,7 @@ def update():


# Get module creation # Get module creation
if 'creationTimestamp' not in cache_module: if 'creationTimestamp' not in cache_module:
print(f"Getting creationTimestamp for plugin {plugin_slug} module {module_slug}")
cache_module['creationTimestamp'] = get_module_creation(manifest_filename, module_slug) cache_module['creationTimestamp'] = get_module_creation(manifest_filename, module_slug)


cache_modules[module_slug] = cache_module cache_modules[module_slug] = cache_module


Loading…
Cancel
Save