68
Continuous Integration How I stopped guessing if that merge was bad Joe Ferguson https://joind.in/14016

Continuous Integration: How I stopped guessing if that merge was bad

Embed Size (px)

Citation preview

Continuous IntegrationHow I stopped guessing if that merge was bad

Joe Fergusonhttps://joind.in/14016

Continuous Integration? Continuous Deployment?

Continuous Integration

Frequently integrate code changes into the existing code repository

Merging branches to master/production

Automated build tests to ensure issues found quickly

Does not have to be deployed

Continuous Delivery

Produce valuable changes in code in short cycles to be released at any time.

AKA: Continuous Deployment

Automated build tests to ensure issues found quickly

Deployment happens on successful build

Continuous Integration or

Continuous Delivery

Which is right for you?

Your goal should be Continuous Integration (at least!)

Strive for Continuous Delivery if it makes sense

Applications with a live event component may not be suited for Continuous Delivery

The Problem

2 Developers and now scaling up

No longer 1 developer == 1 project

Version control is the obvious answer

What happens if the team just learning version control?

Story Time!

Our Problem

Scaling up meant more developers contributing to same code bases

Previously 1 developer per codebase

Our Process

Master always deployable / not broken

Feature branching off master

Feature branches merged to dev/staging

dev/feature merged to master (release / deploy)

What we needed

Private build testing

Cheap or Free (had to prove value to stakeholders / managers)

Customizable for some pretty uncommon things (So we thought)

There are a lot of CI solutions out there

Travis-CI.org

Great for OSS

Private projects require paid account

Not hosted on your infrastructure

Jenkins-CI.org

Self hosted (Bring your own hardware)

Great flexibility and support

Just didn't click for me

Great Atlassian integrations

Utilizes Amazon’s EC2 for build agents

Greater appeal if you’re already using Atlassian and Amazon products

https://www.atlassian.com/software/bamboo

Fully Functional Free Version (Limited Configs & Build Agents)

Enterprise option (unlimited configs, more build agents)

Self hosted (Bring your own hardware)

Runs on Windows / OS X / Linux

Installation

You’ll need Java installed

Configure Database (or use internal TeamCity)

Just want to poke around a bit?

https://github.com/curzona/vagrant-teamcity

Create Admin Account

Ready to start building!

Create a new project

Create a VCS Root

Create a Build Config

Attach VCS to Config

Auto Detected Build Steps

Add Build Steps

Step 1 Composer Install

Step 2 Run phpunit

2 Steps to Build

Running our first build

Build Log

Detailed Output

Detailed Output

Successful Build!

Failed Build :(

When a build fails the steps after will not run*

*sometimes you do want a step to run

What happened?

Oh, Class not found

Finding the breaking change

Finding the broken rev

Revert Change

Build Passes

Questions so far?

Now for something more complex…

Fork in the road…

Testing real things can be hard

Manually create these sites / databases

Docker

Vagrant

Build Test a Web App

Create Build Config

Add VCS Root

Quick NoteYou can add VCS Roots before or after you create a build configuration.

In our first example we did it before, in this example we did it after.

Adding Build Steps

Run DB Migrations

Seed the Database

Run PhantomJS

Copy files to vhost

Run Codeception

Stop PhantomJS

Reset Database

Test Our Build

Verifying our Tests

Automate our builds

Other Triggers

Now we have automatic VCS triggered built tests

What next?

Deployments can be a build step away!

Deployment

https://github.com/laravel/envoy

Envoy Deployment

https://github.com/laravel/envoy

Anything you can script can be a part of your build

Some CI pain points

You have to duplicate your production environment within TeamCity / other CI service

Starting out there will be a lot of trial & error

Don’t forget to back up your CI server configs!

Payoff is better than the pain

Quick feedback on commits

Confidence level of your merges is huge

Less time resolving conflicts

Automate your deployments

Advanced build notifications

Feedback!

https://joind.in/14016

Joe FergusonTwitter: @JoePFerguson

Email: [email protected]: joepferguson

Contact Info: