sbdchd / squawk

🐘 linter for PostgreSQL, focused on migrations
https://squawkhq.com
GNU General Public License v3.0
594 stars 40 forks source link

Missing an option to add an exit code for when `squawk upload-to-github` reports errors #326

Closed wmartins closed 9 months ago

wmartins commented 9 months ago

Hi there! I'm currently integrating Squawk with our GitHub Actions workflow. I really like the report generated by squawk upload-to-github, however, I've missed an option to configure it to fail the execution (exitting with code 1, for example) when Squawk reports errors on my migrations.

It's important for me to be able to fail the execution when there are errors because we don't want to merge migrations that violate the rules that we have configured, and currently squawk upload-to-github doesn't give me that.

The current workaround is using the regular squawk command, which fails the execution but doesn't produce that nice report as a comment.

Suggestion 1

I think a simple way to get this done would be adding a new option to squawk upload-to-github, for example, --exit-on-error, which by default would be false (so it's backwards compatible). This way, if --exit-on-error is passed and Squawk reports an error, the execution fails with exit code 1 (or any other code that makes more sense).

Suggestion 2

Another option, which seems way more complicated, would be making squawk generate some kind of report file, which could be used by upload-to-github. Then, I'd be able to capture the original exit code and upload to github at the same time.


If you need more info about this let me know, I'm not too versed in Rust, but I could try implementing suggestion 1 if that makes sense.

Thank you!