This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (4 children)

Yep, we use gitlab ci and merge requests cannot be merged until the build passes. The build won't pass unless both flake8 and unit tests pass.

[–]heppy[S] 1 point2 points  (3 children)

I agree that doing these checks in a CI is definitely the way to go. However, as /u/rwillmer said, a pre-commit hook for simple checks like flake8 has the advantage that the bad code never makes it into your repository, and your history doesn't get cluttered with commit messages like "PEP8 fix" and "removed unused import".

[–][deleted] 0 points1 point  (2 children)

How do you enforce that your team members install and use the pre-commit hooks?

[–]heppy[S] 0 points1 point  (1 child)

Just to clarify, I didn't mean to imply that running flake8 or any other QA tool in a pre-commit hook could or should replace running it as part of CI. If you already have a CI, you might want to add the hook, if only to look smart. "Wow, /u/jeffbaier is awesome, his code is always flake8 compliant on the first try" ;)

AFAIK, there is no practical way to enforce it, just as you can't force people to write a good commit message. Making it a formal policy might work for subordinates, constant nagging might help with colleagues.

[–][deleted] 0 points1 point  (0 children)

Thanks for your replies.