lhci/README.md
Robert Kaussow e2fa1bf9df
All checks were successful
continuous-integration/drone/push Build is passing
chore: replace master by main as default branch
2020-12-30 16:31:39 +01:00

92 lines
2.9 KiB
Markdown

# lhci
Custom image for lighthouse-ci
[![Build Status](https://img.shields.io/drone/build/docker/lhci?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/docker/lhci)
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/lhci)
[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/lhci)
[![Source: Gitea](https://img.shields.io/badge/source-gitea-blue.svg?logo=gitea&logoColor=white)](https://gitea.rknet.org/docker/lhci)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/docker/lhci/src/branch/main/LICENSE)
Custom wrapper Docker image for [lighthouse-ci](https://github.com/GoogleChrome/lighthouse-ci).
## Usage
There are two wrapper scripts around the lhci command you could use:
- `/usr/bin/lhci-official`: This will simply forward your command to the official binary at `/usr/local/bin/lhci`
- `/usr/bin/lhci`: This is a modified wrapper to post-process the created report file to prepare an upload.
The wrapper `/usr/bin/lhci` will do the following:
- create `DIST=$LHCI_BASE_DIR/$UPLOAD_OUTPUT_DIR/dist/`
- find all files flagged with `isRepresentativeRun` in the `manifest.json`
- copy those files to `$DIST`
To get it working you need to configure the `fileupload` in `.lighthouserc.yml`command line configuration will not work:
```Yaml
---
ci:
[...]
upload:
target: filesystem
# has to be a relative path to the .lighthouserc.yml location
outputDir: lhci_reports
```
What you will get is the following file structure which could be used as an upload source:
```Shell
lhci_reports/dist/
├── 9cf658e2-202007160745.html
├── f33fa4c4-202007160745.html
└── ffae8d3e-202007160745.html
# <FILENAME_HASH>-<DATETIME>.html
```
You will also get the target URLs in your CI output:
```Shell
/usr/bin/lhci autorun
[...]
All results processed!
Dumping 6 reports to disk at /drone/src/lhci_reports...
Done writing reports to disk.
Done running autorun.
Post-process report files...
Report for http://localhost:43901/ will be uploaded to https://example.com/9cf658e2-202007160745.html
Report for http://localhost:43901/404.html will be uploaded to https://example.com/ffae8d3e-202007160745.html
Report for http://localhost:43901/posts/ will be uploaded to https://example.com/f33fa4c4-202007160745.html
```
```Shell
docker run -v $(pwd)/public:/drone/src lhci autorun
# or pass arguments to lhci
docker run -v $(pwd)/public:/drone/src lhci autorun --upload.target=temporary-public-storage
```
## Environment variables
```Shell
LHCI_BASE_DIR="/drone/src"
LHCI_SERVER_URL="https://example.com/"
```
## Build
```Shell
docker build -t lhci:latest .
```
## License
This project is licensed under the MIT License - see the [LICENSE](https://gitea.rknet.org/docker/lhci/src/branch/main/LICENSE) file for details.