Dev.Objective Notes: Automated Hybrid Application Development And Release - Trevor Brindle

June 21, 2016

(I had never seen Trevor give a presentation before this — it was a great talk full of useful content.  Shameless plug: he and I are both speaking in September at NCDevCon.  Hopefully we don’t have conflicting timeslots, I want to see his session on Vagrant for mobile dev! Dan, please don’t schedule us at the same timeslot! ;) )

Why spend the time automating things?
Consider not only your own time, but your team’s time as well
if you’re setting up/cleaning/deleting/etc,
…you’re not coding. you’re not doing what you’re paid to do.

when tight deadlines come up, you often cut corners. 90% of the time TESTING is what gets cut

with mobile - delayed rollout for updating, not everyone updates at the same time

automation lowers the threshold for entry. new developers need to set everything up.

keep developers doing what they do best - ACTUALLY coding

fixing a bug in “maintenance” after the app is in prod costs a LOT more money than fixing it early in development.

continuous integration
- on every commit, you build and test your app
- if tests pass, you’re ready to go to QA or back to Dev for more features

continuous delivery
actually BUILDING the app and pushing it somewhere as the build artifact for it to be distro’d
Test Flight, HockeyApp, etc
on every commit, build/test/deliver and ready for QA

continuous deployment
on every commit, build/test/deploy and ready for the PUBLIC

CI solutions (i.e. a platform to handle this for you)
Jenkins / Hudson (same product w/ different names).
Most popular
java app that integrates w/ your repo, kicks off builds, etc.

(it doesn’t really matter WHAT you choose)

Circle CI / Travis CI
cloud based solutions so you don’t have to manage the hardware
they come w/ their own setup issues (but so does Jenkins)

6 components of successful / sustainable CI solution
setup
configure
clean
build
test
release

setup -
self contained script to set up your build env
node, npm, cordova, Xcode, etc — all of that is scriptable

configuration
ability to change end points, settings, preferences

clean

build
grunt, gulp, etc (not ALWAYS necessary to use these, might be overly complex)
grunt is known for maybe being overly verbose

“make” - build automation tool from the 70’s, simple commands without the possibility of dependencies breaking, no chance of API changes, etc.
use ANY scripting language
#!usr/bin/env
just point it to your correct interpreter and it will do the rest for you
alternatives: grunt, gump, broccoli, npm scripts, etc
“makefile” stores your build script

setup —
Vagrant is a great tool for this
no incompatibilities
update everyone’s build machine at once
spin up a new server in minutes

Make sure you script it.
(can’t script installing Xcode, but everything else you can)

configure —
think about a 12-factor app http://12factor.net
template for setting up Node apps (there are 12 factors to it. duh)
- script separate of config from code
- anything you might have to change, it should NEVER be in Git/SVN/etc
— have to assume it could be visible to the public at any point
— last thing you want to do is release a Prod app with Dev endpoints and API keys in it.

clean —
no matter how good your gitignore is, or how amazing your tools are, you still need a clean script
Native projects have intermediary files that often get cached and can cause hiccups in the build, can deliver cached content when something DID change.
running a “clean” will take out all the caching, can pre-compile stuff ahead of time so things run faster, etc.
clean should force a “full fresh build”
don’t go crazy because something is messing with you, just write a “normal” clean script

build —
whatever you use probably already has a CLI tool
ionic, babel, lib sass, posts, react, etc,

testing —
1000’s of kinds of tests
do ALL of them
do any/all testing that you can

release —
fastlane - toolset of ruby gems, takes pain out of releasing iOS apps (android support coming soon). screenshots, certificates, xcodebuild CLI, provisioning profiles for iOS development, itunesConnect upload your binaries/metadata/screenshots automatically, push, googleplay — all get automated via FastLane


CodePush - Microsoft thing. Cordova plugin/service, you can upload your build artifacts to. on app lifecycle events, will ask if there is a new version available, silently download and will use it on the next app start. Amazing, and it’s FREE!
— very well documented
— works w/ React Native and Cordova
(theoretically it should work for NativeScript too)
use cases -
emergency bug fix
new feature
content update
(Apple is actually okay with this process.)