Slide 1

Slide 1 text

Continuously Deploying WordPress Continuously Deploying WordPress Giuseppe Mazzapica

Slide 2

Slide 2 text

Biggest German WordPress Agency WordPress.com Featured Service Partner Gold Certified WooCommerce Expert @gmazzap github.com/gmazzap https://gmazzap.me PHP developer since 2005, first met WordPress in 2006. Moderator at wordpress.stackexchange.com Since 2016 WordPress Engineer at: Giuseppe Mazzapica Continuously Deploying WordPress Continuously Deploying WordPress

Slide 3

Slide 3 text

What is ? Continuous Deployment It is a set of pratices to automate the process that goes from the writing of source code to its release in production. Premise of continuous deployment is continuous integration. Continuously Deploying WordPress

Slide 4

Slide 4 text

Continuous deployment and continuous delivery share the set of practices and tools, but continuous deployment implies the automation of the transition from development cycle to release cycle, whereas that transition is not automated for continuous delivery. Continuously Deploying WordPress

Slide 5

Slide 5 text

Key Concepts Continuous Integration Continuous Delivery Continuous Deployment Development Cycle Release Cycle “You’re doing continuous delivery when: Your software is deployable throughout its lifecycle Your team prioritizes keeping the software deployable over working on new features Anybody can get fast, automated feedback on the production readiness of their systems any time somebody makes a change to them You can perform push-button deployments of any version of the software to any environment on demand Martin Fowler Continuously Deploying WordPress

Slide 6

Slide 6 text

Continuous Development Source Code Code Review Tests Unit, Integration Version Control Build Continuous Integration Continuous Delivery Continuous Deployment Code Deployment Tests Platform Tests Acceptance Maintenance Monitoring to Stage Environment to Production Environment Environment Configuration Stage, Production Release Cycle Development Cycle Continuously Deploying WordPress

Slide 7

Slide 7 text

Continuous Integration All custom code lives under version control. Development team clones, edits and updates code repository frequently. At every update, unit tests are started automatically and the QA team is notificated so they can start code review. Continuously Deploying WordPress

Slide 8

Slide 8 text

Continuously Deploying WordPress Version Control: Tools Mercurial Perforce Git Subversion git-scm.com subversion.apache.org mercurial-scm.org perforce.com

Slide 9

Slide 9 text

Continuously Deploying WordPress Continuous Integration: Tools Hudson Circle CI Bitbucket Pipelines Jenkins Travis CI jenkins.io travis-ci.org hudson-ci.org circleci.com bitbucket.org Gitlab CI about.gitlab.com/gitlab-ci

Slide 10

Slide 10 text

Continuously Deploying WordPress Code Review: Tools Gerrit GitHub Gitlab Phabricator Codacy Crucible codacy.com atlassian.com/software/crucible gerritcodereview.com github.com gitlab.com phacility.com/phabricator

Slide 11

Slide 11 text

Continuously Deploying WordPress Testing: Tools JavaScript Jest Codeception Behat Atoum PHPUnit phpspec PHP phpunit.de phpspec.net codeception.com behat.org Mocha mochajs.org Jasmine jasmine.github.io Cucumber.js cucumber.io atoum.org facebook.github.io/jest Tape github.com/substack/tape

Slide 12

Slide 12 text

Continuously Deploying WordPress Continuous Delivery & Deployment Development happens in continuous integration At the end of development cycle code is automatically released in a production-like environment (stage), and other tests are automatically started Configuration of the servers is automated, reproducible, scalable, and under version control. It is also manages different environments.

Slide 13

Slide 13 text

Continuously Deploying WordPress Continuous Delivery & Deployment When release cycle ends successfully on stage (acceptance and user acceptance test pass) the code is released in production with the same routine that occurred for the stage environement. Release in production may happen: automatically, that’s continuous deployment manually (push-the-button), that’s continuous delivery

Slide 14

Slide 14 text

Continuously Deploying WordPress Key Concepts Automation Scalability, Reproducibility, Maintainability Quality Control Automated tests at every step If any test fails, the cycle stops and starts over The closer the production environement, the more tests are “black box” Dev/Prod Parity All environments share same setup and technologies Code is environment agnostic Continuous Monitoring

Slide 15

Slide 15 text

Continuously Deploying WordPress new features bugfixes improvements quality controls convenience estimations usability tests performance monitoring errors monitoring feedback analysis e g a t S / t s e T quality assurance feature management feature planning Continuous development, ensuring the code is environment agnostic, allows for different focuses for different environments being carefree about the existence of problems related to each specific environment g n i r o t i n o m Development Production

Slide 16

Slide 16 text

Continuously Deploying WordPress Configuration Management: Tools Puppet Chef SaltStack Ansible Dockerdocker.com ansible.com puppet.com chef.io saltstack.com CFEnginecfengine.com Forge forge.laravel.com Services Vagrant vagrantup.com Other Digital Oceandigitalocean.com VPS Hosting + API Linode linode.com AWS aws.amazon.com

Slide 17

Slide 17 text

Continuously Deploying WordPress Code Deployment: Tools Envoy BLDR Robo Fabric Deployer Capistranocapistranorb.com deployer.org laravel.com/docs/envoy robo.li fabfile.org bldr.io

Slide 18

Slide 18 text

Continuously Deploying WordPress Code Deployment: Services Envoyer envoyer.io AWS CodeDeploy aws.amazon.com/codedeploy DeployHQ Deploybot Codeship deployhq.com deploybot.com codeship.com

Slide 19

Slide 19 text

Continuously Deploying WordPress Debugging, Profiling: Tools Blackfire Z-Ray Tideways Valgrind XDebug xdebug.org valgrind.org blackfire.io zend.com/en/products/server/z-ray tideways.io

Slide 20

Slide 20 text

Continuously Deploying WordPress Greylog Cube NewRelic Rollbar Monolog Loggly Logging, Monitoring Tools Logstash Dynatrace DataDog Logmatic Sentry Grafana elastic.co graylog.org square.github.io/cube loggly.com rollbar.com bit.ly/mono-log newrelic.com dynatrace.com datadoghq.com logmatic.io grafana.com sentry.io

Slide 21

Slide 21 text

Continuously Deploying WordPress Continuous development is not a toolset, but more a mindset that aims at integrating different skills available across company teams, sharing decisions and responsibilities. Application code is not a separate element, but it is part of an integrated process, which always evolves, and whose reason to be is the research of business value maximization.

Slide 22

Slide 22 text

Continuously Deploying WordPress Continuous development is both a set of practices and a company attitude. It is a modular process that can be integrated step by step in existent company processes.

Slide 23

Slide 23 text

Continuously Deploying WordPress What about WordPress?

Slide 24

Slide 24 text

Continuously Deploying WordPress Within continuous development, WordPress is just another tool. Specifically, it is a tool for writing website or web application code. So the question is: is it possible to integrate WordPress in a continuous development process? If so, how?

Slide 25

Slide 25 text

Continuously Deploying WordPress Continuous Development Source Code Code Review Tests Unit, Integration Version Control Build Continuous Integration Continuous Delivery Continuous Deployment Code Deployment Tests Platform Tests Acceptance Maintenance Monitoring to Stage Environment to Production Environment Environment Configuration Stage, Production Release Cycle Development Cycle

Slide 26

Slide 26 text

Continuously Deploying WordPress Code Review Tests Unit, Integration Version Control Build Code Deployment Tests Platform Tests Acceptance Maintenance Monitoring to Stage Environment Environment Configuration Stage, Production Source Code Continuous Development WordPress Core Custom Themes Custom Plugins 3rd Party Plugins Continuous Integration Continuous Delivery Continuous Deployment Release Cycle Development Cycle

Slide 27

Slide 27 text

Continuously Deploying WordPress Integrating WordPress into a continuous development context does not affect the rest of the process, it is only needed to take into account that the codebase will be made by different elements: WordPress core 3rd-party code (themes, plugins) Custom code (themes, plugins)

Slide 28

Slide 28 text

Continuously Deploying WordPress Continuous development dictates to keep code under version control, but also to automate each step of the development cycle. The most effective solution to obtain both things is to keep custom code under version control and to treat 3rd-party code (including WordPress) as an external dependency.

Slide 29

Slide 29 text

Continuously Deploying WordPress Real world projects, more often than not, have a complex “dependency tree”, which is impossible to maintain without a dependency management tool In the PHP world, where also WordPress lives in, the only (as of today) possible solution is Composer getcomposer.org

Slide 30

Slide 30 text

Continuously Deploying WordPress WordPress requires configuration based on PHP files, which is an obstacle to environment agnostic code. Different projects which integrate WordPress and Composer also allow to manage different environments, but aiming for cross-environment parity, different environments should be configured via environment variables.

Slide 31

Slide 31 text

Continuously Deploying WordPress WP Starter wecodemore.github.io/wpstarter and roots.io/bedrock Bedrock are two libraries which ease the integration of Composer and WordPress, allowing WordPress configuration via environment variables.

Slide 32

Slide 32 text

Continuously Deploying WordPress Using Composer and environment variables means to put in practice the current best practices about deployment of PHP code, paving the way for the usage in WordPress context of tools designed for "generic" PHP applications.

Slide 33

Slide 33 text

Continuously Deploying WordPress The last important missing "piece" is WP CLI Allowing the execution of WordPress-specific tasks (i.e., creating a user, or activating a plugin) from the command line is a key component towards complete WordPress deployment automation. wp-cli.org

Slide 34

Slide 34 text

Continuously Deploying WordPress When integrated with Composer, environemt variables, and WP CLI (maybe with the help of libraries like Bedrock or WP Starter), WordPress stands like any other application, PHP or otherwise, perfectly integrable in a process of continuous development.

Slide 35

Slide 35 text

Continuously Deploying WordPress

Slide 36

Slide 36 text

Continuously Deploying WordPress Questions?