Bug 1754241: ./mach lint now raises exception on no-op in CI r=ahal

If there's no files to lint in CI, that's a smell that something is
misconfigured.

Resolve this by raising an exception accordingly if `MOZ_AUTOMATION` is
set (and we aren't running the tests for the linting code itself).
Automatically recommend specifying `*`, as (assuming the use of a
shell) that will resolve to "all files/dirs at $topsrcdir`", which
matches existing behaviour if `--outgoing` and `--workdir` aren't
provided.

Differential Revision: https://phabricator.services.mozilla.com/D138172
This commit is contained in:
Mitchell Hentges 2022-02-10 16:22:06 +00:00
parent 11b1dc9d1f
commit cb97199fe0

View File

@ -337,6 +337,14 @@ class LintRoller(object):
print(e.output)
if not (paths or vcs_paths) and (workdir or outgoing):
if os.environ.get("MOZ_AUTOMATION") and not os.environ.get(
"PYTEST_CURRENT_TEST"
):
raise Exception(
"Despite being a CI lint job, no files were linted. Is the task "
"missing explicit paths?"
)
print("warning: no files linted")
return self.result