Continuous Integration je velice důležité, leč často opomíjené téma. Většina lidí má tento termín zažitý jako něco co je složité a patří to do velkých společností. Opak je pravdou, CI můžete využívat i jako freelancer nebo malá společnost velice jednoduše. Ať už ho chcete používat k testování, nasazování, doručování buildu nebo notifikacím, ušetří Vám to hodně času a peněz. Dominik se věnuje problematice CI pro mobilní vývoj již více jak 2 roky a se svými kolegy vyrobil CI pipeline pro iOS, Android i backend, která šetří stovky minut denně celému týmu. Ve svém talku se zaměří, jak na mobilní platformy, tak na backendy a frontendy, aby si na své přišel opravdu každý.
4. Software Architect @ Ackee
Mobile developer since 2010
Teaching iOS on CTU (which also happens to be my Alma
Mater)
CodeCamp lecturer
Speaker
Introduction
5. 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
6. 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
7. 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
9. Continuous integration (CI) is the practice, in software
engineering, of merging all developer working copies
to a shared mainline several times a day.
— Wikipedia
10. What is CI?
Thats easy. Thats what we do already!
But is that helpful ?
We need to add more
11. What is CI? Best practices
Maintain 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
12. 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
14. 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
15. What is CI? App
development companies
Key part of CI for small teams is automation.
Everything else is a bonus!
16. 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
17. Time/Money/Brain saver
Bigger 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.
18. CI is on the rise
Virtualization architecture (Docker) makes it much simpler
and affordable.
Mature tooling
Developers are lazier
19. Is it safe?
Well definitely safer …
It should prevent from programmer errors
20. Is it safe? Quiz
Do 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 ?
21. Is it safe? Quiz part #2
How often you notify your co-workers about your deploy?
Shout out to the office ?
Email to all@company.com Subject: I just Released!
Write to slack channel ?
22. Is it safe? Quiz result
No you DO NOT
because you are humans
and you are lazy
23. 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!
24. 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
25. Is it safe? Commit messages
category: Not very helpful
31. 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
33. What Jenkins should do with
Backends?
Checkout revisions
Code quality check
Deployment
Notifying
34. 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
35. 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
39. NodeJS code quality - Testing
“Just testing” with automated start
Oh and “Blaming” feature
We use Mocha / Chai combo
History overview
again zero failure tolerance
41. 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
47. What Jenkins should do with
apps?
Run UnitTests
Run UITests
Run Linter & formatter
Build Binary
Deploy for tester
Notify
Go beyond
48. What Jenkins should do with
apps?
For building ios app you need mac
Macbook, Mac mini, iMac, Mac Pro
or … Mackee
49. What Jenkins should do with
apps?
UITests are pain
Unit testing is same as on Backend
50. 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
51. Building binary for iOS
Xcodebuild - horrible tool
XCTool - facebook wrapper around Xcodebuild
IPA - (yes it is actual name of this tool) simplified xcodebuild
Fastlane
52. 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
53. 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)
54. 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)
56. 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
57. 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
58. 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
59. 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
60. 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
63. 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
64. We are always trying to push
it further
If 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
65. 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