Skip to content

Commit

Permalink
Make lighthouse binary path configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejslawik committed Jun 2, 2023
1 parent 5623b2e commit c10d0eb
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions recipe/custom/lighthouse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class LighthouseConfig
private $slackAuthToken = '';
private $slackChannels = '';
private $projectSlug = '';
private $lighthouseBin = 'lighthouse';

public function getTargetUrl(): string
{
Expand Down Expand Up @@ -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 !== '';
}
}
Expand All @@ -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\" \
Expand All @@ -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\" \
Expand Down

0 comments on commit c10d0eb

Please sign in to comment.