Skip to content

Commit

Permalink
#41 extend output with links and assertionResults
Browse files Browse the repository at this point in the history
  • Loading branch information
alekseykulikov committed May 25, 2020
1 parent 4f84d83 commit b2e4263
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Lighthouse CI Action'
description: 'Audit URLs using Lighthouse and test performance with Lighthouse CI.'
description: 'Audit URLs using Lighthouse and test performance with Lighthouse CI'
inputs:
urls:
description: 'List of URL(s) to analyze'
Expand All @@ -19,7 +19,11 @@ inputs:
description: 'API token to push to LHCI server'
outputs:
resultsPath:
description: 'Path to the folder with results'
description: 'Path to the folder with LHCI results'
links:
description: 'Links to compare/result UI for each URL (content of links.json)'
assertionResults:
description: 'Assertion results (content of assertion-results.json)'
runs:
using: 'node12'
main: 'src/index.js'
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const lhciCliPath = require.resolve('@lhci/cli/src/cli')
const { getInput, hasAssertConfig } = require('./config')
const { uploadArtifacts } = require('./utils/artifacts')
const { setAnnotations } = require('./utils/annotations')
const { setOutput } = require('./utils/output')

/**
* Audit urls with Lighthouse CI in 3 stages:
Expand Down Expand Up @@ -88,7 +89,7 @@ async function main() {
core.endGroup() // Uploading
}

// await setOutput(resultsPath)
await setOutput(resultsPath)
await setAnnotations(resultsPath) // set failing error/warning annotations
}

Expand Down
22 changes: 22 additions & 0 deletions src/utils/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const core = require('@actions/core')
const { getLinks, getAssertionResults } = require('./lhci-helpers')

/**
* Set output: {
* resultsPath: string
* links: Object<url,url> (links.json)
* assertionResults: LhciAssertion[] (assertion-results.json)
* reports: LhciReportSummary[] (waiting https://github.com/GoogleChrome/lighthouse-ci/issues/142)
* }
*
* @param {string} resultsPath
*/

exports.setOutput = async function setOutput(resultsPath) {
const links = await getLinks(resultsPath)
const assertionResults = await getAssertionResults(resultsPath)

core.setOutput('resultsPath', resultsPath)
core.setOutput('links', links ? JSON.stringify(links) : '')
core.setOutput('assertionResults', assertionResults ? JSON.stringify(assertionResults) : '')
}

0 comments on commit b2e4263

Please sign in to comment.