Slide 1

Slide 1 text

How We Use GitHub and AWS Together at COOKPAD @takai  

Slide 2

Slide 2 text

Naoto Takai Cowboy Coder

Slide 3

Slide 3 text

20M UU/month 1.5M recipes (October 31 2013)

Slide 4

Slide 4 text

Ruby 2.0 Rails 3.2 (October 31 2013)

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Bad news: GitHub Enterprise does not support EC2.

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

GitHub LDAP SMTP Accessing AWS: LAN AWS Helper Gateway SSH Tunnel (autossh) GitHub Enterprise does not support SSH tunneling

Slide 9

Slide 9 text

Developer Access from External: LAN AWS GitHub Gateway SSH Tunnel (autossh) Reverse Proxy Internet Developer Tips ‣ DNS lookup Helper

Slide 10

Slide 10 text

Developer Access from External (SSH): LAN AWS GitHub Gateway SSH Tunnel (autossh) Internet Developer Tips: SSH con g hack Host github-enterprise Hostname gateway CheckHostIP no StrictHostKeyChecking no port 2222 Helper

Slide 11

Slide 11 text

5 pro tips for successful GitHub and AWS

Slide 12

Slide 12 text

Open pull request every time. Pro Tip:

Slide 13

Slide 13 text

We are using GitHub Enterprise since 2012. ✗ Quality was dependent on individual skills. ✗ Our code base was growing. ✗ It was hard to track changes in the code. ✗ Code review was very hard.

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

We made the rule: ✓ Code review is required to be merged into the master. Team Pull Request Owner Developer Developer review open merge review

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Effects: ✓ Everyone talks about “readable code”. ✓ We can share our business knowledge, technique, and pitfalls.

Slide 19

Slide 19 text

Number of Pull Requests 0 100 200 300 400 500 600 700 800 2012-04 2012-05 2012-06 2012-07 2012-08 2012-09 2012-10 2012-11 2012-12 2013-01 2013-02 2013-03 2013-04 2013-05 2013-06 2013-07 2013-08 2013-09 2013-10 0 10 20 30 40 50 60 Developers Pull Requests

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Pull Request Best Practices

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Use GitHub ow and feature toggle. Pro Tip:

Slide 26

Slide 26 text

How many people use git?

Slide 27

Slide 27 text

How many people use git ow?

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

GitHub Flow ✓ Anything in the master branch is deployable ✓ To work on something new, create a descriptively named branch off of master (ie: new-oauth2-scopes) ✓ When you need feedback or help, or you think the branch is ready for merging, open a pull request ✓ After someone else has reviewed and signed off on the feature, you can merge it into master http://scottchacon.com/2011/08/31/github- ow.html

Slide 30

Slide 30 text

feature branch feature branch master branch pull request & merge GitHub Flow

Slide 31

Slide 31 text

Feature Toggle “The basic idea is to have a con guration le that de nes a bunch of toggles for various features you have pending. The running application then uses these toggles in order to decide whether or not to show the new feature.” http://martinfowler.com/bliki/FeatureToggle.html

Slide 32

Slide 32 text

Feature Toggle Target? Original feature New feature User request Yes No

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Involve non-engineers. Pro Tip:

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

(JUIVCͷαΠτΛݟΔ͚ͩͰɺ։ൃ༻ޠΛ֮͑ΒΕΔ ڞ௨ͷݴޠͰ࿩ͤΔΑ͏ʹͳΔ όάɾϓϩδΣΫτ؅ཧɺXJLJͳͲɺ։ൃʹඞཁͳ͢΂ͯΛҰΧॴͰ ίϚϯυϥΠϯɺϒϥ΢βͳͲ޷͖ͳํ๏Ͱར༻ ϒϥ΢β͔ΒίϛοτͰ͖Δ HJUIVCͱάϧʔϓνϟοτΛ࿈ܞͤͯ͞ɺϦΞϧλΠϜʹ։ൃʹࢀՃ͢Δ ΤϯδχΞʹ࿩͔͚͠΍͘͢ͳΔ HJUͷίϯηϓτʹ׳ΕͨΒɺϩʔΧϧ؀ڥΛͭͬͯ͘ΈΔ ݸਓϨϙδτϦΛ࢖ͬͯɺϑΝΠϧͷڞ༗΍όοΫΞοϓΛ͢Δ (JUIVC্Ͱத਎ΛݟΕͳ͍ϑΝΠϧܗ͕ࣜɺஈʑͱݏ͍ʹͳͬͯ͘Δ ࣗ෼ͷۀ຿ΛɺεΫϦϓτʹ୅ΘΓʹ΍ͬͯ΋Β͏ ։ൃऀ͕ϓϧϦΫΤετ͘ΕͨΓɺػೳͱͯ͠औΓࠐ·ΕͨΓ http://www.goodpic.com/mt/archives2/2013/09/non-engineers-should-use-github.html

Slide 39

Slide 39 text

Repository Product Support Product Manager Issue Developer UI/UX Designer Pull Request le le review open open Usage of Pull Request and Issue

Slide 40

Slide 40 text

Use GitHub as hub for CD. Pro Tip:

Slide 41

Slide 41 text

How often do you deploy?

Slide 42

Slide 42 text

11+ deploys per day

Slide 43

Slide 43 text

✓ Development ✓ Source code review ✓ Continuous integration ✓ Production test ✓ Production Source Code Review Continuous Integration Production Test Developement Production GitHub Git Repository merge pull req pull tag deploy deploy Deployment Pipeline

Slide 44

Slide 44 text

LAN EC2 CI Server Git Repository Production Test HipChat tag pull notify deploy Development DB schema Remote Spec distribute Git Repository clone pusher service hook pull push Developer merge

Slide 45

Slide 45 text

require 'sinatra' post '/update' do payload = JSON.parse(params[:payload]) project = payload['repository']['name'] if system("pgrep -f \"sh -c git --git-dir=#{REPOSITORY_ROOT}/#{project}\"") next "Found another process for #{project}\n" end cmd = "git --git-dir=#{REPOSITORY_ROOT}/#{project} remote prune origin " + "&& git --git-dir=#{REPOSITORY_ROOT}/#{project} fetch -q " + "&& git --git-dir=#{REPOSITORY_ROOT}/#{project} push -q --mirror git-repo" pid = Process.spawn(cmd) Process.detach(pid) "Spawn following command: #{cmd}\n" end Clone Pusher

Slide 46

Slide 46 text

CI Production DB Development DB Test DB GitHub Enterprise replication schema pull Developer Machine Test Database Schema

Slide 47

Slide 47 text

GitHub is DevOps interface. Pro Tip:

Slide 48

Slide 48 text

݈શͳํ

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

Puppet Client Puppet Master GitHub Enterprise deploy IT Professional push pull Puppet Client Puppet Client Con guration Management with Puppet

Slide 51

Slide 51 text

5 pro tips for successful GitHub and AWS ✓ Open pull request every time. ✓ Use GitHub ow and feature toggle. ✓ Involve non-engineers. ✓ Use GitHub as hub for CD. ✓ GitHub is DevOps interface.