+ All Categories
Home > Mobile > Dominik Veselý - Vše co jste kdy chtěli vědět o CI a báli jste se zeptat

Dominik Veselý - Vše co jste kdy chtěli vědět o CI a báli jste se zeptat

Date post: 16-Feb-2017
Category:
Upload: mdevtalk
View: 76 times
Download: 1 times
Share this document with a friend
66
Transcript

DOMINIK VESELÝSoftware Architect, Ackee

Everything you always wanted to know about CI but were afraid to

ask

Software Architect @ Ackee

Mobile developer since 2010

Teaching iOS on CTU (which also happens to be my Alma Mater)

CodeCamp lecturer

Speaker

Introduction

2 years in searching for the golden grail in mobile automation

Motivation to save time and money by not doing routine work

Get the edge

Last 6 months pushing it to the limits

CI experience

Inspired by Woody Allen’s “Everything You Always Wanted to Know About Sex * But Were Afraid to Ask “

Series of short sequences (questions) about topic which should reveal all the important facts about Continuous Integration

This talk and movie parallel

What is CI?

Is it safe?

Which tools should I choose?

What it should do on Backends?

What it should do on Apps?

Does it hurt?

Is it worthy?

Questions

What is CI?

Continuous integration (CI) is the practice, in software engineering, of merging all developer working copies

to a shared mainline several times a day.

— Wikipedia

What is CI?

Thats easy. Thats what we do already!

But is that helpful ?

We need to add more

What is CI? Best practicesMaintain Code Repository

Automate the build

Make the build self-testing

Everyone commits to the baseline every day

Every commit (to baseline) should be built

Make it easy to get the latest deliverables

Everyone can see the results of the latest build

Automate deployment

Developers hate spending time with building / deploying

“I dont wanna do this monkey job”

Tester need build now … developer is busy or N/A

Scenarios for needs of CI

What is CI?

Huge software would take ages to build on workstation

Pipeline with QA / Testing / Reporting and hundreds of others …

Necessary for big companies

What is CI? Corporate edition

What is CI? App development companies

Key part of CI for small teams is automation. Everything else is a bonus!

Iniciative of Ackee to focus on good and clean solutions.

Leverage technology to improve your apps

We focused primarily on CI and testing for all our platforms

#rokkvality

Time/Money/Brain saverBigger app 344 builds 4 min approx for build and deploy

1032 minutes = 17,2 hours per 4 months

Which makes it 50 hours per project (3 platforms)

With 5 concurrent projects thats 250 hours

For work that is fully automated and you don’t have to care about it at all.

CI is on the rise

Virtualization architecture (Docker) makes it much simpler and affordable.

Mature tooling

Developers are lazier

Is it safe?

Well definitely safer …

It should prevent from programmer errors

Is it safe? QuizDo you write tests? — not part of a quiz (of course you do)

Do you enjoy writing tests?

Do you enjoy running tests?

How often do you forget to run tests before/during build?

How often do you make a mistake while deploying … wrong environment / wrong build etc ?

Is it safe? Quiz part #2

How often you notify your co-workers about your deploy?

Shout out to the office ?

Email to [email protected] Subject: I just Released!

Write to slack channel ?

Is it safe? Quiz result

No you DO NOT

because you are humans

and you are lazy

Is it safe? Quiz result

But! There is someone who does not mind!

Yes! It is Jenkins

He might be even enjoying it

He never forgets

He will always notify you!

Is it safe? Notifying

How Jenkins knows about what has been changed

Commit messages

It is tricky part when you have Dominik in your team

Is it safe? Commit messages category: Not very helpful

Is it safe? Co at least he tried…

Is it safe? Commit messages category: prayer!

Is it safe? Commit messages category: WTF?!

Which tools should I use? and Why?

First you need CI server software which is responsible for points 2-6

CI server options

TravisCI

CircleCI

GitlabCI

Bamboo

Jenkins

CI build

Build is “single work unit” with each commit / time / on demand trigger one build is started

Build consists of “unlimited” number of build steps

Build consists of “unlimited” number of post build steps

each (post) build step can change build status

CI build status

Success

Unstable

Failure

Custom?

What Jenkins should do with Backends?Checkout revisions

Code quality check

Deployment

Notifying

NodeJS code quality - Lint

Depends on how much “lint nazi” you want to be.

Checks for appropriate code style rules.

Not only visual but also semantical checks

Breaking the rules emits warnings / errors

NodeJS code quality - Lint

We chose ESLint which seems best performing and most active

With Airbnb code style.

You can setup how many warnings / errors makes build unstable / failed

NodeJS code quality - Lint

NodeJS code quality - Lint

We have 0 errors &

“unlimited” warning policy

NodeJS code quality - Lint

NodeJS code quality - Testing

“Just testing” with automated start

Oh and “Blaming” feature

We use Mocha / Chai combo

History overview

again zero failure tolerance

NodeJS code quality - Testing

NodeJS code quality - Coverage

awesome tool - Istanbul

tells you how much of your code is covered by tests

conditionals / methods / statements

again you can set up % for failure

we are very benevolent on this one :/ #rokkvality

NodeJS code quality - Coverage

NodeJS code quality - Coverage

NodeJS Deployment

Post build task. If build is successful you can deploy it

Azure / AWS / Bluemix / Heroku / SSH

There is always plugin for that

NodeJS Notifying we use custom channels for each project ci-project so it does not spam your project channel but still keep the relevance

What Jenkins should do with apps?

Primary focus is on delivering builds

What Jenkins should do with apps?Run UnitTests

Run UITests

Run Linter & formatter

Build Binary

Deploy for tester

Notify

Go beyond

What Jenkins should do with apps?For building ios app you need mac

Macbook, Mac mini, iMac, Mac Pro

or … Mackee

What Jenkins should do with apps?

UITests are pain

Unit testing is same as on Backend

Linting in Swift

We are “using” SwiftLint but it is very young project

Swift does not have its “good standards” yet

Swift3 would broke everything

Therefore “soft” code style

Building binary for iOS

Xcodebuild - horrible tool

XCTool - facebook wrapper around Xcodebuild

IPA - (yes it is actual name of this tool) simplified xcodebuild

Fastlane

FastLane

Awesome CI tool for iOS enables you tons of things including run tests, building, signing and much more

Detailed talk on it on mDevCamp

You can run it locally or on CI server

Building binary for iOS

Idea is build binary into file on filesystem and then distribute it

HockeyApp / TestFlight

Again there are lot of plugins

Troubles with certificates (Who would say that)

Testing for Android

Start emulator (there is plugin or script ready)

Run monkey testing

Then if you have UI/Unit tests in project they will run

Problems with Emulator (needs virtualization support)

Linting in Java

Available in Android build system

Unfortunately conflicts with RetroLambda

Building binary for Android

Multiple build types in Gradle script (Debug Beta Release)

Handles version code, obfuscation, test report, Mappings.txt and Apk

Than we just run the Gradle wrapper

Deploying apps

We use HockeyApp

We had upload to hockeyapp as one post build task in each job

Now we have separate job just to upload the binary and notify on slack in separate #hockeyapp channel which is really neat!

Good for testers and project managers

Go beyond

You can use your CI server to also create and upload screenshots

Tint your icon with beta flag

upload to the app store

more on mDevCamp

Does it hurt?

It could be pain and lot of headache

You have to update credentials

You have to update your Hackintosh :<

You have to update SDK

You are working with different versions of SDK with different projects

It is process so it sucks

Does it hurt? #2

When it does not work you have to find alternatives

You have to spend more time to write better code

Anyone can see your mistakes immediately

There could be some laughter

Does it hurt? #2

Is it worthy?

YES!

I can not stress that enough! YES!

All the time, money and focus it saves will not only make you work faster and better. It will make you feel

better about your work

We are always trying to push it furtherIf you wanna start with CI, let me know

If you come up with something better, let me know

Did you like my presentation, let me know

Catch me on twitter @dominikvesely or hashtag #rokkvality / #mdevtalk

Or lets have a beer @ afterparty

Key points

Don’t do work that can be automated. And it’s boring.

Keep focus on important stuff

Keep whole team informed

Save money and time

Catch me on twitter @dominikvesely or hashtag #rokkvality / #mdevtalk

Beer @ afterparty

WWW.MDEVTALK.CZ

mdevtalk


Recommended