From 2af8dc5b3d5c5ccb85c87cc6fdac0bef80a81264 Mon Sep 17 00:00:00 2001 From: Leonardo Bartoli Date: Thu, 18 Apr 2024 17:01:49 +0200 Subject: [PATCH] Restore lighthouse fix --- wptagent.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/wptagent.py b/wptagent.py index 751417185..4ab82ba78 100644 --- a/wptagent.py +++ b/wptagent.py @@ -585,6 +585,10 @@ def startup(self, detected_browsers): if self.get_node_version() < 16.0: logging.warning("Node.js 16 or newer is required for Lighthouse testing") + # Force lighthouse 11.4.0 + if self.get_lighthouse_version() != '11.4.0': + subprocess.call(['sudo', 'npm', 'i', '-g', 'lighthouse@11.4.0']) + # Check the iOS install if self.ios is not None: ret = self.requires('usbmuxwrapper') and ret @@ -625,6 +629,20 @@ def get_node_version(self): pass return version + def get_lighthouse_version(self): + """Get the installed version of lighthouse""" + version = None + try: + if sys.version_info >= (3, 0): + stdout = subprocess.check_output(['lighthouse', '--version'], encoding='UTF-8') + else: + stdout = subprocess.check_output(['lighthouse', '--version']) + version = stdout.strip() + except Exception: + pass + + return version + def update_windows_certificates(self): """ Update the root Windows certificates""" try: