continuous integration · 2018-11-09 · continuous integration and build server written in java...

35
Continuous Integration Svetlana Omelkova Software Engineer Taxify

Upload: others

Post on 27-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Continuous Integration

Svetlana OmelkovaSoftware Engineer

Taxify

Page 2: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

About me● (till Oct.18) Nevercode.io Full Stack Software Engineer

○ CI service for mobile (Android, iOS, Cordova, Ionic frameworks)

○ Python, Django, AWS, MacMiniVault

● (currently) Full Stack Software Engineer at Taxify○ Nodejs stack, Javascript, Jenkins CI

● TA for software engineering and testing courses

Page 3: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

AgendaTheory

● What is Continuous Integration? ● Why to practice CI?● What are CI steps?● CI best practices

Practice

● Tools and technologies

● Cloud based vs. self hosted solutions

Demo: Travis CI for open source projects

Page 4: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

What is “Continuous”

Page 5: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

What is Continuous Integration(CI)?It is

❏ It is a development methodology

❏ of continuous developer integrations

❏ verified by automated builds

It is not

❏ Nightly builds❏ Developer branches❏ Scheduled integration

points❏ Builds using IDE

Page 6: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Why should we do CI?Risk 1: Fixing bugs late is costly

Why software is still built with waterfall?

Page 7: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Why should we do CI?Risk 2: Luck of team cohesion

❏ “Changes are incompatible, how to merge?”❏ “Why did you update a Magic library to version

2.0.1-beta?”❏ “I thought you fixed it month ago”

Page 8: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Why should we do CI?Risk 3: Poor quality of code

❏ “We have 3 classes doing the same thing”❏ “Why I can’t just include FooBar and not require all the

13 libraries”❏ “Why part of our code uses spaces and another part tabs?”

Page 9: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Why should we do CI?Risk 4: Lack of project visibility

❏ “What do you mean the tests are failing?”❏ “What is in version 1.2.3 of the build?”❏ “What is our code coverage now?”

Page 10: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Why should we do CI?Risk 5: Lack of deployable software

❏ “It works on my machine”❏ “I need a new build to test this”❏ “The boss|customer|peer is coming we need a working demo

asap”

Page 11: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Why should we do CI?Risk 5: Lack of deployable software

❏ “It works on my machine”❏ “I need a new build to test this”❏ “The boss|customer|peer is coming we need a working demo

asap”

Page 12: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

With CI build softwareBetter

❏ Quality❏ tested early

and often❏ follows best

practices and coding standards

Faster

❏ Test in parallel

❏ no scheduled integrations

❏ build is not an event

Cheaper

❏ Identify defects earlier

❏ fix is least costly

❏ repeatable automated testing

Page 13: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Build steps (phases)❏ Compilation

Page 14: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Compilation❏ Compile code from sources❏ Compile for each target platform (different OS, browsers,

mobile runtimes etc.)

Page 15: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Build steps (phases)❏ Compilation❏ Test Execution

Page 16: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Test Execution❏ Ensure software functions as expected using unit,

integration, component tests etc.❏ Code coverage (measure to which degree source code is

executed when tests run)

Page 17: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Build steps (phases)❏ Compilation❏ Test Execution❏ Code inspection

Page 18: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Code inspection❏ Ensures healthy source code❏ Enforces best practices❏ Indicate problems earlier

Page 19: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Build steps (phases)❏ Compilation❏ Test Execution❏ Code inspection❏ Status notification

Page 20: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Status notification❏ Ensure that all interested parties

(developers|management|customers) are on the same page❏ Easy build results access over direct links

Page 21: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Build steps (phases)❏ Compilation❏ Test Execution❏ Code inspection❏ Status notification❏ Automated deployment (optional, part of CD process)

Page 22: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Automated deployment❏ Product can be released at any time❏ Continuous demo-able state of the software❏ Eliminates “works on my machine” problem

Page 23: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

CI best practices❏ Build at each commit❏ Build every time dependency changes❏ Use single build script❏ Do not depend on local environment (IDE, local packages)❏ Use dedicated server

Page 24: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

CI best practices (advices)❏ Commit often❏ Do not commit broken code❏ Fix build failures immediately❏ Build and test on every target environment (browsers, OS,

mobile runtimes)❏ Create and store artifacts

Page 25: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

It was all lyrics so far, let’s move to tools and technologies

Page 26: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Continuous Integration CycleCode (manual) Compile

Test/code qualityReport/Artifacts

Deploy

Continuous Deployment

Page 27: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

(Some) Tools and Technologies❏ IDEs (IntelliJ, Eclipse, Atom etc.)❏ Git ❏ Webhooks (next slide)❏ Jenkins ❏ Travis CI❏ Code quality tools (Code climate, coverall, etc.)❏ Slack❏ Deployment services (AWS, Heroku, etc.)

Page 28: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Webhook as a technology to enable CI● Webhook is a method to augment the behaviour of a web app

with custom callbacks● Callbacks can be managed by any third-party, who may not

be affiliated with the originating web app

git add .git commit

git push webhook trigger build

Page 29: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Jenkins● Continuous integration and build server● Written in Java● Can be used to automate such tasks as build, test,

distribute software● Server based system running in servlet container(e.g

Tomcat, Jetty)● Completely free and open source/ Commercial support● Has tons of plugins, supports everything● May be a problem to configure, unstable, need dedicated

engineer to maintain

Page 30: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Travis CI● Cloud platform that provides hosted CI for GitHub

repositories● Free for open source● Does not store artifacts (use third party services)

Page 31: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Cloud-hosted alternatives● Codeship CI ● Circle CI● TeamCity from JetBrains

And many others

Page 32: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Comparison between self-hosted and cloud-hosted CISelf-hosted CI Cloud-hosted CI

Application Service

“Free” of charge (need to maintain) Commercial (usually free for open-source)

Highly flexible Easy to use

Install all you need yourself Pre-installed build and test tools

Need to deal with security issues yourself

Need to provide uname/pwd; ssh keys for your repos

Fast (usually) Builds can be queued

Page 33: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Demo● CI for Java project using Travis CI

○ Demo project: ○ Setup○ Build○ Test○ Test coverage with Jacoco and CodeClimate○ Notification: Email○ Status badges

Check docs for more features: https://docs.travis-ci.com/

Page 34: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

Thank you for your attention

In case of any questions:

[email protected]

Page 35: Continuous Integration · 2018-11-09 · Continuous integration and build server Written in Java Can be used to automate such tasks as build, test, distribute software Server based

https://careers.taxify.eu/ (We have office in Tartu)