From c10d0eb5f7ef0007c0984bf10e131bb654cfbd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20S=C5=82awik?= Date: Fri, 2 Jun 2023 08:50:09 +0200 Subject: [PATCH] Make lighthouse binary path configurable --- recipe/custom/lighthouse.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/recipe/custom/lighthouse.php b/recipe/custom/lighthouse.php index e2cf436..0651885 100644 --- a/recipe/custom/lighthouse.php +++ b/recipe/custom/lighthouse.php @@ -9,6 +9,7 @@ class LighthouseConfig private $slackAuthToken = ''; private $slackChannels = ''; private $projectSlug = ''; + private $lighthouseBin = 'lighthouse'; public function getTargetUrl(): string { @@ -65,11 +66,22 @@ public function setProjectSlug(string $projectSlug): self return $this; } + public function getLighthouseBin(): string + { + return $this->lighthouseBin; + } + + public function setLighthouseBin(string $lighthouseBin): void + { + $this->lighthouseBin = $lighthouseBin; + } + public function validate(): bool { return $this->slackAuthToken !== '' && $this->slackChannels !== '' && $this->targetUrl !== '' + && $this->lighthouseBin !== '' && $this->projectSlug !== ''; } } @@ -93,7 +105,7 @@ public function validate(): bool runLocally("curl {$lighthouseConfig->getTargetUrl()} {$curlBasicAuth} > /dev/null"); // Generate results for mobile and push to Slack - runLocally("lighthouse {$lighthouseConfig->getTargetUrl()} --quiet --no-enable-error-reporting \ + runLocally("{$lighthouseConfig->getLighthouseBin()} {$lighthouseConfig->getTargetUrl()} --quiet --no-enable-error-reporting \ --chrome-flags=\"--headless --no-sandbox\" --form-factor=mobile \ --output-path={$lighthouseConfig->getProjectSlug()}-mobile.html {$extraHeaders}"); runLocally("chromium-browser --no-sandbox --headless --screenshot=\"{$lighthouseConfig->getProjectSlug()}-mobile.png\" \ @@ -105,7 +117,7 @@ public function validate(): bool https://slack.com/api/files.upload"); // Generate results for desktop and push to Slack - runLocally("lighthouse {$lighthouseConfig->getTargetUrl()} --quiet --no-enable-error-reporting \ + runLocally("{$lighthouseConfig->getLighthouseBin()} {$lighthouseConfig->getTargetUrl()} --quiet --no-enable-error-reporting \ --chrome-flags=\"--headless --no-sandbox\" --form-factor=desktop --screenEmulation.disabled \ --output-path={$lighthouseConfig->getProjectSlug()}-desktop.html {$extraHeaders}"); runLocally("chromium-browser --no-sandbox --headless --screenshot=\"{$lighthouseConfig->getProjectSlug()}-desktop.png\" \