Greg Lund-Chaix, Senior Infrastructure Engineer at Tag1, hosted a webinar for Drupal 4 Gov to teach users how to simplify their development workflows by using local development environments. His talk shows you some common tools, his four rules for development, and some basic techniques to help you use Git effectively to improve your processes and enhance your approach to development.

Drupal 4 Gov best practices

In his talk, Greg discusses the following tools and what makes them useful to you:

He also walks you through the installation of DDEV, to help you understand how easy it can be to set up a local development environment. These tools assist with automated environment creation and more, with included developer tools (MySQL, Composer, Drush, and so on) to make it easy for you to get to work. Tools like DDEV and Lando ensure your local environment matches your production environment, preventing long troubleshooting sessions when something works locally, but not on production.

The four rules

Next, Greg talks about his four rules for development, and why they save time:

  1. Work in a branch.
  2. Don’t merge your own code.
  3. Never edit on the server(s).
  4. Your ‘main’ branch is always deployable.

These four rules ensure you make fewer mistakes that could introduce bugs, or even cause outages due to bad code. Branches ensure you’re not editing on the server, and that your code changes are contained. Requiring others to review your code before a merge helps ensure fewer mistakes make it through, and help you become a better developer. These help keep your ‘main’ branch deployable at all times, so you’ve always got a working code base.

Git basics

Finally, Greg shows off some basic Git techniques. Many of these are common to experienced developers, but not as well known by others. They will help you develop more quickly, with fewer mistakes.

  1. Rebase often.
  2. Set up a helpful git-prompt.
  3. Used narrowly focused branches.
  4. Push & pull regularly to avoid merge conflicts.
  5. Learn the differences between git merge and git pull --rebase including never merging your own code.
  6. Sniff and lint your code before committing.

Each of these practices ensure that fewer mistakes ever make it to the ‘main’ branch. Understanding merging and rebasing, and when to use them ensures your team never overwrites each other’s work. Focused branches ensure it’s clear why and where you made changes. Regular pushes and pulls keep your entire team’s branches up to date.

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.

It encompasses many open source projects but their 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.

Photo by sergio souza on Unsplash