Upload
sergiy-mokienko
View
46
Download
1
Embed Size (px)
Citation preview
Continuous Integration in Android
Sergiy MokienkoAndroid developer
Make round picture online http://www.cutmypic.com/
#dfua
The only thing you should care about is code.
Foreword
#dfua
Journey begins CI what are you ?
#dfua
The main thing about Continuous Integration is delivering features without breaking your solution
#dfua
Steps
Code
Test
Merge
BuildDeploy
#dfua
No way to merge without testing
#dfua
+ + =
#dfua
VCS
#dfua
Benefits
Jira integration Slack integration Access management
Pull requests
#dfua
Benefits
#dfua
Strategy
Tim
e
devFeature
branches
Starting feature
Merging feature
#dfua
Merging policy
Pull requestAuto tests
Staticanalysis
Code reviewMerge
#dfua
Pull Request
Leave comments
#dfua
Pull RequestSee changes
#dfua
Pull RequestBuild on pull request
#dfua
Pull RequestEasy merge
#dfua
Auto test
Test Java Separately
#dfua
Auto test
Unit tests should be fast
#dfua
Auto testKeep tests relevant
#dfua
Auto testUse spoon
#dfua
Auto test
#dfua
Static Analysis
#dfua
Code Review
Look for potential bugs Verify tests coverage
#dfua
Code Review
Project structure not violatedRun happy path
#dfua
No you are ready to merge boy =)
#dfua
Version naming
#dfua
Strategy
Tim
e
dev masterFeature
branches
Starting feature
Merging feature
Release0.2
Hot Fix
Release0.1
#dfua
#dfua
Build & Deploy
#dfua
Build server
#dfua
Build server
Open Sourced
Plugins
Free
Easy setUp
Scripts support
Build agents
Variety of build triggers
VCS support
Remote test Run
Poor git support
Plugins
No default support for build agentsYou have pay for it
#dfua
TeamCity Build configuration
VCS RootBuild triggers
Build steps
Failure ConditionsArtefacts
#dfua
TeamCity Build configuration
- Script supports
-Attach several VCS roots
-Build dependencies between jobs
- Select branch for build
- Schedule triggers
- Repository manipulations
#dfua
Version naming
int majorVersion = MAJOR_VERSION as intint minorVersion = MINOR_VERSION as intint bugFixVersion = BUG_VERSION as intversionCode majorVersion * 100000000 + minorVersion * 1000000 + bugFixVersion * 10000 versionName "" + majorVersion + "." + minorVersion + "." + bugFixVersion
#dfua
gradle.properties
MAJOR_VERSION = 1 MINOR_VERSION = 19 BUG_VERSION = 0 COMPILE_SDK_VERSION=23 BUILD_TOOLS_VERSION=23.0.2MIN_SDK_VERSION=16 TARGET_SDK_VERSION=23 SNAPSHOT=trueSNAPSHOT_ANALYTICS=falseAUTOTEST=falseCONNECTION_TEST=falseMIXPANEL_QA_KEY=1234567890BRANDS_DIR=brandsBRAND=internalSERVER_PROJECT_ID=123456789LEVERATE_PASSWORD=leveratepas
#dfua
BuildConfig
String snapshot = (Boolean.valueOf(getProperty('SNAPSHOT').toString())) ? "Boolean.parseBoolean(\"true\")" : "false"buildConfigField 'boolean', 'SNAPSHOT', snapshotString snapshotAnalytics = (Boolean.valueOf(getProperty('SNAPSHOT_ANALYTICS').toString())) ? "Boolean.parseBoolean(\"true\")" : "false"buildConfigField 'boolean', 'SNAPSHOT_ANALYTICS', snapshotAnalyticsString autotest = (Boolean.valueOf(getProperty('AUTOTEST').toString())) ? "Boolean.parseBoolean(\"true\")" : "false"buildConfigField 'boolean', 'AUTOTEST', autotestString connectionTest = (Boolean.valueOf(getProperty('CONNECTION_TEST').toString())) ? "Boolean.parseBoolean(\"true\")" : "false"buildConfigField 'boolean', 'CONNECTION_TEST', connectionTestString mixPanelDebugKey = ("\"" + getProperty('MIXPANEL_QA_KEY').toString() + "\"") buildConfigField 'String', 'MIXPANEL_QA_KEY', mixPanelDebugKey
#dfua
Email Notification
<TeamCity data directory>/config/_notifications/
Including ERRORS from the log
<#list build.buildLog.messages[1..] as message><#-- skipping the first message (it is a root node)-->
<#if message.status == "ERROR" || message.status == "FAILURE" >
${message.text}
</#if>
</#list>
#dfua
Email Notification
<TeamCity data directory>/config/_notifications/
<p>Build artifacts:</p>
<#list build.artifactsDirectory.listFiles() as file>
<a href="${webLinks.getDownloadArtefactUrl(build.buildTypeExternalId, build.buildId, file.name)}">${file.name}</a> (${file.length()}B)<br/>
</#list>
#dfua
Unit testMerge to any feature branchOn every pull request
JUnit tests onlyLint inspections
Test reportLint report
Cancel PullRequest if test fails
#dfua
MergeOn Every PullRequest: Feature branch -> dev Hot fix -> master
UI Tests on device
Test report
Cancel PullRequest if test fails
#dfua
Nightly build
Scheduled Every night on dev branch
Runs full Test run of All test suits on all relevant
Test reportNotifies all team with results
Notifies all team with results
#dfua
Debug deployment
Triggered on every pull request:Feature branch -> dev
Builds debug version of the applicationUpload debug.apk to your debug build delivery cloud
debug .apk
#dfua
Debug deployment
Triggered manually
Builds release version of your applicationCreates a tag with release version Uploads release.apk to google play
release.apk
#dfua
Release deployment
Triggered manually
Builds release version of your applicationCreates a tag with release version Uploads release.apk to google play
release.apk
#dfua
Deployment debug
#dfua
Debug deploymentif (project.hasProperty("deployGateToken")) {
apply plugin: 'deploygate'
deploygate {
userName = "username"
token = project.property("deployGateToken")
}
apks {
release {
sourceFile = file('build/outputs/apk/sirix-debug-' + android.defaultConfig.versionName + '.apk')
}
}
}
#dfua
Release deployment
#dfua
Release deployment
apply plugin: 'com.github.triplet.play'play { serviceAccountEmail = 'your-service-account-email' pk12File = file('key.p12') track = 'production|betta|alpha' uploadImages = true}
#dfua
Good to have
#dfua
Summary
Use correct toolsMake your tests fastAutomate build delivery everywhereUse good VCSUse cross platform toolsGive gradle a chanceAutomate you release cycle
#dfua
Questions ?
Mokienko Sergiy@[email protected]://www.facebook.com/Korwin22
Thank you!
#dfua
Resourcehttps://www.jetbrains.com/teamcity/documentation/http://square.github.io/spoon/http://nvie.com/posts/a-successful-git-branching-model/https://github.com/Tapadoo/TCSlackNotifierPluginhttps://github.com/Triple-T/gradle-play-publisherhttps://deploygate.com/?locale=enhttps://get.fabric.io/https://www.sonatype.com/nexus-repository-sonatypehttp://cyrilmottier.com/2014/12/09/a-story-of-software-development-methodologies/https://www.reddit.com/r/androiddev/comments/3ig3gm/show_us_your_gradle_tasks/https://medium.com/@jordanjoz/streamlining-eeros-android-build-process-6a870ef40a89#.1psxvs5kqhttps://medium.com/fuzz/getting-the-most-out-of-crashlytics-380afb703876#.5vyv6s5hc