Commit c767458a authored by Protocole's avatar Protocole
Browse files

Merge branch '298-lighthouse-update-0-2-0' into 'latest'

Resolve "Lighthouse update 0.2.0"

Closes #298

See merge request r2devops/hub!157
parents 344d9dfb 04ac7b7e
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -13,22 +13,26 @@ This job analyzes a remote website (or a local web service) and gives you a repo
    include:
      - remote: 'https://jobs.r2devops.io/lighthouse.yml'
    ```
2. Choose a target

    !!! note
        This job can be run on external services or by running a container
        instance of your website. **You need to choose between two following
        options**.
2. Choose a target

    * Option 1: external service
    !!! tip "Plug and play available !"
      This job is **plug and play** 🚀, see the Option 1.<br/>
      Other options need some configuration.<br/><br/>
      **Using one of these option is mandatory to job success**

    Add the site IP or the domain name of the service in `LIGHTHOUSE_TARGET` variable
    (see [jobs customization](http://localhost:8000/use-the-hub/#jobs-customization))
    ??? summary "Option 1: Choose the **plug and play** 🚀 mode"
      😎 You have nothing to do, you can go to the next step.<br/><br/>If you are using one of hub building job to build a static website, **prefer to choose this option.**<br/>
      Your static website will be directly used by lighthouse !
      <br/><br/>*In case you updated the artifact path in your building job, don't forget to update `PAGES_PATH` variable.*

    *  Option 2: container instance
    ??? summary "Option 2: Plug manually your external website"
      Add the site IP or the domain name of the service to check in `LIGHTHOUSE_TARGET` variable
      (see [jobs customization](/use-the-hub/#jobs-customization))

    ??? summary "Option 3: Plug manually your container instance"
      Add the target container instance as a service (see
    [Container instance as Service](/use-the-hub/#container-instance-as-service)) and
      [Container instance as Service](/use-the-hub/#advanced-services)) and
      set variable `LIGHTHOUSE_TARGET` as the name of your container.

3. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
@@ -52,6 +56,7 @@ This job analyzes a remote website (or a local web service) and gives you a repo
| `OUTPUT_FORMAT` | Format of report file (`json`, `csv`, `html`) | `html` |
| `OUTPUT_LOCALE` | Language of report file | `en` |
| `ADDITIONAL_OPTIONS` | Variable to add custom options (see [options](https://github.com/GoogleChrome/lighthouse#cli-options){:target="_blank"}) | ` ` |
| `PAGES_PATH` | Path of your static website (not used if `LIGHTHOUSE_TARGET` is filled) | `website_build/` |

### Audit configuration

+1 −1
Original line number Diff line number Diff line
name: lighthouse
description: A simple job to do various tests on a site using Google Lighthouse
description: A simple job to do various tests on a website using Google Lighthouse
default_stage: dynamic_tests
icon: 🗽
maintainer: Protocole
+16 −4
Original line number Diff line number Diff line
@@ -5,16 +5,28 @@ lighthouse:
  image: justinribeiro/lighthouse
  stage: dynamic_tests
  variables:
    LIGHTHOUSE_TARGET: "https://go2scale.io"
    LIGHTHOUSE_TARGET: ""
    OUTPUT_NAME: "lighthouse"
    OUTPUT_FORMAT: "html"
    OUTPUT_LOCALE: "en"
    ADDITIONAL_OPTIONS: ""
    PAGES_PATH: "website_build/"
  script:
    # Put in full lowercase OUTPUT_FORMAT to avoid problems
    - export OUTPUT_FORMAT=$(echo ${OUTPUT_FORMAT} | tr '[:upper:]' '[:lower:]')
    - export ADDITIONAL_OPTIONS="--output ${OUTPUT_FORMAT} --output-path ./${OUTPUT_NAME}.${OUTPUT_FORMAT} ${ADDITIONAL_OPTIONS}"
    - export ADDITIONAL_OPTIONS="--output ${OUTPUT_FORMAT} --output-path ${OUTPUT_NAME}.${OUTPUT_FORMAT} ${ADDITIONAL_OPTIONS}"
    - export ADDITIONAL_OPTIONS="--locale ${OUTPUT_LOCALE} ${ADDITIONAL_OPTIONS}"
    - |
      if [ -z ${LIGHTHOUSE_TARGET} ]; then
        if [ ! -d ${PAGES_PATH} ]; then
          echo "[ERROR] Variable LIGHTHOUSE_TARGET must be filled, see https://r2devops.io/jobs/dynamic_tests/lighthouse/"
          exit 1
        fi

        npm install serve
        npx serve ${PAGES_PATH} &
        export LIGHTHOUSE_TARGET="http://localhost:5000"
      fi
    - lighthouse ${ADDITIONAL_OPTIONS} --chrome-flags="--headless --disable-gpu" ${LIGHTHOUSE_TARGET}
  artifacts:
    paths:
+3 −0
Original line number Diff line number Diff line
* Remove `LIGHTHOUSE_TARGET` default value
* The pipeline will now fail if no target is defined
* New feature to run the job without any configuration
 No newline at end of file