Code Studio and Site Factory: Best Practices

  • 3 minute read

I recently wrote about basic architectural structures for multisite codebases in CI/CD tools, such as Acquia Code Studio. Taking this a step further, this post covers the best practices for setting up a Site Factory codebase in Code Studio. If you want to get started, also check out our tutorial and our setup instructions on docs.acquia.com!

Remember, many of the “best practices” for integrating Site Factory and a CI/CD solution, are in fact best practices for those products separately. 

Site Factory Best Practices

  • Automate deployment stages with factory hooks. This allows you to run database updates, import configuration, flush caches, etc. 
  • Establish a configuration management strategy that not only takes different environments, for example, dev, stage, or prod, but also different sites. Remember, key things such as site name, contact email, etc. will always be different between sites.
  • Simulate all deployments into your test environment prior to production deployment by first staging down your sites, and then deploying your new tag from dev. This will ensure that you are getting the most current database(s) and code. Usually if a deployment passes or fails in your test environment, it will do the same in your production environment as well.
  • Establish a governance system for your multisite to ensure that your features and architecture do not suffer from issues such as scope creep, and poorly planned development.
  • Build out a default site that is representative of your features across all sites, with real content from your site(s).

Code Studio Best Practices

  • Install Drupal during each CI/CD build and import your configuration.
  • Build automated testing using a framework of your choice that uses your default site and content, such as Behat, PHPUnit, or Nightwatch.
  • Never merge (or deploy) builds that do not pass all automated tests.
  • Structure your local or personal development workspace, CI/CD, and deployment workflows to use the same commands in the same order. For example, updating the database, importing configuration, and flushing caches.
  • Minimize the customizations you make to the Code Studio Auto Devops pipeline. Acquia maintains our recommended workflow on your behalf. The more you customize it, the more you have to maintain it!

Other Reminders

Remember that Site Factory is for all intents and purposes the “same” as Acquia Cloud. There are subtle differences, certainly. But as far as Code Studio is concerned, the codebase it builds out is “just a Drupal codebase.” You know and I know that it is for a multisite (but shhhh don’t tell Code Studio). So, as long as you focus on building out a repeatable workflow that incorporates your configuration management strategy and automated tests, you should be in fantastic shape to integrate that codebase with Code Studio