-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to provide custom LHCI config #22
base: main
Are you sure you want to change the base?
Conversation
fc3ed3d
to
386ebb6
Compare
386ebb6
to
7a96715
Compare
entrypoint.sh
Outdated
@@ -195,6 +196,11 @@ ci: | |||
aggregationMethod: median-run | |||
EOF | |||
|
|||
# Merge custom Lighthouse CI config, if provided | |||
if [[ -f ".github/lighthouserc-custom.yml" ]]; then | |||
yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' lighthouserc.yml .github/lighthouserc-custom.yml -i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd just use .lighthouserc.yml
as default since that's the default for LHCI. Probably better for us to handle this complexity. Would make our code slightly more complicated, but we're taking that complexity away from the devs.
Maybe something like:
default_config="$(mktemp XXXXX.yml)"
cat <<- EOF > $default_config
...
EOF
if [[ -f ".lighthouserc.yml" ]]; then
yq eval-all '...' $default_config .lighthouserc.yml > .lighthouserc.yml.tmp
mv .lighthouserc.yml.tmp .lighthouserc.yml
else
mv $default_config .lighthouserc.yml
else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better!
I'd just make sure that it's clearly explained in the README that it doesn't have to be the complete config.
I think that's OK. If you're overwriting them, then it's really on you :P. I think we can fix that with some kind of "Advanced Usage" docs that shows the default configuration and how you can change that. |
The default path to the custom LHCI config is .lighthouserc.yml, but it can be customized. The custom config will be merged with the default one.
7a96715
to
8de9640
Compare
@charlespwd I've just pushed an updated version. One thing that I found a bit confusing is the default value for inputs in Anyway, while working on it, I realized that one can overwrite any LHCI configuration setting with environment variables, so it's already possible to modify the default jobs:
lhci:
name: Lighthouse
runs-on: ubuntu-latest
steps:
- name: Lighthouse
...
env:
LHCI_UPLOAD__TARGET: lhci
LHCI_UPLOAD__SERVER_BASE_URL: ...
LHCI_UPLOAD__TOKEN: ...
LHCI_UPLOAD__BASIC_AUTH__USERNAME: ...
LHCI_UPLOAD__BASIC_AUTH__PASSWORD: ... Maybe it's not very convenient, but possible. |
This PR introduces changes that allow one to provide a partial custom LHCI config that gets merged with the default one provided in
entrypoint.sh
file and fixes #20.It's a bit of a wip, but I wanted to get some feedback first. Things that are missing:
.lighthouserc.yml
)README.md
fileDockerfile
to use the updated base image, once it's publishedIt's also possible to overwrite some of the other inputs (e.g. LHCI scores) with this config, which might be a bit confusing.
I tested it with
act
and it works. I also pushed the new base Docker image that includesyq
toszimek/lighthouse-ci-action:1.1.0
.