Skip to content

Instantly share code, notes, and snippets.

@stevenpetryk
Created June 19, 2019 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenpetryk/671e114a8bbd6d877677dd986cef4f2d to your computer and use it in GitHub Desktop.
Save stevenpetryk/671e114a8bbd6d877677dd986cef4f2d to your computer and use it in GitHub Desktop.
Lighthouse automation
workflows:
version: 2
lighthouse-hourly:
jobs:
- lighthouse
triggers:
- schedule:
cron: '0 * * * *'
filters:
branches:
only:
- master
const pagePaths = [/* ... */]
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage()
for (const pagePath of pagePaths) {
await page.goto(`https://intercom.com${pagePath}`)
const { lhr, report } = await lighthouse(url, {
port: new URL(browser.wsEndpoint()).port,
output: 'html',
})
const accessibilityScore = lhr.categories.accessibility.score * 100
const bestPracticesScore = lhr.categories['best-practices'].score * 100
const performanceScore = lhr.categories.performance.score * 100
const seoScore = lhr.categories.seo.score * 100
metrics.gauge('accessibility', accessibilityScore, [`path:${pagePath}`], sharedTimestamp)
metrics.gauge('best_practices', bestPracticesScore, [`path:${pagePath}`], sharedTimestamp)
metrics.gauge('performance', performanceScore, [`path:${pagePath}`], sharedTimestamp)
metrics.gauge('seo', seoScore, [`path:${pagePath}`], sharedTimestamp)
// and `report` will contain your full HTML report!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment