Hi everyone! In this video, we're focusing on local hygiene in our automation pipeline by learning how to protect your main branch and catch code errors before they are even committed.
We will start by looking at GitHub branch protection using Rulesets. By setting up strict rules to prevent force pushes, restrict accidental deletions, and require pull requests before merging, we can protect our production code from unexpected breaks.
I will walk you through automating local checks using a framework called pre-commit. We will use pipx on Ubuntu to install it globally, then set up our configuration file to automatically run tools like Ruff for Python and ESLint with Prettier for Vue.js.
By formatting our files and catching syntax issues locally the moment we run a commit, we keep our codebase clean and save a lot of time during code reviews.
Finally, we will test our new hooks in the terminal to see them stop a bad commit, reformat the code, and pass on the second try. We will also take a quick look ahead at our next module, which covers taking this automation to the cloud using Continuous Integration with GitHub Actions!
Useful links:
Course files: https://github.com/ImadSaddik/FullSta...
Source code: https://github.com/ImadSaddik/ImadSad...
Pre-commit: https://github.com/pre-commit/pre-commit
Pipx: https://github.com/pypa/pipx
Don't forget to like, subscribe, and leave a comment if you have any questions or feedback!
⭐️ Contents ⭐️
(00:00) Intro and agenda
(04:34) Protecting the default branch with GitHub Rulesets
(09:37) Understanding Git hooks and pre-commit
(16:03) Installing pipx and pre-commit on Ubuntu
(19:30) Testing the Python pre-commit hooks live
(21:20) Exploring pre-commit for Vue.js with ESLint and Prettier
(26:20) Summary and what's next (CI/CD automation)