public function githubLighthouseStatus($sha, $opts = [
        'hostname' => null,
        'protocol' => 'http',
        'performance' => false,
        'performance-score' => 50,
        'accessibility' => false,
        'accessibility-score' => 50,
        'best-practices' => false,
        'best-practices-score' => 50,
        'progressive-web-app' => false,
        'progressive-web-app-score' => 50,
    ])
    {
        $host = ProjectX::getProjectConfig()
            ->getHost();

        $protocol = $opts['protocol'];
        $hostname = isset($opts['hostname'])
            ? $opts['hostname']
            : (isset($host['name']) ? $host['name'] : 'localhost');

        $url = "$protocol://$hostname";
        $path = new \SplFileInfo("/tmp/projectx-lighthouse-$sha.json");

        $this->taskGoogleLighthouse()
            ->setUrl($url)
            ->chromeFlags([
                '--headless',
                '--no-sandbox'
            ])
            ->setOutput('json')
            ->setOutputPath($path)
            ->run();

        if (!file_exists($path)) {
            throw new \RuntimeException(
                'Unable to locate the Google lighthouse results.'
            );
        }
        $selected = array_filter([
            'performance',
            'accessibility',
            'best-practices',
            'progressive-web-app'
        ], function ($key) use ($opts) {
            return $opts[$key] === true;
        });

        $report_data = $this->findLighthouseScoreReportData(
            $path,
            $selected
        );
        $state = $this->determineLighthouseState($report_data, $opts);

        $this->taskGitHubRepoStatusesCreate($this->getToken())
            ->setAccount($this->getAccount())
            ->setRepository($this->getRepository())
            ->setSha($sha)
            ->setParamState($state)
            ->setParamDescription('Google Lighthouse Tests')
            ->setParamContext('project-x/lighthouse')
            ->run();
    }
public function githubLighthouseStatus($sha, $opts = [
        'hostname' => null,
        'protocol' => 'http',
        'performance' => false,
        'performance-score' => 50,
        'accessibility' => false,
        'accessibility-score' => 50,
        'best-practices' => false,
        'best-practices-score' => 50,
        'progressive-web-app' => false,
        'progressive-web-app-score' => 50,
    ])
    {
        $host = ProjectX::getProjectConfig()
            ->getHost();

        $protocol = $opts['protocol'];
        $hostname = isset($opts['hostname'])
            ? $opts['hostname']
            : (isset($host['name']) ? $host['name'] : 'localhost');

        $url = "$protocol://$hostname";
        $path = new \SplFileInfo("/tmp/projectx-lighthouse-$sha.json");

        $this->taskGoogleLighthouse()
            ->setUrl($url)
            ->chromeFlags([
                '--headless',
                '--no-sandbox'
            ])
            ->setOutput('json')
            ->setOutputPath($path)
            ->run();

        if (!file_exists($path)) {
            throw new \RuntimeException(
                'Unable to locate the Google lighthouse results.'
            );
        }
        $selected = array_filter([
            'performance',
            'accessibility',
            'best-practices',
            'progressive-web-app'
        ], function ($key) use ($opts) {
            return $opts[$key] === true;
        });

        $report_data = $this->findLighthouseScoreReportData(
            $path,
            $selected
        );
        $state = $this->determineLighthouseState($report_data, $opts);

        $this->taskGitHubRepoStatusesCreate($this->getToken())
            ->setAccount($this->getAccount())
            ->setRepository($this->getRepository())
            ->setSha($sha)
            ->setParamState($state)
            ->setParamDescription('Google Lighthouse Tests')
            ->setParamContext('project-x/lighthouse')
            ->run();
    }
public function githubLighthouseStatus ( $ sha , $ opts = [ 'hostname' => null , 'protocol' => 'http' , 'performance' => false , 'performance-score' => 50 , 'accessibility' => false , 'accessibility-score' => 50 , 'best-practices' => false , 'best-practices-score' => 50 , 'progressive-web-app' => false , 'progressive-web-app-score' => 50 , ] ) { $ host = ProjectX :: getProjectConfig ( ) -> getHost ( ) ; $ protocol = $ opts [ 'protocol' ] ; $ hostname = isset ( $ opts [ 'hostname' ] ) ? $ opts [ 'hostname' ] : ( isset ( $ host [ 'name' ] ) ? $ host [ 'name' ] : 'localhost' ) ; $ url = "$protocol://$hostname" ; $ path = new \ SplFileInfo ( "/tmp/projectx-lighthouse-$sha.json" ) ; $ this -> taskGoogleLighthouse ( ) -> setUrl ( $ url ) -> chromeFlags ( [ '--headless' , '--no-sandbox' ] ) -> setOutput ( 'json' ) -> setOutputPath ( $ path ) -> run ( ) ; if ( ! file_exists ( $ path ) ) { throw new \ RuntimeException ( 'Unable to locate the Google lighthouse results.' ) ; } $ selected = array_filter ( [ 'performance' , 'accessibility' , 'best-practices' , 'progressive-web-app' ] , function ( $ key ) use ( $ opts ) { return $ opts [ $ key ] === true ; } ) ; $ report_data = $ this -> findLighthouseScoreReportData ( $ path , $ selected ) ; $ state = $ this -> determineLighthouseState ( $ report_data , $ opts ) ; $ this -> taskGitHubRepoStatusesCreate ( $ this -> getToken ( ) ) -> setAccount ( $ this -> getAccount ( ) ) -> setRepository ( $ this -> getRepository ( ) ) -> setSha ( $ sha ) -> setParamState ( $ state ) -> setParamDescription ( 'Google Lighthouse Tests' ) -> setParamContext ( 'project-x/lighthouse' ) -> run ( ) ; }
GitHub lighthouse status check.

@param string $sha
@param array $opts
@option string $url Set the URL hostname.
@option string $protocol Set the URL protocol http or https.
@option bool $performance Validate performance score.
@option bool $performance-score Set the performance score requirement.
@option bool $accessibility Validate accessibility score.
@option bool $accessibility-score Set the accessibility score requirement.
@option bool $best-practices Validate best-practices score.
@option bool $best-practices-score Set the best-practices score requirement.
@option bool $progressive-web-app Validate progressive-web-app score.
@option bool $progressive-web-app-score Set the progressive-web-app score requirement.
GitHub lighthouse status check .