lighthouse-ci icon indicating copy to clipboard operation
lighthouse-ci copied to clipboard

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

Open adityagautam opened this issue 1 year ago • 2 comments

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 avatar Jul 06 '23 16:07 adityagautam

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

adityagautam avatar Jul 17 '23 16:07 adityagautam