Introduction to DevOps
In the rapidly moving and evolving landscape of software development, organizations are constantly seeking ways to improve the quality and stability of the software they produce. One of the biggest revolutions in this field was the advent of DevOps, a software development methodology that integrates the software development team (Dev) and IT operations team (Ops) into a single, cohesive unit. Each of these teams represents domain-specific knowledge critical to the success of a project.
Before DevOps, the Dev team would be responsible for building features and updating code, while the Ops team would be focused on deploying the code, as well as maintaining and monitoring the infrastructure. This separation of responsibilities was often necessary, as each of these roles could be considered a full-time endeavor. As a consequence, we saw reduced visibility across these teams because their interactions were sparse. This reduced visibility made problems harder to diagnose and often caused friction in the software development lifecycle (SDLC).
The marrying of development and operations into a single team works hand-in-hand with the agile development methodology to enable rapid, stable, continuous deployments to Drupal sites. DevOps encompasses everything from developer enablement to continuous integration and continuous delivery (CI/CD), to infrastructure provisioning and maintenance. DevOps places a heavy emphasis on automating the processes used to validate and deploy code. Check out this resource to learn how Bounteous and Acquia eliminate silos and the effort required to maintain the DevOps workflow.
Understanding DevOps for Drupal
When considering DevOps for Drupal, the prime directive is to maintain a stable, bug-free, feature-rich website. A single change to code must go through rigorous review and testing processes to ensure its correctness. You also want to get that code change to production as quickly and consistently as possible. Rapid innovation requires rapid iteration, but rapid iteration can be a dangerous game if not approached properly.
There are a multitude of steps required to achieve stability, each with its own set of challenges and required domain knowledge. We’ll explore these steps individually, but keep in mind that Acquia bundles all of them for you into Code Studio, a powerful CI/CD toolkit that comes with best practices baked in.
One of the most important places desiring consistency is in our environment configurations. There are numerous environments used in Drupal development, including Dev, Test, Live, CI/CD, and local environments. Every server and computer running your code should be using the same tools to run that code. This means using the same versions and configurations of software like Apache, PHP, and MySQL. The closer you can match environments, the more confident you can be that your changes will behave as expected.
Each developer also requires their own development environment where they can freely explore and improve the codebase. These environments also need to match your live environment. Some well-established tools in the community, such as DDEV, make this relatively straightforward, but they will still need some level of manual setup and custom scripting to align to best practices.
With Acquia Cloud IDE, each developer gets their own, cloud-based development environment that is virtually guaranteed to be consistent across developers.
CI: Automating the review process
Rapid iteration starts with continuous integration. CI encompasses the process of taking a code change and making sure it “fits in” with the rest of your codebase. In the case of Drupal, there are a few checks you’ll want to do to ensure code consistency, starting with the build process.
There are a number of third-party packages that drive a Drupal project. Best practices dictate that these third-party dependencies shouldn’t be tracked in your codebase, but instead downloaded during the CI/CD process. This includes the tooling needed to validate and test your codebase. CI processes almost always start with downloading these dependencies to ensure there are no conflicts or errors that would prevent you from completing the CI/CD process.
Once you have your dependencies, you also need to make sure your code follows best practices laid out by the Drupal community coding standards. These standards improve the maintainability of a project in the long term, and they also help prevent common bugs that would require intense investigation to fix. Historically, coding standards were enforced manually by developers, but tools like PHPCS and PHPStan can automate these processes and catch more potential issues than any developer could catch during a manual review.
Finally, you should test all aspects of your project using automated testing tools like Behat, PHPUnit, or Backstop.js. Some of these tools are meant to simulate user behaviors, while others can ensure your code is executing as originally intended. This is where a consistent CI environment comes into play to make sure that the tests can be trusted along every step of the process. Automated testing is key in the rapid development of Drupal sites.
CD: Automating the deployment process
Once your code has been reviewed and tested, you can build it and ship it. The first step in this process is to package your code into a release artifact. This process should exactly match the build process used in your CI pipeline. This includes things like adding third-party dependencies to the codebase and compiling your front–end theme. You’ll also want to “sanitize” the codebase to remove any auxiliary files provided by Drupal, such as the INSTALL.txt file.
Once you have your build artifact, you can deploy it to your development environment for verification. One of the most critical pieces of consistency comes in the form of database management. With the introduction of config management in Drupal 8, an intricate dance formed around best practices for promoting configuration changes between environments. Any time a code deployment is made, you need to run a sequence of config import commands to apply these configuration changes to a Drupal site. Bundling these commands into an automated process reduces the chances of running the commands incorrectly. This is the goal of DevOps: to automate these processes.
AutoDevOps: Streamlining best practices
Many of the tasks in DevOps for Drupal are the same across all Drupal projects. Things like environment setup, config management, and even deployment processes have consistent solutions that can be reused across projects. Wouldn’t it be great if these processes came preconfigured for us? Well, good news, everyone! Acquia tools come with many of these CI/CD tasks preconfigured. This can save hours of setup time and instills best practices into every Drupal project that you run.
Acquia Code Studio
Acquia Code Studio is a SaaS suite of developer tools, optimized for Drupal in partnership with GitLab. From inception to launch, Code Studio provides fully automated tools to plan, build, test, review, and deploy code. This means you no longer need to procure, set up, and maintain tools for issue management, DevOps, and code collaboration. Code Studio offers a fully managed CI/CD pipeline optimized for Drupal. Acquia owns and automates the hard parts of Drupal development so you can stay focused on what's most valuable: innovation.
Acquia Cloud Actions
Cloud Actions is a feature of Cloud Platform that offers customers the ability to perform DevOps tasks easily from within the Cloud Platform UI and automate common tasks when deploying code to Acquia Cloud Next (ACN) environments.
As customers deploy Drupal sites, there are common tasks that must be performed such as running database updates, importing or synchronizing configuration, clearing caches, etc. Cloud Actions helps automate these tasks whenever a code deployment or switch is initiated.
Unleashing your project’s full potential with DevOps
DevOps has been revolutionary to the SDLC and along the way, it has unlocked rapid development with increased stability. The union of development and operations allows ideas to get to market quicker with consistent results. It enables developers to maintain ownership of their code from their local environment all the way to production. This ownership lets developers take pride in their work and ultimately deliver the perfect product.
Acquia makes DevOps easy. From Code Studio to Cloud IDE, the solutions come packed with best practices that bring your projects to their full potential! Check out this resource to learn more about the current DevOps landscape and all the tools that exist out there to help you plan, build, test, review, and deploy your Drupal applications.