In his Drupal 4 Gov webinar Using tools and Git workflow best practices to simplify your local development, Greg Lund-Chaix, a senior infrastructure engineer at Tag1, talks about some of the ways that teams struggle when they become successful and need to learn to scale.
The four rules are intended to help you work faster, with more people, while keeping your team from making mistakes. Greg’s four rules align with git flow, or GitHub flow, distilling those processes down to the essential ideas you should follow, whether you’re a lone developer, or part of a growing team.
All work is done in a branch
The first and most important rule is to never make changes or develop in your main
branch. Always create a feature or issue branch to make changes. Working in branches is a best practice:
- Ensures your
main
branch is clean. - Prevents multiple users from changing the same file, causing a difficult to resolve merge conflict. This also prevents users from affecting each other’s work.
- Prevents bugs from being reintroduced when a user merges their code.
Nobody merges their own code
Merging your own code is one of the most common ways mistakes get made. You get caught up in a task, make a quick fix, and commit it. And then - you miss that critical bracket, comma, or word that causes everything to come crashing down. Building your process to have a second set of eyes can prevent critical mistakes. Ask a colleague to double check your work. It may not matter every time, but when it does matter, it really matters.
Building code reviews into your development process on all levels - coding, testing, and documentation, builds a culture of trust, empowerment, and collaboration between your developers on a team, and your developers and other teams. It’s also a great way to learn from each other, code review will help you become a better developer.
No editing on the servers
Although many platforms prevent direct editing on the server, this is not the case for every organization. You should only make changes on a server using some form of version control. Editing a server directly opens the server to human mistakes like typographical errors, incorrect code versions, or other configuration errors.
Your tools should pull and update code on your server. Using version control and deployment tools ensures accountability, encourages (or even enforces) reviews, and when an outage inevitably occurs there’s a known working checkpoint to roll back to. This can shorten downtime significantly.
Your main
branch is always deployable
Greg says, “Assume that main
could, at any given second, be deployed to the server without warning.” If your entire team follows this rule, continuous integration and continuous deployment is easier and safer.
If you’re in the mindset where committing code (not yours!) triggers a production release, you’re likely to be more mindful and diligent about your quality control practices. You and your team will be more aware of the importance of code reviews. Each member of the team will be more vigilant about correct code.
In cases where you have multiple, dependent branches, take the time to consider the best way to merge all of that code. Merging a group of branches into a single branch, which is in turn merged to main
may be the best choice.
Follow the rules, have a happier site
Following Greg’s four rules goes a long way towards keeping your website running smoothly and helps you to scale up your team. Your development and infrastructure teams will spend less time on outages, reversions, and merge conflicts. You will prevent problems in your codebase, and you’ll have better code quality for the future.
About Drupal 4 Gov
Drupal 4 Gov is an open source community for developers and IT professionals with an interest in making the government more open to open source. This blog was based on Greg’s Drupal 4 Gov presentation.
Drupal 4 Gov encompasses many open source projects but our beginnings are in the Drupal project.
Drupal 4 Gov offers:
- Drupal GovCon - held September 24th - 25th 2020 - virtually
- Gov Summit @ DrupalCon
- Global Training Days/Half Training Days
Tag1 Consulting thanks Drupal 4 Gov for its permission to reshare this presentation.