GoogleChrome / lighthouse-ci

Automate running Lighthouse for every commit, viewing the changes, and preventing regressions
Apache License 2.0
6.34k stars 635 forks source link

gitHubApiHost is not honoring the value specified in lighthouserc.js file and still taking the default value - LHCI version 0.12.0 #922

Open adityagautam opened 1 year ago

adityagautam commented 1 year ago

Describe the bug Custom value defined in upload object for gitHubApiHost in lighthouserc.js file is not being honored. It is still taking the default gitHubApiHost value defined here ( https://github.com/GoogleChrome/lighthouse-ci/blob/main/packages/cli/src/upload/upload.js#L40).

Error am getting while trying to set github status is GitHub responded with 401 {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}

The reason am certain is because of the documentation url in the error response. As am using the git enterprise host api, if the credentials is invalid I get a different documentation_url in error response. The documentation url above is coming from api.github.com which is default value.

Also for context am running the setup inside a docker container in jenkins.

My lighthouserc file.

module.exports = {
  ci: {
    collect: {
      url: ['https://x.x.x.x'],
      numberOfRuns: 3,
      disableStorageReset: true,
      headful: false,
      settings: {
        disableStorageReset: true,
        preset: 'desktop',
        throttlingMethod: 'provided', // No throttling
        onlyCategories: [
          'performance',
          'accessibility',
          'pwa',
        ],
      },
      puppeteerLaunchOptions: {
        headless: 'new',
        disableStorageReset: true,
        defaultViewport: null,
        args: ['--no-sandbox', '--disable-setuid-sandbox'],
      },
      puppeteerScript: 'login.js', // Run this script before auditing above URLs'. Usually Login Scripts.
      maxWaitForLoad: 90000,
      // disableFullPageScreenshot: true, // Disable full page screenshot, to save disk space.
    },
    upload: {
      target: 'lhci',
      token: 'xxxxxxxxxxx',
      serverBaseUrl: 'http://x.x.x.x/',
      gitHubApiHost: 'https://git.corp.company_name.com/api/v3',
      gitHubToken: 'xxxxxxxx', 
      ignoreDuplicateBuildFailure: true, // Ignore duplicate build failure.
    },
    assert: {
      // preset: 'lighthouse:recommended',
      assertions: {
        'first-contentful-paint': [
          'warn', // options: 'off', 'warn', 'error'
          { maxNumericValue: 2000, aggregationMethod: 'optimistic' },
        ],
      },
    },
    wizard: {
      serverBaseUrl: 'http://x.x.x.x/',
    },
    server: {
    },
  },
};

I have also tried passing giHubApiHost value like this but same result. Can someone let me know how to fix this? lhci autorun --upload.gitHubApiHost=https://git.corp.company_name.com/api/v3

LHCI version: 0.12.0

adityagautam commented 1 year ago

@patrickhulce Any help/hints here will be appreciated. Do I need to export gitHubApiHost value before starting the lighthouse test?