bgatellier / scodi

A command-line tool to industrialize web quality measurement
MIT License
1 stars 0 forks source link

A command-line tool to industrialize web quality measurement.

npm codecov Known Vulnerabilities

Description

Scodi is a tool that centralize the use of famous web quality measurement services (Google Lighthouse, GreenIT Analysis or Mozilla Observatory) in a unique CLI.

With his modular approach, it makes easy to process the analysis results into a database to track metrics over time, or send them into a communication tool like Slack.

Moreover the command-line interface allows a smooth integration into a CI/CD chain.

Example of use

Exemple scenario:

Manual, with NPM packages

  1. Install the packages

    npm install @scodi/lighthouse @scodi/slack @scodi/mysql
  2. Set the credentials for Slack (API key) and MySQL (database URL)

    echo SCODI_SLACK_ACCESS_TOKEN=xoxb-rest-of-token >> .env
    echo SCODI_MYSQL_DATABASE_URL=login:password@127.0.0.1:3306 >> .env
  3. Create a Slack channel named scodi and a database with the same name.

  4. Start the analysis

    npx scodi lighthouse --config '{"url":"https://www.ipcc.ch/"}'

Once the analysis is over, you will receive a Slack notification to quickly identify what can be improved:

Analyzed URL, overall grade over 100, several metrics like Speed Index, First Contentful Paint and advices for improvements

And the results will be stored in a report table, which you can exploit with tools like Grafana:

Analyzed URL, overall grade over 100, several metrics like Speed Index, First Contentful Paint and advices for improvements

For more options, have a look at the help by using npx scodi -h

Packaged, with the Docker image

Scodi is also available as a Docker image.

With the example scenario given previously, the Docker image is used as follow:

docker run --rm\
    --env SCODI_SLACK_ACCESS_TOKEN=xoxb-rest-of-token\
    --env SCODI_MYSQL_DATABASE_URL=login:password@127.0.0.1:3306\
    fabernovel/heart:latest\
    lighthouse --config '{"url":"https://www.ipcc.ch"}' --only-listeners=mysql,slack

Automated, with the GitHub Action

If you're using GitHub, you can simplify the integration of Scodi in your CI scripts by using the GitHub Action.

With the example scenario given previously, the GitHub Action is used as follow:

- uses: faberNovel/heart-action@v4
  with:
    analysis_service: lighthouse
    listener_services_only: mysql,slack
    mysql_database_url: ${{ secrets.MYSQL_DATABASE_URL }}
    SCODI_SLACK_ACCESS_TOKEN: ${{ secrets.SCODI_SLACK_ACCESS_TOKEN }}

Design

Scodi has been designed to be as light as possible, which explains its modular approach: you only install what you need.

To do so, Scodi is divided in 3 types of packages.

packages types

Type Mission Example
Runner Starts an analysis using the CLI or the HTTP API
Analysis Analyzes URLs using third-party services using GreenIT Analysis
Listener Do thing with the results of the analysis send them into a Slack channel

The minimum setup you need to run Scodi, is to have the Scodi CLI runner module and a single analysis module.

packages list

Name Type Purpose
Scodi API Runner Exposes an HTTP API that starts an analysis when it is requested
Scodi CLI Runner Control the other modules by using a CLI
Scodi GreenIT Analysis Analyzes URLs with GreenIT Analysis
Scodi Lighthouse Analysis Analyzes URLs with Google Lighthouse
Scodi Observatory Analysis Analyzes URLs with Mozilla Observatory
Scodi SSL Labs Server Analysis Analyzes URLs with Qualys SSL Labs Server
Scodi MySQL Listener Stores the results of the analysis into a MySQL database
Scodi Slack Listener Sends the results of the analysis to a Slack channel