Lighthouse-ci: autorun not working with --no-lighthouserc

Created on 12 May 2020  Ā·  6Comments  Ā·  Source: GoogleChrome/lighthouse-ci

Documentation
--no-lighthouserc Disables automatic usage of a .lighthouserc file.

Running

npx lhci --no-lighthouserc autorun

Configuration file not found
Error: Unable to determine `staticDistDir`; 
Set it explicitly in lighthouserc.json

Having errors for not finding .lighthouserc is not what I expect when using --no-lighthouserc

P1 bug

All 6 comments

What behavior did you expect based on the documentation?

You've told LHCI you don't want it to find a configuration file automatically and then you didn't provide one manually or specify one of the mandatory flags. There's nothing else we can do but fail in that case.

  1. No mandatory flags are mentioned in the documentation for autorun
  2. I can figure that I need to provide an url for collect, so Iā€˜d expect an error for not providing an url

This leads to the next problem

  1. works
lhci collect --url https://www.google.com/
Run #1...done.
…
Done running Lighthouse!
  1. fails
npx lhci autorun --collect.url https://www.google.com/
Run #1...failed!
…
Runtime error encountered: The URL you have provided appears to be invalid.

In general what I am trying to do is use autorun for what I have successfully been using a shell script so far:

#!/bin/bash
npx lhci collect --url https://www.google.de
npx lhci assert --preset lighthouse:recommended
npx lhci upload --token …

I was missing the = sign.
This is working
lhci autorun --collect.url=https://www.google.com/ --assert.preset=lighthouse:recommended --upload.token …

No mandatory flags are mentioned in the documentation for autorun

There aren't any for autorun but autorun just runs the other commands and the other commands have mandatory arguments. If we can't infer anything about the build they must be provided.

Glad you figured it out!

I ran into this as well: it appears that --no-lighthouserc doesn't work with lhci autorun as it does with the other commands like lhci collect. On the other hand LHCI_NO_LIGHTHOUSERC does seem to be honored:

# Option works with collect, conf file ignored:
$ lhci --no-lighthouserc collect --url=http://localhost
Running Lighthouse 3 time(s) on http://localhost
Run #1...
...
# Environment variable works with collect, conf file ignored:
$ LHCI_NO_LIGHTHOUSERC=1 lhci collect --url=http://localhost
Running Lighthouse 3 time(s) on http://localhost
Run #1...
...
# Option ignored with autorun, conf file is loaded:
$ lhci --no-lighthouserc autorun --collect.url=http://localhost
āœ…  .lighthouseci/ directory writable
āœ…  Configuration file found
...
# Environment variable works with autorun, conf file ignored:
 $ LHCI_NO_LIGHTHOUSERC=1 lhci autorun --collect.url=http://localhost
āœ…  .lighthouseci/ directory writable
āš ļø   Configuration file not found

I guess this is because the subcommands get options passed down that have the appropriate prefix, but that doesn't seem to work here:

$ lhci --collect.no-lighthouserc autorun --url=http://localhost
lhci <command> <options>
...

  --no-lighthouserc  Disables automatic usage of a .lighthouserc file.                                                                                                   

Not enough non-option arguments: got 0, need at least 1

The docs as well as the usage text both suggest that plain --no-lighthouserc should work with the autorun command.

Thanks for the additional detail @chosak a separate issue from what the OP was running into, but more similar to the title anyway šŸ˜†

We need to forward --no-lighthouserc to the child commands šŸ‘

I guess this is because the subcommands get options passed down that have the appropriate prefix, but that doesn't seem to work here:

I would expect lhci autorun --collect.no-lighthouserc --collect.url=http://localhost to work and force collect to ignore the configuration but no other subcommands

Was this page helpful?
0 / 5 - 0 ratings