continuous integration

27
Continuous Integration with Jenkins, Github & Grunt

Upload: joerg-henning

Post on 15-Apr-2017

205 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Continuous Integration

Continuous Integrationwith Jenkins, Github & Grunt

Page 2: Continuous Integration
Page 3: Continuous Integration

- Integrate any changes within a matter of hours into the product

- Collection of tools and practices to make that possible

- Originating from XP, now an essential practice in Agile SD

What is CI?

Page 4: Continuous Integration

RPM/Spectos Cloud

Page 5: Continuous Integration

● LAMPP● MEAN● Ubuntu● AWS, EC2● Jenkins● JIRA● Github

Technology Stack

Page 6: Continuous Integration

Motivation

- RPM: Frontend + 10 backend services- New features usually affect at least frontend

+ one (maybe 2 or 3) backends- How to know everything works well with

each other?- Who determines when we can ship to the

customer?

Page 7: Continuous Integration

Practices

● Single Source Repository● Automate the build● Self-Testing● Commit often● Build every commit

Page 8: Continuous Integration

Practices (cont.)

● Fix broken builds ASAP● Keep builds fast● Easy access to latest version● Everybody can see what’s happening● Automate deployment

Page 9: Continuous Integration

Source Code Repository

- Not one “single” repo but one per project

- It’s all on https://github.com/Spectos (private, sorry)

Page 10: Continuous Integration

Source Code Repository

- Mainline branch:

Page 11: Continuous Integration

Source Code Repository

Sources

Docs

Dependencies

Tests Cronjobs

IDE Settings

Build Script

Config

Page 12: Continuous Integration

Build Automation- Using Grunt: http:

//gruntjs.com/ - Javascript taskrunner,

based on Node.js- Simple syntax (JS)- Easy to wrap around

other tools (Cake Shell, bash)

- Lot of plugins

Page 13: Continuous Integration

Build Automation- Database backups,

migrations- Generate locales (ng)- Run tests (mocha.js or

Cake shell)- Deploy via shipit.js (like

Capistrano)- Init work queues, clear

caches, etc.

Page 14: Continuous Integration

Build Automation

// start development server

grunt s

// run all tests

grunt test

// deploy to stage

grunt shipit:stage deploy

Page 15: Continuous Integration

Testing

Page 16: Continuous Integration

Testing

- Automated tests for each functionality added (TDD is recommended)

- Using PHPUnit for PHP or mocha for Node.js apps

- Part of every build- Automated frontend tests with Selenium

(WIP)

Page 17: Continuous Integration

Commit Often

- On your local: multiple times per day, easy to experiment and undo changes (git reset --hard ftw.)

- Remote: Pull & rebase often to avoid merge conflicts

- Push every feature when you consider it done so it can be integrated & tested

Page 18: Continuous Integration

Fix Broken Builds ASAP- Emails are not very

effective- Desktop notifications,

sounds- Integrations (Slack)- Broken build is top

priority!

Page 19: Continuous Integration

Speed

- Full commit build not > 10 min

- Currently: ~6 min for full ecosystem

- Component builds (one per service)

Page 20: Continuous Integration

Speed - How To?

- Avoid expensive stuff in tests (I/O, large datasets)

- Run things parallel- Consider build

pipeline (not necessary yet)

Page 21: Continuous Integration

Build Triggers

- Jenkins- Using Github hooks- Every commit pushed to

dev/master will trigger a build

- Production deploy: manual

Page 22: Continuous Integration

Easy Access

githubmaster

development

production

FDB-123 rpm-dev.spectos.com/FDB-123/current

rpm-dev.spectos.com/dev/current

rpm-stage.spectos.com

rpm.spectos.com

Feature Branch

Page 23: Continuous Integration

Branch Builds (Frontend only)

Page 24: Continuous Integration

Improvements

- Travis style builds (.travis.yml)- Dynamic provisioning for build workers- Containers (Docker, …)- Frontend tests (Selenium, Robot)- Test reports, coverage reports, Sonar- Blue/Green deployment

Page 25: Continuous Integration

Benefits- Reduced risk: find problems early, no unpredictable

integration phase (“Blind Spot”)- Helps to ensure code & functional quality- Debugging: smaller changesets, bugs don’t pile up- (Almost) no manual tasks, repeatable, less error-prone- Precondition for Continuous Deployment => rapid

feedback cycles, more focused development- Bottom line: less bugs, more features = happier

developers & happier customers

Page 27: Continuous Integration

http://spectos.comhttp://jhenning.me

Thank You!