Deployable commits
Your primary branch should be deployable at all times. This requires all validation checks (tests, linting, type checking) to pass before a commit makes it into the main branch. This also typically means when changes are merged, they either bring in a set of commits which can each be deployable on their own or are squashed into a single commit. Having this kind of discipline makes it easier to rollback to any point in time, perform a bisect when trying to identify when a bug was introduced, and understand the evolution of the codebase.
Examples
- You enforce branch protection rules so that all pull requests into the main branch require passing tests and a successful build before they're merged. This ensures the main branch is always in a deployable state, enabling quick rollbacks if needed and reducing last-minute issues in production.
- Use feature flags to deploy to production even if the feature isn't fully ready for users. If issues are found in production, you can disable the feature via the flag without needing a rollback.
Share this principle