Skip to content

smithbr/learning-lighthouse-ci

Repository files navigation

Learning Lighthouse CI from scratch (quickstart)

version

Just one of the things I'm learning. https://github.com/hchiam/learning

Have Lighthouse CI tool run with Travis for every commit or PR to a web app project hosted on GitHub.

Results upon commit

Build Status

Automated test run info here: https://travis-ci.org/hchiam/learning-lighthouse-ci (or click on the badge above)

Example PR here (click "View details"): hchiam/learning-lighthouse-ci#1 (comment)

Setup steps (if you git clone this repo)

  1. To test the web app locally:

    npm install
    npm start

    and in a separate CLI tab:

    npm install -g @lhci/cli@0.3.x
    lhci autorun
  2. To test the web app upon commit/PR:

Setup steps (if you're starting from an empty folder)

  1. For lhci autorun to work, you need a web app set up that has things like a dist or public folder, etc. To do that, you can run a one-liner command to set up a React app:

    # cd to desktop or containing folder
    create-react-app my-app
  2. To make sure it's working locally:

    cd my-app
    npm start

    and in another CLI tab:

    cd my-app
    npm install -g @lhci/cli@0.3.x
    lhci autorun
  3. The key is setting up the Travis file .travis.yml:

    language: node_js
    node_js:
      - 10
    before_install:
      - npm install -g @lhci/cli@0.3.x
    script:
      - npm run build
      - lhci autorun
    addons:
      chrome: stable

Aside

If you want to see a report with more details (e.g. vulnerable libraries -> which specific ones), use a different CLI tool: run lighthouse locally:

npm install -g lighthouse
lighthouse https://airhorner.com/
# lighthouse <url>

Then open the generated html file.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published