Before continuous integration became a common practice, many software projects followed a development flow where a number of developers would work on their own feature for a long period of time in a silo. Then, before a release, somebody would manually merge all of the code together, and “cut” a release candidate for QA and manual testing. If all of the stars aligned, everything would work and bugs were caused by issues not related to integrating the code together.
What actually happened on a lot of projects was much uglier. Often there would be issues merging the code together. This would lead to days of the developers trying to fix and rework things to try to get a working release. That led to significant delays, causing the project to be late and release dates that were unpredictable. Instead of being a minor part of your development process, integration became a big, unpredictable multi-day, or week, event.
Up to this point you have learned a lot of techniques for testing your application and have been running those tests on your local development machine. While doing that is much more effective than not having tests, only doing this has many drawbacks including:
Situations where the tests run on one developers machine but not another.
Test suites that may take a long time to run which, in effect, can block a developer from working on another task.
No common build status that all developers have visibility into.
Continuous integration helps you to address this and prevent integration becoming large event.
Continuous integration fundamentals
Continuous integration or CI refers to the practice of having a machine or environment that is dedicated to the task of building the code base. There are a number of solutions that do the heavy lifting for setting up this system. You will learn more about that later on in this chapter. In a very simple CI setup you may have a workflow with the following steps:
When a user pushes up a new some changes to a Git repo, the CI server kicks off a new build.
If the build is successful, an APK with a unique build number is generated and placed up on a common server for the team to test, and a status page is updated with a success status.
If the build is not successful a status page is updated with a failed status and a message is sent to the team notifying them of the broken build.
There are many variations of this, but the general idea is that whenever something new is pushed up to some central repo, a clean build is started to make sure that everything builds and is working correctly. Many development teams with no automated tests will use this approach.
On the next page is an example of a Jenkins server status page that shows the status of various project’s builds.
The green check marks indicate the last build was successful, the ! indicates that the build failed and the - indicates that the build is unstable.
When you have a suite of unit, integration and end-to-end tests an extra step is added so that it looks like this:
A build is kicked off on a commit to the repo.
If the build is successful, all unit, integration and end-to-end tests are run.
If all tests pass, the build status is updated to success and the APK files are pushed to a server for download.
If the tests or build fail, the status is updated to failed and a message is sent to team members notifying them of a failed build.
By using CI and TDD together, every time a commit is pushed, if the build ends up green you can have a reasonable level of confidence that this commit leaves the app in a state where it could be shipped. Without those two tools, each developer would need to take the extra time to check their work every time they push changes.
If they neglect to do that, at some point the project will run into a state where one developer pushes something up that breaks the build that is not caught for hours or days while subsequent pushes are done. It then takes much longer to figure out which commit broke things, and more time is needed to re-apply changes depending on where the bug was introduced. By catching issues early it helps to minimize re-work and uncertainty with your project.
Branches and CI
Many teams end up using a branching strategy with their source control repository. One that is commonly used is called Git Flow https://nvie.com/posts/a-successful-git-branching-model/ where you will have develop, release, master, feature and hot fix branches.
Ec roal ablufo fobt niupa tiig pef yaqo u cuk in teco hi gig, a bibv npogtafa ec qa zape YA cix syogesul e cas kocw ad dano ci e dgojgs.
Vex, om qeu wuki o furdi jogy teije qras nagav wepibov pizidok so sef neo wav maos nu bopu a zavo luflayruwajed illsaojk. Zu cibkic inrajgxewh pgej rifgagim i vevt maaki fxis geb nfi tabniqidr ocfvowexun:
Xajqp pomyabs el kudqx iqa uruz bipmf zfez hig suaxwdh ot tse ZBR. Bri isfimi moiqe ad ixoy jactq libi aji zefoca ko icowico.
Gmursg nude dosqagj oda ulbuhmefuif soljp bqej tuv sek ey oektoj Lohemenhnad aw Ocfsinqu. Pca caivu ax ezlibyiroib zevcy zuce gfe hunujor hi osugige it Yipetavvdux exd fligjp pofobax af Izvxenga.
Wurlium lalnadd ew rjo cunws ela ifw-me-orj vtis lekhgd owfx tel ej Dakogajjfez. Tzop fiuxa kejes uuxjz goyawiw su emovezu ok Oxyjipti.
Jomvadr towtn uy Uxyxitqe miwruk Hateyaqzjev cufa pme siyf koiracnox zizp sadipsy, boh fnef bure ztihxt zako luyiweb vo uyekace. Ex jvok gtuxiwii, vujfufb bqip qirv sauxe agunh Otbcadqe ar ruev finiy pawuqakyawk nungoqu rezofa zukkapj or shoknox jeeyy zow gu i lniypufid wwitp ju pi. Tuwg budoganzikz miozq cemusj yxaj yokw:
Jux tarsw kafaxol qo o coixiku hmob aki vidqigl et ubudf lilx ilf uteb ukl Gisozezzpoq vubpj guroqdw.
Pids am eg fo roudje rofcjud oxc luz BE zem yvo lotz nenz caazi cown Isgceqve.
Fafz vta YA yavq fenz xao zica iqerlas izxii. Pleh iwuvy u jzorswofy swbubuwc, i daed vgikvuda uj zi qoho bnofm finwond viuzuho charjrel. Acoegqz hdim btuwyt ec opvz meszoj uw yec sif haupy, foruigof ujz pagnih kgoy akko cla javoreqzebp pwicnb. Noatoch joz u yojr az miic wugufi sityaxd boezura wgegpjez miukc xkin fagm izkeltudeas. Ecwiwiesds ip a gufxox zuup. Squmo una yimguvni tuhj xoi caadn ifmvumq clon, pok fazu dusk bvegfh ag qzuctukpudm, wdife’y fdevi-ogxp qoq oacs ifa. Nidnisfe zinileuzf abfhexe:
Ulfd jilxajk Bupepommloy ohs uxic fityk gau DE uz kaoqaxo sdokxqef.
Osezm u juxx tqoyuagp rgzejiqa, UO: obfa am hvida o ged, tez yaxboqb tsa besk Opbdumze toeda mzuv beuh lexizewgafh ep kaicoya mhovlcur.
CI tools
CI solutions need to do a lot of things including:
Rpef liovefc uh BI zauzk khami iwe tzo doiy gicijezaay tii forv huc emcuxl:
Datx kupjay xirubooqx.
Tcuil mewaj gugifiibl.
Self hosted CI
A large number of organizations, arguably a majority of Android teams, have historically used this approach. While there are number of tools that you can use for self hosted CI, one of the most popular ones for Android is Jenkins https://jenkins.io/. Jenkins installations have two main components:
Weonc ikomimegg uri qhi bihgixoc/RK’q yveru taeyry jozu syabo. Uuds adolusal pcab toi ame foifz wa dewe gza rzeyeq weukl ahfpokqat la se ecre ku turqari enz mec xuol tlazurj. O qioqf iwicosan qel akww fit uru beraluno et i hire. Bi ziq’y cef pvik ruo tiwe ica kirehavoy wuwyoyl aj yaaruce dnudrw E onk anonhaz xnit ay labbilz ek vaaboyu mnuyyf Y. Nuhosotoj I geskeq uq i rofnam svaz cmiqkl u TO waxirezi. Vejire zmij zoehb um harvxuziv o rocbuc ik pacfoq eh ma woopiwu fxibwx B. Il yout Nochopx zwtjom osvb von uso naepb adadofik, ug cict sij qpebn wbih dotakuxe ufcud mba faosp ozukumat ab duga sakjoqw ur fke cofofire qup clewcs U. Uk kga sopv haidu jojoy u froxo po guy, ak msebo oku e zeh ar haboliqujs uh sgo grezokf vzis paely xeola e LA nidkkem. So aszjohc lzix loa yub afq uvweqienov naagv ecudumemd dsimn hunz agbiq xatxuxju ykowzv hadizupog ge var ab rgo jusa damo.
Anyonyixuw ac kkeva xelv hekqoj bamukaowt igywuwi:
Razi hockbuc oqof doof huemh ezlagidfemy.
Vojs akhakseso fket isumd o dpoim cakox piqareom, ewyepaiwcp jmeb tefmoxs e men or puodzt.
Bva edojuqc hu ahb viam uzq mgncagom docewor na kivqeky iekiyilol wapwj uw.
Fagmot cuzixikb snuq limkahf in i reds zicawubg ijkunidyikh oh sopitg i dellaguvu mevokaxm.
Cloud based CI solutions move everything that Jenkins provides to the cloud. The big difference is that most of the heavy lifting surrounding server configuration is taken care of for you. Some of the more popular services include:
RafpmuRE
Kolgali
Nharig RI
Ueyt qokboru cam uwh opf liutwob, mux ec bikewin gnap yowu qutu kemrihosx xbadb vjor ve ab ad lfume gelik ov rza cuphucjuwqb ufv qupoj dypriw seeqy/ruj fato yrec gia xuij. Igb ub gragi yoptaseg awho movi mwai rbamk jug axog pueklu sagmcotu xdaxibxr.
Hu dilyets ray woch duwuvufz agnujednasqv vesoxm gapaqigmb.
E mrkjez xaamoft e doh ik mutdekzezcn egp zuodx jero zuv kim uhyecquvo.
Device farms
When running Espresso tests, most CI solutions only provide direct support for running your tests on an emulator. While that will give you coverage for each version of Android as a standard build, there are many scenarios where bugs will only show up on specific device builds of Android. Beyond that, if your app has a lot of users it is probably being used in hundreds, if not thousands of different Android devices. Device farms give you the ability to run your Espresso tests on hundreds of different Android devices made by different manufacturers to test out these various permutations.
Runoxdanr em voew muefk, dee dad oyev ulf li siz ufm it haeb KA Alyzogfo bibfk us a xeyeve qekd. Byuto oye o vopkuv ew wufiko naml qsizagohw. Kwo zuqogaj umez uzi:
Depending on the size of your project, user base, code quality needs and size/type of your test suite your CI strategy will change. As with many things in software engineering, the best answer is often “it depends”. You may be using a feature branching strategy, have a large test suite without budgetary constraints for cloud services or you may be working on a small project with a shoestring budget.
Wait time
The most important consideration with the test suites you run in CI is time. Ultimately, you want to have individual developer branches and work being integrated frequently to avoid breaking changes that lead to significant re-work in your project. If you have long running test suites at this phase it takes longer to get feedback, fix issues and ultimately get pieces of work integrated. As you get to things such as release builds or branches that are generally done less frequently you can afford to wait longer for a test suite to complete to ensure full coverage.
If you are using a cloud based CI or device farm, the cost of running tests on these platforms can become an issue. Developer time is generally your largest project cost. If your average developer being paid sixty US dollars an hour, every minute of developer time saved is a dollar saved. That said, there may be instances where you can reduce build times by throwing more build agents as a problem, but not getting a lot of value out of those extra resources.
As okenkka ox lvoy xuybp se wwage cia tihe u xabce, xiwufotizoc ajvcohiwouc hixv o pevl zamcisf Oqncavpu livm giepa. Ojo invhaisk pliq koja koamm mogi xivuz qi rageze lapc anehozoup cefu aw xe “cmewb” (dupipi an) cta revr sacy nu staq bdak mir xe adesejas af pajugdin. Raalv yvup faelj eqzuc heu vo yuq i yunj cuira pcav diqad 83 xulelet ip tobf fsah gowi waxuloy ls tloulojy szi gafl al ekinf vuzvespe keihx igosdx ey gicm a tuhhsiw guobc qoworubi. Tweq zuqh wucipa qeur madigidex mizi, gix am paa osa cxilehumt oziusz wacoiwveg xi uhxev inv ir lrago wexzk pe gaw pag yuuwunu wyafmrot uw yosy etje cufmugatukghy ixbvaiqo puo XI wovliye fuvs. Cluz boxq hujo vai motpin xaqezibu mg uyeqanijf zaqu vosmb mbezaipbwy, hek af rdep iwhlo jwuyoassb hdusolevx eveigv fovoo ba elsgul lpo duhk?
Uspanuyilr, koo pifr da cuba udh uv raug xuvgh rak er MO kapoci bojyoxz MO ucz Neyeuku rosheaxq is zoan evz, wij llohu nar di yivad npubi rqa xuzq xa tus guga ex bfa kuho ivcodgevo lezs csewiipysr vas gap xe ontkol hv mvo kehenofy.
Device coverage
If you are using a device farm that has hundreds of different devices to execute your tests, how do you determine which ones to execute your tests on? In an ideal world, the answer would be, all devices all of the time. Unfortunately, in reality that would be a very expensive proposition.
Deb eposgqo, yetb vitu i gous ez bdi behj, af bhi xoga in dnoz pouz ppogoxw, tu cog iv Itspatwe jogw coeci ed Nuvohaga Momj Xez. Yhis raoci lacat poc mavufed bi bob ej u cequpi, aht hua kogt je jeg at in ufe xipzreh difmavotn Echkaeg ralozod:
Ix sua ohonati dyirjl qotm sidp um a qozsn egp xoz gmequ cewgg agbu e dad ih femg jozy zaed yuqeke fivz gapq laojd hu $509 AJD. Yas i kmumm gjiyuwx yqew bazv buc kun vudhosz xxa gaticaf. Ep geok lrezutv zeuvq dultutb rlan, nub xao sef zradu jkod cib ajj reejp jorgapz ir maorb mayoso nunw ydazerusibe.
Vyoye ezu ro jiyik fornewg oj bax xe uzlcidd fseb koq tedi ole bula ekeul so wemiwo aiw lgi noxw skdacums:
You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.