Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for...

55
@EvanMHerman Introduction to Workflow Automation 1 WordCamp Baltimore - October 14th, 2017

Transcript of Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for...

Page 1: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHerman

Introduction toWorkflow Automation

1

WordCamp Baltimore - October 14th, 2017

Page 2: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHerman

Evan HermanSoftware Engineer at GoDaddyWordPress Core ContributorPlugin Developer

Page 3: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanGoal

The main goal of this talk is to expose more of the WordPress community to powerful development tools and techniques which increase efficiency and help build and deliver products in a predictable and consistent manner.

Page 4: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHerman

“The point of automation is to reduce cost and labor.”Rick Sanchez

Why Automate Tasks?

Page 5: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWhat Will Be Covered

- WP CLI Aliases - managing multiple client sites- Using WP CLI scaffold to automate code creation- WordPress Coding Standards- Automating Tasks using Grunt.js- Acceptance Testing to simulate user actions within our software- Brief Overview of the CI/CD pipeline

Page 6: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHerman

WP CLI

6

Page 7: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWP CLI: Aliases- ~/.wp-cli/config.yml - Global WP-CLI config- wp-cli.yml - root directory of any WordPress install (Local WP-CLI config)

Page 8: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWP CLI: Aliases

Page 9: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanUsing WP CLI @alias

wp @alias command

wp @marlee plugin update wordpress-seo

wp @sell4more theme update --all

wp @all core update

Page 10: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWP CLI Aliases: Checking Core Version

Page 11: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWP CLI Aliases: Updating Core

Page 12: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWP CLI: Scaffold

wp scaffold child-themeGenerate child theme based on an existing theme.

wp scaffold pluginGenerate starter code for a plugin.

wp scaffold plugin-testsGenerate files needed for running PHPUnit tests in a plugin.

wp scaffold post-typeGenerate PHP code for registering a custom post type.

wp scaffold taxonomyGenerate PHP code for registering a custom taxonomy.

wp scaffold theme-testsGenerate files needed for running PHPUnit tests in a theme.

wp scaffold _sGenerate starter code for a theme based on _s.

Page 14: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWP CLI: Plugin Scaffold Results

Page 15: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHerman

Coding Standards

15

Page 16: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanCoding Standards

Coding standards are a set of guidelines for a specific programming language that recommend programming style, practices, and methods.

Page 17: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanPHP_CodeSnifferhttps://github.com/squizlabs/PHP_CodeSniffer

Page 18: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWordPress Coding Standards

WordPress coding standards is a collection of PHP_CodeSniffer rules to validate code developed for WordPress.

Page 19: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanInstalling WordPress Coding Standards

https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

$ composer create-project wp-coding-standards/wpcs --no-dev

1. Install WordPress standards into wpcs directory.2. Install PHP_CodeSniffer.3. Register WordPress standards in PHP_CodeSniffer configuration.4. Make phpcs command available from wpcs/vendor/bin.

Tip: To make the phpcs/phpcbf command accessible from anywhere you should add wpcs/vendor/bin to your system path (sudo nano etc/paths).

Page 20: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanUsing WordPress Coding Standards

Page 21: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanUsing WordPress Coding Standards

Page 22: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanUsing PHPCBF

Page 23: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanPHPCBF Fixed Code

Page 24: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanPHPCBF Fixed Code

Page 25: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanPHPCS Passing

Page 26: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWordPress Coding Standards in your Editor

Page 27: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWordPress Coding Standards in your Editor

Page 28: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWordPress Coding Standards in your Editor

Page 29: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHerman

Grunt.js

29

JavaScript “task runner”

Page 30: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanWhat is Grunt.js?

GruntJS is a JavaScript based command line build tool, or task runner, that helps developers automate repetitive tasks.

https://gruntjs.com/

Page 31: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanGrunt.js Required Files

package.jsonThis file is used by npm to store metadata for your project.

GruntfileThis file is named Gruntfile.js and is used to configure or define tasks and load Grunt plugins.

Page 32: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHerman

Package.json

Page 33: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHerman

Gruntfile.js

Page 34: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanAwesome Grunt.js Tasks

grunt-wp-i18nInternationalize WordPress themes and plugins

grunt-wp-readme-to-markdownConvert readme.txt to readme.md.

grunt-cssjanusConvert stylesheets between LTR and RTL

grunt-wp-deployGrunt plug-in to deploy a build directory to WordPress' SVN

Page 35: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanDeploying a GitHub hosted Plugin to WordPress.org

Page 36: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanDeploying a GitHub hosted Plugin to WordPress.org

1. assets_dir - WordPress org assets directory (Screenshots, banner, icon etc.)

2. build_dir - Build directory with the files you want to transfer to WordPress.org

3. plugin_main_file - Main file name.

4. plugin_slug - The WordPress.org plugin slug.

Grunt Plugin: grunt-wp-deploy

Page 37: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanDeploying a GitHub hosted Plugin to WordPress.org

Grunt Plugin: grunt-contrib-copy

Page 38: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanDeploying a GitHub hosted Plugin to WordPress.org

Grunt Plugin: grunt-contrib-clean

Page 39: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanDeploying a GitHub hosted Plugin to WordPress.org

Page 40: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanDeploying a GitHub hosted Plugin to WordPress.org

Page 41: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHerman

Acceptance Testing

41

Page 42: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanAcceptance Tests

Acceptance tests will simulate a user's actions and confirm that the actions taken lead to the desired results within the application.

Page 43: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanAcceptance Tests: Codeception

Page 44: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanExample Acceptance Test

Page 45: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanAcceptance Tests Example (might be best to demo this)

Page 46: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHerman

Continuous Integration/Continuous Deployment

46

Page 47: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanContinuous Integration

A software development practice where developers regularly merge their code changes into a central repository. Each check-in is then verified by an automated build.

- Automate the QA Process- Improve Developer Productivity- Find and Address Bugs Quicker

Page 48: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanContinuous Deployment

Expands upon continuous integration by deploying all code changes to a testing environment and/or a production environment after the build stage has passed all tests/checks.

- Automate the Software Release Process- Improve Developer Productivity- Deliver Updates Faster

Page 49: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanCI/CD Tools

Page 50: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanCI/CD Pipeline Visualized

Page 51: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanTravis Build Failure

Page 52: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanTravis Build Success

Page 53: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanRepository Notifications

Page 54: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanRepository Notifications

Page 55: Workflow Automation @EvanMHerman Introduction to · 2017. 10. 18. · Generate PHP code for registering a custom post type. wp scaffold taxonomy ... Codeception @EvanMHerman Example

@EvanMHermanThank You

@EvanMHerman

@EvanHerman

@eherman24