From 4d46051a1f746e18c02653eec195f00792462a43 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Mon, 11 May 2026 17:15:51 +0200 Subject: [PATCH 01/15] add new command to perform optional post-installation tasks for django apps --- .../commands/openquake_engine_postinstall.py | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 openquake/server/management/commands/openquake_engine_postinstall.py diff --git a/openquake/server/management/commands/openquake_engine_postinstall.py b/openquake/server/management/commands/openquake_engine_postinstall.py new file mode 100644 index 000000000000..f09f57c7c4da --- /dev/null +++ b/openquake/server/management/commands/openquake_engine_postinstall.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# oq-geoviewer +# Copyright (C) 2018-2019 GEM Foundation +# +# oq-geoviewer is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# oq-geoviewer is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +# import subprocess +from django.apps import apps as django_apps +from django.core.management import call_command, get_commands +import sys +from django.core.management.base import BaseCommand + +class Command(BaseCommand): + help = ("Command that run a '_postinstall' command if it exists") + + def add_arguments(self, parser): + parser.add_argument('django_app', + help='django application name') + + def handle(self, *args, **options): + found = False + for app in django_apps.get_app_configs(): + label = app.label + if options['django_app'] == label: + found = True + break + + if not found: + self.stdout.write( + self.style.ERROR( + "No django app '%s' found." % (options['django_app'],)) + ) + sys.exit(1) + + postinstall_cmd = options['django_app'] + '_postinstall' + django_cmds = get_commands() + if postinstall_cmd not in django_cmds: + self.stdout.write( + self.style.WARNING( + "No 'postinst' action needed for app %s, skipped." % (options['django_app'],)) + ) + sys.exit(0) + + call_command(postinstall_cmd) From 2c14bf5c4f8bbb74d154071fcc2a8bf1c6f53d9d Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Mon, 11 May 2026 17:22:11 +0200 Subject: [PATCH 02/15] completed post-install for Django apps --- install.py | 139 ++++++++++++++++++++++++----------- openquake/server/settings.py | 11 +++ setup.py | 37 ++-------- 3 files changed, 114 insertions(+), 73 deletions(-) diff --git a/install.py b/install.py index 747e1fe8280d..fe9325ac330b 100644 --- a/install.py +++ b/install.py @@ -260,12 +260,17 @@ def get_requirements_branch(version, inst, from_fork): return version -def install_standalone(venv): +def install_or_postinstall_standalone(venv, is_install=True): """ - Install the standalone Django applications if possible + Install the standalone Django applications if possible or + run '_postinstall' command if it exists """ errors = [] - print("The standalone applications are not installed yet") + if is_install: + print("The standalone applications are not installed yet") + else: + print("Run '_postinstall' command for each standalone\n" + " Django applications, if it exists") if sys.platform == "win32": if os.path.exists("python\\python._pth.old"): pycmd = inst.VENV + "\\python.exe" @@ -273,24 +278,57 @@ def install_standalone(venv): pycmd = inst.VENV + "\\Scripts\\python.exe" else: pycmd = inst.VENV + "/bin/python3" - for app in [ - "oq-platform-standalone", - "oq-platform-ipt", - "oq-platform-taxonomy", - ]: - try: - print("Applications " + app + " are not installed yet \n") - subprocess.check_call( - [pycmd, "-m", "pip", "install", "--find-links", URL_STANDALONE, - app] - ) - except Exception as exc: - # for instance is somebody removed a wheel from the wheelhouse - errors.append("%s: could not install %s" % (exc, app)) + STANDALONE_APP_INFO = [ + {"pkg": "oq-platform-standalone", "name": None}, + {"pkg": "oq-platform-ipt", "name": "openquakeplatform_ipt"}, + {"pkg": "oq-platform-taxonomy", "name": "openquakeplatform_taxonomy"}, + {"pkg": "django-gem-taxonomy", "name": "django_gem_taxonomy"}, + ] + + if is_install: + for app in STANDALONE_APP_INFO: + try: + print("Applications " + app['pkg'] + " are not installed yet \n") + + subprocess.check_call( + [pycmd, "-m", "pip", "install", "--find-links", URL_STANDALONE, + app['pkg']] + ) + except Exception as exc: + # for instance is somebody removed a wheel from the wheelhouse + errors.append("%s: could not install %s" % (exc, app['pkg'])) + else: + for app in STANDALONE_APP_INFO: + if not app['name']: + continue + + try: + if sys.platform == "win32": + django_admin = ['Scripts', 'django-admin.exe'] + else: + django_admin = ["bin", "django-admin"] + + django_env = os.environ.copy() + django_env["DJANGO_SETTINGS_MODULE"] = "openquake.server.settings" + + subprocess.check_call( + [os.path.join(inst.VENV, *django_admin), + "openquake_engine_postinstall", app['name']], + env=django_env) + except Exception as exc: + # for instance is somebody removed a wheel from the wheelhouse + errors.append("%s: error during %s postinstall command execution" % (exc, app['name'])) + return errors +def install_standalone(venv): + return install_or_postinstall_standalone(venv, is_install=True) + +def postinstall_standalone(venv): + return install_or_postinstall_standalone(venv, is_install=False) + def before_checks(inst, args, usage): """ Checks to perform before the installation @@ -300,6 +338,10 @@ def before_checks(inst, args, usage): if args.dbport: inst.DBPORT = int(args.dbport) + if args.novenv: + inst.VENV = os.path.join(os.getenv('LocalAppData'), 'Programs', + 'OpenQuake Engine', 'python3') + # check platform if (inst is server and sys.platform != "linux") or ( inst is devel_server and sys.platform != "linux" @@ -416,7 +458,7 @@ def normalize_version(version): return f"=={version}" -def install(inst, version, from_fork): +def install(inst, version, from_fork, novenv, noupgrade): """ Install the engine in one of the three possible modes """ @@ -436,34 +478,38 @@ def install(inst, version, from_fork): if inst is server or inst is devel_server: subprocess.check_call(["chown", "openquake", inst.OQDATA]) - # recreate the openquake venv - ensure(pyvenv=inst.VENV) - print("Created %s" % inst.VENV) + if not novenv: + # recreate the openquake venv + ensure(pyvenv=inst.VENV) + print("Created %s" % inst.VENV) - if sys.platform == "win32": - if os.path.exists("python\\python._pth.old"): - pycmd = inst.VENV + "\\python.exe" + if sys.platform == "win32": + if os.path.exists("python\\python._pth.old"): + pycmd = inst.VENV + "\\python.exe" + else: + pycmd = inst.VENV + "\\Scripts\\python.exe" else: - pycmd = inst.VENV + "\\Scripts\\python.exe" + pycmd = inst.VENV + "/bin/python3" else: - pycmd = inst.VENV + "/bin/python3" + pycmd = os.path.join(inst.VENV, 'python.exe') # upgrade pip and before check that it is installed in venv if sys.platform != "win32": ensure(pip=pycmd) - subprocess.check_call( - [pycmd, "-m", "pip", "install", "--upgrade", "pip", "wheel"] - ) + subprocess.check_call([pycmd, "-m", "pip", "install"] + ([ + ] if noupgrade else ["--upgrade"]) + [ + "pip", "wheel"]) else: if os.path.exists("python\\python._pth.old"): - subprocess.check_call( - [pycmd, "-m", "pip", "install", "--upgrade", "pip", "wheel", - "urllib3"]) + subprocess.check_call([pycmd, "-m", "pip", "install"] + ([ + ] if noupgrade else ["--upgrade"]) + [ + "pip", "wheel", "urllib3"]) else: - subprocess.check_call([pycmd, "-m", "ensurepip", "--upgrade"]) - subprocess.check_call( - [pycmd, "-m", "pip", "install", "--upgrade", "pip", "wheel", - "urllib3"]) + subprocess.check_call([pycmd, "-m", "ensurepip"] + ([ + ] if noupgrade else ["--upgrade"])) + subprocess.check_call([pycmd, "-m", "pip", "install"] + ([ + ] if noupgrade else ["--upgrade"]) + [ + "pip", "wheel", "urllib3"]) # install the requirements branch = get_requirements_branch(version, inst, from_fork) @@ -494,12 +540,14 @@ def install(inst, version, from_fork): subprocess.check_call([pycmd, "-m", "pip", "install", "-e", CDIR]) elif version is None: # install the stable version subprocess.check_call( - [pycmd, "-m", "pip", "install", "--upgrade", "openquake.engine"] + [pycmd, "-m", "pip", "install"] + ([ + ] if noupgrade else ["--upgrade"]) + ["openquake.engine"] ) elif re.match(r"\d+(\.\d+)+", version): # install an official version subprocess.check_call( - [pycmd, "-m", "pip", "install", "--upgrade", - f"openquake.engine{normalize_version(version)}"] + [pycmd, "-m", "pip", "install"] + ([] if noupgrade + else ["--upgrade"]) + + [f"openquake.engine{normalize_version(version)}"] ) else: # install a branch from github (only for user or server) commit = latest_commit(version) @@ -509,8 +557,9 @@ def install(inst, version, from_fork): custom_env["TMPDIR"] = tmp # Linux/macOS custom_env["TEMP"] = tmp # Windows subprocess.check_call( - [pycmd, "-m", "pip", "install", - "--upgrade", GITBRANCH % commit, "--no-clean"], + [pycmd, "-m", "pip", "install"] + ( + [] if noupgrade else ["--upgrade"]) + [GITBRANCH % commit, + "--no-clean"], env=custom_env) fix_version(commit, inst.VENV) @@ -541,6 +590,8 @@ def install(inst, version, from_fork): if inst in (user, devel): # create/upgrade the db in the default location subprocess.run([oqreal, "engine", "--upgrade-db"]) + errors += postinstall_standalone(inst.VENV) + if ( inst is server and not os.path.exists(inst.OQ) @@ -634,6 +685,10 @@ def remove(inst): help="the kind of installation you want", ) parser.add_argument("--venv", help="venv directory") + parser.add_argument("--novenv", action="store_true", + help="keep the current python environment") + parser.add_argument("--noupgrade", action="store_true", + help="not use '--upgrade' in pip install calls") parser.add_argument("--remove", action="store_true", help="disinstall the engine") parser.add_argument("--version", help="version to install (default stable)") @@ -651,7 +706,7 @@ def remove(inst): if args.remove: remove(inst) else: - errors = install(inst, args.version, args.from_fork) + errors = install(inst, args.version, args.from_fork, args.novenv, args.noupgrade) if errors: # NB: even if one of the tools is missing, the engine will work sys.exit('\n'.join(errors)) diff --git a/openquake/server/settings.py b/openquake/server/settings.py index 35b50ea0a6d3..9ab7d29e5c46 100644 --- a/openquake/server/settings.py +++ b/openquake/server/settings.py @@ -230,6 +230,17 @@ # IMPACT_DEFAULT_USGS_ID = 'us7000n7n8' # loadable and convertible rupture # IMPACT_DEFAULT_USGS_ID = 'us6000jllz' # loadable but with conversion err +# Definition of Django applications +STANDALONE_APP_NAME_MAP = { + 'openquakeplatform_ipt': 'ipt', + 'django_gem_taxonomy': 'taxonomy', + } +if APPLICATION_MODE != 'TOOLS_ONLY': + STANDALONE_APP_NAME_MAP['openquakeplatform_taxonomy'] = 'glossary' + +ARISTOTLE_DEFAULT_USGS_ID = 'us7000n7n8' # loadable and convertible rupture +# ARISTOTLE_DEFAULT_USGS_ID = 'us6000jllz' # loadable but with conversion err + EXTERNAL_TOOLS = os.environ.get('EXTERNAL_TOOLS', False) == 'True' # If False, a warning is displayed in case a newer version of the engine has diff --git a/setup.py b/setup.py index 32b96f0d0d38..dfdd5512968a 100644 --- a/setup.py +++ b/setup.py @@ -1,31 +1,6 @@ -# -*- coding: utf-8 -*- -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# -# Copyright (C) 2013-2026 GEM Foundation -# -# OpenQuake is free software: you can redistribute it and/or modify it -# under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenQuake is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with OpenQuake. If not, see . - -import os -from setuptools import setup - -def generate_data_files(source_dir): - # Helper function for demos - data_files_list = [] - for target_dir, _dirs, files in os.walk(source_dir): - if files: - source_files = [os.path.join(target_dir, f) for f in files] - data_files_list.append((target_dir, source_files)) - return data_files_list - -setup(data_files=generate_data_files('demos')) +[pytest] +markers = + slow: a slow test +addopts = --tb short +consider_namespace_packages = true +DJANGO_SETTINGS_MODULE = openquake.server.settings From a0b1f0b9f53db8e1c62ca4157381fc91be62130a Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Mon, 11 May 2026 18:36:33 +0200 Subject: [PATCH 03/15] add a comment to trigger tests --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ad16676f8fa7..b0a2b5174edf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,4 @@ +# MN: Just for test [build-system] requires = ["setuptools >= 79.0", "wheel"] build-backend = "setuptools.build_meta" From 05e89d81a20d23d76fd356f9febaaec7f541b9d7 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Tue, 12 May 2026 09:32:33 +0200 Subject: [PATCH 04/15] replaced wrong setup.py --- setup.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index dfdd5512968a..32b96f0d0d38 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,31 @@ -[pytest] -markers = - slow: a slow test -addopts = --tb short -consider_namespace_packages = true -DJANGO_SETTINGS_MODULE = openquake.server.settings +# -*- coding: utf-8 -*- +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright (C) 2013-2026 GEM Foundation +# +# OpenQuake is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OpenQuake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with OpenQuake. If not, see . + +import os +from setuptools import setup + +def generate_data_files(source_dir): + # Helper function for demos + data_files_list = [] + for target_dir, _dirs, files in os.walk(source_dir): + if files: + source_files = [os.path.join(target_dir, f) for f in files] + data_files_list.append((target_dir, source_files)) + return data_files_list + +setup(data_files=generate_data_files('demos')) From 14eccc7968e55bbf6b08ebcf6c1b5ab97317a8c8 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Tue, 12 May 2026 09:51:51 +0200 Subject: [PATCH 05/15] replaced standalone wheelhouse with the current LTS version --- install.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.py b/install.py index fe9325ac330b..697a927fb936 100644 --- a/install.py +++ b/install.py @@ -208,7 +208,9 @@ class devel(user): "win32": ("win64",), } GITBRANCH = "https://github.com/gem/oq-engine/archive/%s.zip" -URL_STANDALONE = "https://wheelhouse.openquake.org/py/standalone/latest/" +# FIXME just for devel test +# URL_STANDALONE = "https://wheelhouse.openquake.org/py/standalone/latest/" +URL_STANDALONE = "https://wheelhouse.openquake.org/py/standalone/engine-3.23/" def ensure(pip=None, pyvenv=None): From b42366a1de4c94b1bf80749e288b26dc426caad5 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Tue, 12 May 2026 10:08:48 +0200 Subject: [PATCH 06/15] retrigger tests commit --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b0a2b5174edf..ad16676f8fa7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,3 @@ -# MN: Just for test [build-system] requires = ["setuptools >= 79.0", "wheel"] build-backend = "setuptools.build_meta" From 21cccea313c9183e64e6272a5b58785af1369c30 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Tue, 12 May 2026 10:43:19 +0200 Subject: [PATCH 07/15] trigger tests via fake commit --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ad16676f8fa7..0133fd67e986 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,4 @@ +# FIXME: MN - trigger for test [build-system] requires = ["setuptools >= 79.0", "wheel"] build-backend = "setuptools.build_meta" From 25caf9c365a2d5c56c137b2f08ea4e0acff6dfbb Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Tue, 12 May 2026 11:06:26 +0200 Subject: [PATCH 08/15] remove dev comment to trigger tests --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0133fd67e986..ad16676f8fa7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,3 @@ -# FIXME: MN - trigger for test [build-system] requires = ["setuptools >= 79.0", "wheel"] build-backend = "setuptools.build_meta" From 1b334f1f819c613f2feae3907615c71625881772 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Tue, 12 May 2026 11:11:15 +0200 Subject: [PATCH 09/15] replaced STANDALONE folder for wheelhouse site --- install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.py b/install.py index 697a927fb936..4730b348a683 100644 --- a/install.py +++ b/install.py @@ -210,7 +210,7 @@ class devel(user): GITBRANCH = "https://github.com/gem/oq-engine/archive/%s.zip" # FIXME just for devel test # URL_STANDALONE = "https://wheelhouse.openquake.org/py/standalone/latest/" -URL_STANDALONE = "https://wheelhouse.openquake.org/py/standalone/engine-3.23/" +URL_STANDALONE = "https://wheelhouse.openquake.org/py/standalone/b3.23-pre5/" def ensure(pip=None, pyvenv=None): From 2ad64810a207cdb33cf6b74377d7c4208d8811dd Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Tue, 12 May 2026 11:46:34 +0200 Subject: [PATCH 10/15] trigger tests with fake comment --- install.py | 1 + 1 file changed, 1 insertion(+) diff --git a/install.py b/install.py index 4730b348a683..a1b34bbf7043 100644 --- a/install.py +++ b/install.py @@ -1,3 +1,4 @@ +# FIXME: mn just to trigger CI # -*- coding: utf-8 -*- # vim: tabstop=4 shiftwidth=4 softtabstop=4 # From 0ba42e3024ce76ee9e48152acc3199acaa0034ab Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Tue, 12 May 2026 12:18:24 +0200 Subject: [PATCH 11/15] minor changes and remove obsolete config --- install.py | 1 - openquake/server/settings.py | 3 --- 2 files changed, 4 deletions(-) diff --git a/install.py b/install.py index a1b34bbf7043..4730b348a683 100644 --- a/install.py +++ b/install.py @@ -1,4 +1,3 @@ -# FIXME: mn just to trigger CI # -*- coding: utf-8 -*- # vim: tabstop=4 shiftwidth=4 softtabstop=4 # diff --git a/openquake/server/settings.py b/openquake/server/settings.py index 9ab7d29e5c46..69ebab350fcd 100644 --- a/openquake/server/settings.py +++ b/openquake/server/settings.py @@ -238,9 +238,6 @@ if APPLICATION_MODE != 'TOOLS_ONLY': STANDALONE_APP_NAME_MAP['openquakeplatform_taxonomy'] = 'glossary' -ARISTOTLE_DEFAULT_USGS_ID = 'us7000n7n8' # loadable and convertible rupture -# ARISTOTLE_DEFAULT_USGS_ID = 'us6000jllz' # loadable but with conversion err - EXTERNAL_TOOLS = os.environ.get('EXTERNAL_TOOLS', False) == 'True' # If False, a warning is displayed in case a newer version of the engine has From 7eb52a78ec140b611aa028ea8721ae3e0a68e99c Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Tue, 12 May 2026 14:58:00 +0200 Subject: [PATCH 12/15] create new wheelhouse folder for 'post-inst' branch --- install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.py b/install.py index 4730b348a683..1aeb0221693e 100644 --- a/install.py +++ b/install.py @@ -210,7 +210,7 @@ class devel(user): GITBRANCH = "https://github.com/gem/oq-engine/archive/%s.zip" # FIXME just for devel test # URL_STANDALONE = "https://wheelhouse.openquake.org/py/standalone/latest/" -URL_STANDALONE = "https://wheelhouse.openquake.org/py/standalone/b3.23-pre5/" +URL_STANDALONE = "https://wheelhouse.openquake.org/py/standalone/post-inst/" def ensure(pip=None, pyvenv=None): From 70be55b97cb1f2b1f9aec270fa0f23cac8d99ad8 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Thu, 14 May 2026 16:32:36 +0200 Subject: [PATCH 13/15] add django-gem-taxonomy to the list of django apps --- .github/workflows/webui_rh_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/webui_rh_test.yml b/.github/workflows/webui_rh_test.yml index 75c0fb5aebfe..ac71b313278e 100644 --- a/.github/workflows/webui_rh_test.yml +++ b/.github/workflows/webui_rh_test.yml @@ -66,7 +66,7 @@ jobs: eval '$mypython -m pip install -e . ' ## Standalone apps echo "Downloading standalone apps" - for app in oq-platform-standalone oq-platform-ipt oq-platform-taxonomy; do + for app in oq-platform-standalone django-gem-taxonomy oq-platform-ipt oq-platform-taxonomy; do # do not fail on exit code 2 if the branch # does not exist in the app repository set +e From 4809ba7855aa5d07b23aed480663598b2bce32f6 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Thu, 14 May 2026 16:47:43 +0200 Subject: [PATCH 14/15] if branch doesn't exists nor 'master' exists try 'main' branch --- .github/workflows/webui_rh_test.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/webui_rh_test.yml b/.github/workflows/webui_rh_test.yml index ac71b313278e..39577098aff9 100644 --- a/.github/workflows/webui_rh_test.yml +++ b/.github/workflows/webui_rh_test.yml @@ -81,6 +81,19 @@ jobs: echo "Git branch '$BRANCH' does not exist in the remote repository" TOOLS_BRANCH=master fi + + set +e + git ls-remote --exit-code --heads https://github.com/gem/${app}.git $BRANCH >/dev/null 2>&1 + EXIT_CODE=$? + # set again to fail on exit code not 0 + set -e + if [[ $EXIT_CODE == '0' ]]; then + echo "Git branch '$BRANCH' exists in the remote repository" + TOOLS_BRANCH=$BRANCH + elif [[ $EXIT_CODE == '2' ]]; then + echo "Git branch '$BRANCH' does not exist in the remote repository" + TOOLS_BRANCH=main + fi echo "We need to use the branch $TOOLS_BRANCH for the standalone apps" git clone -b ${TOOLS_BRANCH} --depth=1 https://github.com/gem/${app}.git eval '$mypython -m pip install -e ./${app}' From b6867d304753e2cd972b289832557e80aadf3048 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Thu, 14 May 2026 17:00:23 +0200 Subject: [PATCH 15/15] more solide and modern (manage 'main' branch case too) management of django apps --- .github/workflows/webui_rh_test.yml | 54 +++++++++++++---------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/.github/workflows/webui_rh_test.yml b/.github/workflows/webui_rh_test.yml index 39577098aff9..45719fa4f605 100644 --- a/.github/workflows/webui_rh_test.yml +++ b/.github/workflows/webui_rh_test.yml @@ -67,37 +67,31 @@ jobs: ## Standalone apps echo "Downloading standalone apps" for app in oq-platform-standalone django-gem-taxonomy oq-platform-ipt oq-platform-taxonomy; do - # do not fail on exit code 2 if the branch - # does not exist in the app repository - set +e - git ls-remote --exit-code --heads https://github.com/gem/${app}.git $BRANCH >/dev/null 2>&1 - EXIT_CODE=$? - # set again to fail on exit code not 0 - set -e - if [[ $EXIT_CODE == '0' ]]; then - echo "Git branch '$BRANCH' exists in the remote repository" - TOOLS_BRANCH=$BRANCH - elif [[ $EXIT_CODE == '2' ]]; then - echo "Git branch '$BRANCH' does not exist in the remote repository" - TOOLS_BRANCH=master - fi - - set +e - git ls-remote --exit-code --heads https://github.com/gem/${app}.git $BRANCH >/dev/null 2>&1 - EXIT_CODE=$? - # set again to fail on exit code not 0 - set -e - if [[ $EXIT_CODE == '0' ]]; then - echo "Git branch '$BRANCH' exists in the remote repository" - TOOLS_BRANCH=$BRANCH - elif [[ $EXIT_CODE == '2' ]]; then - echo "Git branch '$BRANCH' does not exist in the remote repository" - TOOLS_BRANCH=main - fi - echo "We need to use the branch $TOOLS_BRANCH for the standalone apps" - git clone -b ${TOOLS_BRANCH} --depth=1 https://github.com/gem/${app}.git - eval '$mypython -m pip install -e ./${app}' + for branch in "$BRANCH" "master" "main"; do + TOOLS_BRANCH="$branch" + # do not fail on exit code 2 if the branch + # does not exist in the app repository + set +e + git ls-remote --exit-code --heads https://github.com/gem/${app}.git $TOOLS_BRANCH >/dev/null 2>&1 + EXIT_CODE=$? + # set again to fail on exit code not 0 + set -e + if [[ $EXIT_CODE -eq 0 ]]; then + echo "Git branch '$BRANCH' exists in the remote repository" + break + fi + done + if [[ $EXIT_CODE -ne 0 ]]; then + break + fi + echo "We need to use the branch $TOOLS_BRANCH for the standalone apps" + git clone -b ${TOOLS_BRANCH} --depth=1 https://github.com/gem/${app}.git + eval '$mypython -m pip install -e ./${app}' done + if [ $EXIT_CODE -ne 0 ]; then + echo "No '$branch', nor 'master' or 'main' branch found for '$app' django app; failed" + exit 1 + fi deactivate - name: Actualize 'default' templates for email notifications run: |