etalab / transport-validator

GTFS validator
https://transport.data.gouv.fr/validation/
MIT License
38 stars 10 forks source link

non-zero exit code if checking failed when using --input #198

Open stuebinm opened 6 months ago

stuebinm commented 6 months ago

It would be nice if the validator returned a non-zero exit code when used on the cli with the --input option, either optionally behind a cli flag (e.g. --exit-code) or simply by default if --input is used. Perhaps it would even be possible to use different exit codes depending on severity of warnings or errors found (e.g. code 1 for fatal errors, 2 if there were no fatal errors but some warnings, etc.).

My motivation for this is that it'd make it much easier to use the tool in scripts or CI pipelines; currently the easiest way to answer "did validation fail?" i can find is to parse the json output with jq and check the validations (or issues_count) keys directly.

antoine-de commented 6 months ago

yep, seems a good use case :+1:

Maybe we can add flags like a --fail-on-errors/--fail-on-warnings? wouldn't it be easier for your CI use case?

stuebinm commented 6 months ago

hm, that would of course also be an option — though it'd also make it harder to have a three-way split in e.g. a shell script (e.g. "do $x when everything's fine, $y if there were warnings, $z if there were errors).

but really i don't have a strong opinion either way, I can work with both :)