async function main() {
  core.startGroup('Action config')
  const resultsPath = join(process.cwd(), '.lighthouseci')
  const input = getInput()
  core.info(`Input args: ${JSON.stringify(input, null, '  ')}`)
  core.endGroup() // Action config

  /******************************* 1. COLLECT ***********************************/
  core.startGroup(`Collecting`)
  const collectArgs = [`--numberOfRuns=${input.runs}`]

  if (input.staticDistDir) {
    collectArgs.push(`--static-dist-dir=${input.staticDistDir}`)
  } else if (input.urls) {
    for (const url of input.urls) {
      collectArgs.push(`--url=${url}`)
    }
  }
  // else LHCI will panic with a non-zero exit code...

  if (input.configPath) collectArgs.push(`--config=${input.configPath}`)

  const collectStatus = runChildCommand('collect', collectArgs)
  if (collectStatus !== 0) throw new Error(`LHCI 'collect' has encountered a problem.`)

  core.endGroup() // Collecting

  /******************************* 2. ASSERT ************************************/
  if (input.budgetPath || hasAssertConfig(input.configPath)) {
    core.startGroup(`Asserting`)
    const assertArgs = []

    if (input.budgetPath) {
      assertArgs.push(`--budgetsFile=${input.budgetPath}`)
    } else {
      assertArgs.push(`--config=${input.configPath}`)
    }

    // run lhci with problem matcher
    // https://github.com/actions/toolkit/blob/master/docs/commands.md#problem-matchers
    runChildCommand('assert', assertArgs)
    core.endGroup() // Asserting
  }

  /******************************* 3. UPLOAD ************************************/
  core.startGroup(`Uploading`)

  if (input.serverToken || input.temporaryPublicStorage || input.uploadArtifacts) {
    // upload artifacts as soon as collected
    if (input.uploadArtifacts) {
      await uploadArtifacts(resultsPath, input.artifactName)
    }

    if (input.serverToken || input.temporaryPublicStorage) {
      const uploadParams = []

      if (input.serverToken) {
        uploadParams.push(
          '--target=lhci',
          `--serverBaseUrl=${input.serverBaseUrl}`,
          `--token=${input.serverToken}`,
          '--ignoreDuplicateBuildFailure' // ignore failure on the same commit rerun
        )
      } else if (input.temporaryPublicStorage) {
        uploadParams.push('--target=temporary-public-storage')
      }

      if (input.basicAuthPassword) {
        uploadParams.push(
          `--basicAuth.username=${input.basicAuthUsername}`,
          `--basicAuth.password=${input.basicAuthPassword}`
        )
      }

      if (input.configPath) uploadParams.push(`--config=${input.configPath}`)

      const uploadStatus = runChildCommand('upload', uploadParams)
      if (uploadStatus !== 0) throw new Error(`LHCI 'upload' failed to upload to LHCI server.`)
    }
  }

  // run again for filesystem target
  const uploadStatus = runChildCommand('upload', ['--target=filesystem', `--outputDir=${resultsPath}`])
  if (uploadStatus !== 0) throw new Error(`LHCI 'upload' failed to upload to fylesystem.`)

  core.endGroup() // Uploading

  await setOutput(resultsPath)
  await setAnnotations(resultsPath) // set failing error/warning annotations
}
/**
 * Audit urls with Lighthouse CI in 3 stages:
 * 1. collect (using lhci collect or the custom PSI runner, store results as artifacts)
 * 2. assert (assert results using budgets or LHCI assertions)
 * 3. upload (upload results to LHCI Server, Temporary Public Storage)
 */
Audit urls with Lighthouse CI in 3 stages:
1. collect (using lhci collect or the custom PSI runner, store results as artifacts)
2. assert (assert results using budgets or LHCI assertions)
3. upload (upload results to LHCI Server, Temporary Public Storage)
Audit urls with Lighthouse CI in 3 stages : 1 . collect ( using lhci collect or the custom PSI runner store results as artifacts ) 2 . assert ( assert results using budgets or LHCI assertions ) 3 . upload ( upload results to LHCI Server Temporary Public Storage )
async function main() {
  core.startGroup('Action config')
  const resultsPath = join(process.cwd(), '.lighthouseci')
  const input = getInput()
  core.info(`Input args: ${JSON.stringify(input, null, '  ')}`)
  core.endGroup() 
  core.startGroup(`Collecting`)
  const collectArgs = [`--numberOfRuns=${input.runs}`]
  if (input.staticDistDir) {
    collectArgs.push(`--static-dist-dir=${input.staticDistDir}`)
  } else if (input.urls) {
    for (const url of input.urls) {
      collectArgs.push(`--url=${url}`)
    }
  }
  if (input.configPath) collectArgs.push(`--config=${input.configPath}`)
  const collectStatus = runChildCommand('collect', collectArgs)
  if (collectStatus !== 0) throw new Error(`LHCI 'collect' has encountered a problem.`)
  core.endGroup() 
  if (input.budgetPath || hasAssertConfig(input.configPath)) {
    core.startGroup(`Asserting`)
    const assertArgs = []
    if (input.budgetPath) {
      assertArgs.push(`--budgetsFile=${input.budgetPath}`)
    } else {
      assertArgs.push(`--config=${input.configPath}`)
    }
    runChildCommand('assert', assertArgs)
    core.endGroup() 
  }
  core.startGroup(`Uploading`)
  if (input.serverToken || input.temporaryPublicStorage || input.uploadArtifacts) {
    if (input.uploadArtifacts) {
      await uploadArtifacts(resultsPath, input.artifactName)
    }
    if (input.serverToken || input.temporaryPublicStorage) {
      const uploadParams = []
      if (input.serverToken) {
        uploadParams.push(
          '--target=lhci',
          `--serverBaseUrl=${input.serverBaseUrl}`,
          `--token=${input.serverToken}`,
          '--ignoreDuplicateBuildFailure' 
        )
      } else if (input.temporaryPublicStorage) {
        uploadParams.push('--target=temporary-public-storage')
      }
      if (input.basicAuthPassword) {
        uploadParams.push(
          `--basicAuth.username=${input.basicAuthUsername}`,
          `--basicAuth.password=${input.basicAuthPassword}`
        )
      }
      if (input.configPath) uploadParams.push(`--config=${input.configPath}`)
      const uploadStatus = runChildCommand('upload', uploadParams)
      if (uploadStatus !== 0) throw new Error(`LHCI 'upload' failed to upload to LHCI server.`)
    }
  }
  const uploadStatus = runChildCommand('upload', ['--target=filesystem', `--outputDir=${resultsPath}`])
  if (uploadStatus !== 0) throw new Error(`LHCI 'upload' failed to upload to fylesystem.`)
  core.endGroup() 
  await setOutput(resultsPath)
  await setAnnotations(resultsPath) 
}
async function main ( ) { core . startGroup ( 'Action config' ) const resultsPath = join ( process . cwd ( ) , '.lighthouseci' ) const input = getInput ( ) core . info ( ` ${ JSON . stringify ( input , null , '  ' ) } ` ) core . endGroup ( ) core . startGroup ( ` ` ) const collectArgs = [ ` ${ input . runs } ` ] if ( input . staticDistDir ) { collectArgs . push ( ` ${ input . staticDistDir } ` ) } else if ( input . urls ) { for ( const url of input . urls ) { collectArgs . push ( ` ${ url } ` ) } } if ( input . configPath ) collectArgs . push ( ` ${ input . configPath } ` ) const collectStatus = runChildCommand ( 'collect' , collectArgs ) if ( collectStatus !== 0 ) throw new Error ( ` ` ) core . endGroup ( ) if ( input . budgetPath || hasAssertConfig ( input . configPath ) ) { core . startGroup ( ` ` ) const assertArgs = [ ] if ( input . budgetPath ) { assertArgs . push ( ` ${ input . budgetPath } ` ) } else { assertArgs . push ( ` ${ input . configPath } ` ) } runChildCommand ( 'assert' , assertArgs ) core . endGroup ( ) } core . startGroup ( ` ` ) if ( input . serverToken || input . temporaryPublicStorage || input . uploadArtifacts ) { if ( input . uploadArtifacts ) { await uploadArtifacts ( resultsPath , input . artifactName ) } if ( input . serverToken || input . temporaryPublicStorage ) { const uploadParams = [ ] if ( input . serverToken ) { uploadParams . push ( '--target=lhci' , ` ${ input . serverBaseUrl } ` , ` ${ input . serverToken } ` , '--ignoreDuplicateBuildFailure' ) } else if ( input . temporaryPublicStorage ) { uploadParams . push ( '--target=temporary-public-storage' ) } if ( input . basicAuthPassword ) { uploadParams . push ( ` ${ input . basicAuthUsername } ` , ` ${ input . basicAuthPassword } ` ) } if ( input . configPath ) uploadParams . push ( ` ${ input . configPath } ` ) const uploadStatus = runChildCommand ( 'upload' , uploadParams ) if ( uploadStatus !== 0 ) throw new Error ( ` ` ) } } const uploadStatus = runChildCommand ( 'upload' , [ '--target=filesystem' , ` ${ resultsPath } ` ] ) if ( uploadStatus !== 0 ) throw new Error ( ` ` ) core . endGroup ( ) await setOutput ( resultsPath ) await setAnnotations ( resultsPath ) }
Audit urls with Lighthouse CI in 3 stages:
 1. collect (using lhci collect or the custom PSI runner, store results as artifacts)
 2. assert (assert results using budgets or LHCI assertions)
 3. upload (upload results to LHCI Server, Temporary Public Storage)
Audit urls with Lighthouse CI in 3 stages : 1 . collect ( using lhci collect or the custom PSI runner store results as artifacts ) 2 . assert ( assert results using budgets or LHCI assertions ) 3 . upload ( upload results to LHCI Server Temporary Public Storage )
// Action config /******************************* 1. COLLECT ***********************************/ // else LHCI will panic with a non-zero exit code... // Collecting /******************************* 2. ASSERT ************************************/ // run lhci with problem matcher // https://github.com/actions/toolkit/blob/master/docs/commands.md#problem-matchers // Asserting /******************************* 3. UPLOAD ************************************/ // upload artifacts as soon as collected // ignore failure on the same commit rerun // run again for filesystem target // Uploading // set failing error/warning annotations