$30 off During Our Annual Pro Sale. View Details »

Getting started with continuous integration and WordPress

Getting started with continuous integration and WordPress

These are the slides from a talk given at WordCamp San Diego 2018.

Writing high-quality WordPress code is hard to do. It requires constant effort on our part and good self-awareness to know when we slipped up. But, if your business has any sort of success (which we all want!), you're going to work with more and more people. And many of them are likely to touch with your code.

This is going to put a strain on your development processes. It becomes harder to maintain a certain level of code quality. And you’re no longer the only person pushing code. You're now part of a team and you need a way to standardize all of the things you once did on your own.

That's the goal of continuous integration. It lets you automate your different development workflows from testing to deployment. This ensures that the quality of your code stays consistent.

This talk will go over the basics of continuous integration. We'll also go over some of the tools that are available. And then we'll finish by looking at how you put these tools together to create your own continuous integration environment.

You can read the companion article at: https://carlalexander.ca/continuous-integration-wordpress

Carl Alexander

April 14, 2018
Tweet

More Decks by Carl Alexander

Other Decks in Technology

Transcript

  1. Getting started with
    continuous integration
    and WordPress

    View Slide

  2. Carl Alexander

    View Slide

  3. @twigpress

    View Slide

  4. carlalexander.ca

    View Slide

  5. View Slide

  6. Growing pains

    View Slide

  7. Writing high-quality
    WordPress code is hard to do
    Growing pains

    View Slide

  8. Requires constant effort
    Growing pains

    View Slide

  9. Even harder on a team
    Growing pains

    View Slide

  10. No longer alone pushing code
    Growing pains

    View Slide

  11. Need to standardize
    Growing pains

    View Slide

  12. Goal of continuous integration
    Growing pains

    View Slide

  13. Ensures code quality
    stays consistent
    Growing pains

    View Slide

  14. Minimizes maintenance work
    Growing pains

    View Slide

  15. Automates your different
    development workflows
    Growing pains

    View Slide

  16. What is it?

    View Slide

  17. Part of a larger practice
    What is it?

    View Slide

  18. What is it?
    Continuous deployment

    View Slide

  19. What is it?
    Continuous integration

    View Slide

  20. Processes

    View Slide

  21. Processes
    Continuous integration

    View Slide

  22. Checks out code
    from your repository
    Processes

    View Slide

  23. Compiles your
    JavaScript or preprocessed CSS
    Processes

    View Slide

  24. Processes
    Continuous integration

    View Slide

  25. Can mean different things
    to different people
    Processes

    View Slide

  26. Runs unit tests
    Processes

    View Slide

  27. Processes
    Continuous integration

    View Slide

  28. This is where things can vary
    Processes

    View Slide

  29. Not everyone
    has a staging server
    Processes

    View Slide

  30. Not everyone
    does acceptance testing
    Processes

    View Slide

  31. Prerequisites

    View Slide

  32. Continuous integration
    can’t exists on its own
    Prerequisites

    View Slide

  33. Relies on other processes
    and tools to do its job
    Prerequisites

    View Slide

  34. Version control system
    Prerequisites

    View Slide

  35. Automated test suite
    Prerequisites

    View Slide

  36. Automated test suite
    Prerequisites

    View Slide

  37. Code quality tools
    Prerequisites

    View Slide

  38. Why do we need it?

    View Slide

  39. We want to commit code often
    Why do we need it?

    View Slide

  40. Lots of benefits to doing it
    Why do we need it?

    View Slide

  41. Not without issues either
    Why do we need it?

    View Slide

  42. Can’t let it affect code quality
    Why do we need it?

    View Slide

  43. Need to prevent errors
    Why do we need it?

    View Slide

  44. Helps prevent both issues
    Why do we need it?

    View Slide

  45. Questions

    View Slide

  46. Piecing it together

    View Slide

  47. Two types of continuous
    integration workflows
    Piecing it together

    View Slide

  48. Local

    View Slide

  49. Why would you want to put
    together a local workflow?
    Local

    View Slide

  50. Easier to get up and running
    Local

    View Slide

  51. Lets you test things on your own
    Local

    View Slide

  52. Still useful if you move to a service
    Local

    View Slide

  53. GrumPHP
    Local

    View Slide

  54. Best (and only) tool
    Local

    View Slide

  55. Runs code quality tools
    whenever you commit code
    Local

    View Slide

  56. Uses git hooks to do it
    Local

    View Slide

  57. Can’t commit code
    without tools running
    Local

    View Slide

  58. Same as if it was done elsewhere
    Local

    View Slide

  59. Has limitations
    Local

    View Slide

  60. Hosted services

    View Slide

  61. Systems hosted in the cloud
    Hosted services

    View Slide

  62. Very broad category
    Hosted services

    View Slide

  63. Will look at the ones
    with WordPress support
    Hosted services

    View Slide

  64. A lot of the common features
    Hosted services

    View Slide

  65. Free tier
    Hosted services

    View Slide

  66. Important when evaluating
    Hosted services

    View Slide

  67. Often don’t need more than that
    Hosted services

    View Slide

  68. Different levels of support
    for open source projects
    Hosted services

    View Slide

  69. YAML configuration
    Hosted services

    View Slide

  70. Easy to read
    Hosted services

    View Slide

  71. Integrates with
    your version control system
    Hosted services

    View Slide

  72. Needs to know when
    someone commits code
    Hosted services

    View Slide

  73. Validate commits
    on different branches
    Hosted services

    View Slide

  74. Only supports git
    Hosted services

    View Slide

  75. WP-CLI support
    Hosted services

    View Slide

  76. Comparing services

    View Slide

  77. Comparing services
    • Bitbucket Pipelines
    • Buddy
    • CircleCI
    • GitLab CI
    • Travis CI

    View Slide

  78. Bitbucket Pipelines
    Comparing services

    View Slide

  79. Buddy
    Comparing services

    View Slide

  80. Comparing services

    View Slide

  81. Comparing services

    View Slide

  82. CircleCI
    Comparing services

    View Slide

  83. GitLab CI
    Comparing services

    View Slide

  84. Travis CI
    Comparing services

    View Slide

  85. Questions

    View Slide

  86. Your first workflow

    View Slide

  87. WP-CLI scaffold command
    Your first workflow

    View Slide

  88. $ wp scaffold plugin-tests my-plugin --ci=
    Your first workflow

    View Slide

  89. $ wp scaffold theme-tests my-theme --ci=
    Your first workflow

    View Slide

  90. What do you get?
    Your first workflow

    View Slide

  91. Continuous integration
    configuration file
    Your first workflow

    View Slide

  92. Rules for PHP code sniffer
    Your first workflow

    View Slide

  93. Configuration file for PHPUnit
    Your first workflow

    View Slide

  94. Connect your repository
    to your chosen service
    Your first workflow

    View Slide

  95. Workflow consists of
    two processes
    Your first workflow

    View Slide

  96. Checks for code style issues
    Your first workflow

    View Slide

  97. Runs WordPress unit tests
    Your first workflow

    View Slide

  98. Does this on a mix of
    PHP and WordPress versions
    Your first workflow

    View Slide

  99. Varies depending on the
    continuous integration service
    Your first workflow

    View Slide

  100. All the services support
    PHP 5.6 or newer versions
    Your first workflow

    View Slide

  101. A modern approach

    View Slide

  102. Huge topic
    A modern approach

    View Slide

  103. Lots of different services
    A modern approach

    View Slide

  104. You can customize them
    any way that you want
    A modern approach

    View Slide

  105. Automate the processes
    that you already have
    A modern approach

    View Slide

  106. WP-CLI is a great way to get
    started if you don’t have any
    A modern approach

    View Slide

  107. Great foundation for any workflow
    A modern approach

    View Slide

  108. Questions

    View Slide

  109. Thank you!

    View Slide