Last active
February 7, 2020 13:18
-
-
Save patrickhulce/ffe0f4a7eb0ead4da982c955b7fa6c49 to your computer and use it in GitHub Desktop.
Lighthouse CI Get Diffs For Hashes (DISCLAIMER: untested)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ApiClient = require('@lhci/utils/src/api-client') | |
const {findAuditDiffs} = require('@lhci/utils/src/audit-diff-finder') | |
const client = new ApiClient({rootURL: 'http://lhci-server.example.com'}) | |
const PROJECT_ID = '<UUID of project>' | |
async function getLHR(hash, url) { | |
const [build] = await client.getBuilds(PROJECT_ID, {hash}) | |
const [run] = await client.getRuns(PROJECT_ID, build.id, {representative: true, url}) | |
return JSON.parse(run.lhr) | |
} | |
async function findDiffs(hashA, hashB, url) { | |
const lhrA = await getLHR(hashA, url) | |
const lhrB = await getLHR(hashB, url) | |
const diffs = [] | |
for (const auditId of Object.keys(lhrA.audits)) { | |
diffs.push(findAuditDiffs(lhrA.audits[auditId], lhrB.audits[auditId])) | |
} | |
return diffs | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this is pretty close to done now, the results out of this is a pretty good list of entries that have been impacted, and we only show entries with
numericValue
type. Maybe we can add a list of audits that are 'key' to give feedback, such asfirst-cpu-idle
as extra options for thefindDiffs
function 🤔, cause even filtering out a lot of the entries by narrowing down tonumericValue
ones only, we still have quite a number of entries 😁.