Skip to content

Commit

Permalink
Add GitHub Actions & Lighthouse conf (#1)
Browse files Browse the repository at this point in the history
* Use Lighthouse CI Action
* Configure Asserts in LHCI assertion language
* Add puppeteer script to login into our web app
  • Loading branch information
jonalvarezz committed Jun 6, 2020
1 parent d52f77c commit fe8556b
Show file tree
Hide file tree
Showing 5 changed files with 388 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Flujo automatizada para auditar cada Pull Request con Lighthouse

name: Performance Audit

# Control: Ejecute la acción para cada Pull Request
# Y cada Push a nuestro bello branch de producción
on:
pull_request:
push:
branches:
- todo-lo-bello

jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Install and build
run: |
npm install
npm run build
- name: Audit with lighthouse CI
uses: treosh/lighthouse-ci-action@v2
with:
# Usa nuestra configuracion de Lighthouse CI para correr
# nuestro propio servidor Node y hacer login con Puppeteer.
# Lee más en:
# LHCLI options https://github.com/GoogleChrome/lighthouse-ci/blob/master/docs/cli.md
# treosh/lg-ci-action options https://github.com/marketplace/actions/lighthouse-ci-action
runs: 1
urls: 'http://localhost:3000'
configPath: './.github/workflows/setup/lighthouse-audit.json'
uploadArtifacts: true
28 changes: 28 additions & 0 deletions .github/workflows/setup/lighthouse-audit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"ci": {
"collect": {
"startServerCommand": "npm start",
"startServerReadyPattern": "micro",
"puppeteerScript": "./.github/workflows/setup/puppeteer-login.js",
"settings": {
"disableStorageReset": true
}
},
"assert": {
"assertions": {
"categories:performance": ["error", { "minScore": 0.8 }],
"first-contentful-paint": ["error", { "maxNumericValue": 1000 }],
"interactive": ["error", { "maxNumericValue": 1500 }],
"resource-summary:font:count": ["error", { "maxNumericValue": 1 }],
"resource-summary:script:size": [
"error",
{ "maxNumericValue": 150000 }
],
"resource-summary:stylesheet:size": [
"error",
{ "maxNumericValue": 100000 }
]
}
}
}
}
20 changes: 20 additions & 0 deletions .github/workflows/setup/puppeteer-login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Login to our app
*
* Usa nuestra formulario login y espera
* hasta que un item del carousel salvaje aparezca
* <excited-pikachu.gif>
*
* @param {puppeteer.Browser} browser
* @param {{url: string, options: LHCI.CollectCommand.Options}} context
*/
async function login(browser, { url }) {
const page = await browser.newPage()
await page.goto(`${url}/login`)
await page.type('input[type="email"]', 'mira@que.com')
await page.type('input[type="password"]', 'bello')
await page.click('button')
await page.waitForSelector('.carousel-item')
}

module.exports = login
Loading

0 comments on commit fe8556b

Please sign in to comment.