Git and DevOps – – Why Git



Git and DevOps – – Why Git

0 0


reveal.gitdevops

View Presenation at

On Github CaffGeek / reveal.gitdevops

Git and DevOps

Created by Chad Hurd / @caffgeek

Introduction

Why Git?

Command Line Walkthrough

Leverage Git with Webhooks

If time, Vagrant

Why Git

Branches are FAST and Easy

Undo almost everything

local/offline source control

Everyone has a copy of the FULL repository

Language agnostic

Eclipse Community Survey 2014

Mostly JAVA devs

Git:

2009: 2.4%
2010: 6.8%
2011: 12.8%
2012: 27.6%
2013: 30.3%
2014: 33.3%
							

Subversion:

2009: 57.5%
2010: 58.3%
2011: 51.3%
2012: 46.0%
2013: 37.8%
2014: 30.7%
							

Microsoft?

Team Foundation Version Control

Standards compliant, not custom git

Git, based on libgit2 (same as github)

Industry Support

Use the CLI - Cheatsheet

#create a new repository
git init 

#clone a repository
git clone http://gihub.com/caffgeek/reveal.gitdevops 

#get the changes from the server
git pull #basically a fetch then merge

#check what has changed
git status 

#commit changes locally
git add -A #stages all changes
git commit -m "checkin message"

#push changes to git server
git push

GUIs are great, once you understand what's happening under the hood

Learn how it works better on the CLI

Command line is faster, I didn't go back to the GUI

Git is Distributed

Still a central server (normally)

Each node has a full repo

Share without using central server

100% Redundancy

Status

status = friend

what's changed?

need to add to staging area

how you select files to commit

Committing - Staging

Added all with -A

Individual with filename (wildcards)

Committing - Locally

Commits are local

1st time, went weeks before realizing

status shows us we're behind master...

work without central repo

Committing - Push

Sends to remote repository

Branches

SUPER SUPER FAST

Just pointers

Branch Pointers

in branch and commit, pointer moves with you

Branch Merging

c7 = merged code...classic

Branch Merging

might not be conflicts

Branch Rebase

Branch Rebase

Branch Rebase

Golden Rule of Rebasing

The golden rule of git rebase is to never use it on public branches.

If you need to "push -f"

you are rewriting history

peers don't have those changes

Resources

Tooling around Git

Webhooks = new

github-services = old

WebHooks

Build integrations

Subscribe to events on GitHub.com (fork, delete, create, etc)

Send HTTP POST payload

What's out there?

Only going to go into a few of these

bamboo($) by atlassian (jira)

versioneye - also daviddm for node (packages.json)

Travis CI

https://travis-ci.org/

  • CI service to build and test projects
  • Very comprehensive language support
  • Over 2 dozen at time of writing
  • C/++, C#, F#, JAVA, Javascript/node, PHP, R, SCALA...
  • It can even deploy your app!
  • AWS, Azure, Google App Engine, Heroku,
  • Startup needed services
  • databases (mysql, mongo, neo4j)
  • Not sql server or oracle :(
  • rabbitmq
  • all done through .travis.yml

Travis CI

Sample .travis.yml

language: node_js
node_js:
  - "0.10"
notifications:
  slack: caffgeek:coKj2K5otFWUcZ6e8hY3h8Rn
  • Not very complex
  • You have a console log to see what's going on

Code Climate

https://codeclimate.com

Ruby, JavaScript, PHP (Beta), Python (Beta)

Automatically open issues for code smells - http://github-service-universe.kimminich.de/#/18/6

Overview

Repos at a Glance

Dashboard of Repo

Issue Breakdown

Graphs

Sample

YAML

exclude paths

specific languages

instead of guessing

Create Tickets

Jira

GitHub Issues

Pivotal

No trello(?)

VersionEye

https://www.versioneye.com/

watches your repositories package.json and bower.json

Configure

package.json - node

bower.json - javascript

package.json

bower.json

Settings

Daily/Weekly/Monthly/Never

Public/Private

Vagrant

https://www.vagrantup.com/

single file description of a machine

base image

provision

configure

virtual box

It's Just Code...

VagrantFile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
	config.vm.box = "hashicorp/precise32"
	
	config.vm.network "forwarded_port", guest: 1337, host: 8337
	
	config.vm.synced_folder ".", "/vagrant"
		
	config.vm.provision "shell", path: "sh/provision.sh"
	config.vm.provision "shell", path: "sh/startup.sh", run: "always"
end

provision.sh

# Change the hostname so we can easily identify what environment we're on:
echo "nodejs-vagrant" > /etc/hostname
# Update /etc/hosts to match new hostname to avoid "Unable to resolve hostname" issue:
echo "127.0.0.1 nodejs-vagrant" >> /etc/hosts
# Use hostname command so that the new hostname takes effect immediately without a restart:
hostname nodejs-vagrant

# Install core components
apt-get update

# Install build tools
apt-get install -y make g++ git curl vim libcairo2-dev libav-tools nfs-common portmap

# Install Node.js
# Modified from https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
apt-get update
apt-get install -y python-software-properties python g++ make
add-apt-repository -y ppa:chris-lea/node.js
apt-get update
apt-get install -y nodejs
apt-get install screen

npm install supervisor -g

startup.sh

echo "Running node-supervisor with screen"
screen -d -m /vagrant/sh/node-supervisor.sh

node-supervisor.sh

supervisor --watch /vagrant /vagrant/server.js

Vagrant Up

Vagrant SSH

Questions?

Git and DevOps Created by Chad Hurd / @caffgeek Introduction Why Git? Command Line Walkthrough Leverage Git with Webhooks If time, Vagrant