Awesome
Lighthouse CI Compare Action
This action helps you to based on the results of running Lighthouse CI, compare the current results with the ancestor commit results.
This comparison can be used to create a Markdown table and a comment on the pull request.
Getting started
Prerequisites
- You need to have a Lighthouse CI server running.
- You need to have a Lighthouse CI project created.
- You need to have a
links.json
file generated by Lighthouse CI (this action needs to run after the Lighthouse CI action).
Usage
- name: Lighthouse CI Compare
uses: adevinta/actions-lighthouseci-compare@v1
with:
links-filepath: '.lighthouseci/links.json'
base-url: 'https://your-lhci-server.com/v1'
project-id: 'your-project-id'
current-commit-sha:
${{ github.event_name == 'pull_request' &&
github.event.pull_request.head.sha || github.sha }}
should-build-fail: true
current-commit-sha
: If you are in a Pull Request, you need thegithub.event.pull_request.head.sha
to compare with the commit from which your branch came from, otherwise you can usegithub.sha
.
Inputs
links-filepath
- Description: The location of the links.json file generated by Lighthouse CI.
- Required: Yes
- Default:
.lighthouseci/links.json
base-url
- Description: The base URL of your Lighthouse CI server, for example
https://your-lhci-server.com/v1
. - Required: Yes
project-id
- Description: The project ID of your Lighthouse CI project. This is a GUID.
- Required: Yes
current-commit-sha
- Description: The current commit SHA.
- Required: Yes
should-fail-build
- Description: If the action should fail if it crashes.
- Required: No
- Default:
false
Outputs
markdown
This is a Markdown table with the results of the comparison.
The table looks like this:
<!-- markdownlint-disable -->comparedMetrics
This is the object used to create the table. You can use this output to create your own results or programmatically in a different script.
The object looks like the following:
{
/classified/latest/12:
{ performance:{currentValue:73,previousValue:75,diff:-2,isRegression:true},
lcp:{currentValue:1181,previousValue:1061,diff:120,isRegression:true},
cls:{currentValue:0.002,previousValue:0.002,diff:0,isRegression:false},
tbt:{currentValue:1803,previousValue:1456,diff:347,isRegression:true}},
/_maison_jardin_/offres:
{ performance:{currentValue:68,previousValue:71,diff:-3,isRegression:true},
lcp:{currentValue:2045,previousValue:1513,diff:532,isRegression:true},
cls:{currentValue:0.048,previousValue:0.048,diff:0,isRegression:false},
tbt:{currentValue:2518,previousValue:2260,diff:258,isRegression:true}},
/:
{ performance:{currentValue:72,previousValue:72,diff:0,isRegression:false},
lcp:{currentValue:1338,previousValue:1228,diff:110,isRegression:true},
cls:{currentValue:0.059,previousValue:0.059,diff:0,isRegression:false},
tbt:{currentValue:1747,previousValue:1789,diff:-42,isRegression:false}}}
Which includes the URL as the key and the metrics as the value.
status
Tells if the action has failed or not. We are handling this output because there are reasons why this could fail and you might not want to continue the build anyway.
You can also use the directive continue-on-error
in your workflow to continue
even if this fails, but with this we provide you a way to know if the action has
failed too.
See the FAQ section for more information.
failureReason
This is the reason why the action has failed. Is a print of the error message.
FAQ
My build is failing, what can I do?
Known reasons for failure:
- Build doesn't have an ancestor. This might happen if you don't have properly
configured the
LHCI_BUILD_CONTEXT__ANCESTOR_HASH
in yourlhci autorun
. - The links.json file is not found. This can happen if you are re-running this action manually. If you re-run a job and is the same commit of a previous run, Lighthouse CI will not generate the links.json file again.