Tuesday, October 30, 2018

Travis-CI - Continuous deployment to staging but production deployment only on tag commit

Background

Travis-CI is a hosted Continuous Integration & Continuous Delivery tool. Based on configurations, users can have their application deployed to production. They provide free service to open source projects. The CI&CD environment currently using Linux.

Aim

  • Have the CI & CD pipeline trigger for each and every commit going into GitHub. Deploy only to staging or testing area.
  • Testing / staging area is GitHub pages hosted in the same repo. Deploy to staging should not trigger another build which ends up as infinite loop. Not into gh-pages branch but to \docs folder.
  • When there is tagged commit deploy to production.

How its done

Avoid build on commit from Travis-CI bot

The word bot is used to indicate the CI&CD account used by Travis-CI. We can see that account on the commits from Travis-CI. When the bot commits, it uses message as follows.

""Deploy <github userid>/<project> to github.com/<github userid>/<project>.git:master""

One such example given below.

"Deploy joymon/prayerbook to github.com/joymon/prayerbook.git:master"

We need to write build conditions at the top of .travis.yml file to bye pass the build if the commit message is matching.

Build and deploy on commit tag

This is another condition we need to put into condition. If we don't put this Travis-CI will not build on tag commit. Below is one example.

if: tag IS present OR commit_message != "Deploy joymon/prayerbook to github.com/joymon/prayerbook.git:master" OR tag = true

If we use tag = true alone it may not work. Needs more analysis on the Travis-CI yml schema.

A sample travis.yml file can be found below which works based on the above conditions.

https://github.com/joymon/prayerbook/blob/master/.travis.yml

References

https://stackoverflow.com/questions/18216991/create-a-tag-in-github-repository
https://docs.travis-ci.com/user/conditions-v1
https://github.com/travis-ci/travis-ci/issues/8518

Disclaimer

The author is not working for Travis-CI or any of their subsidiaries or partners. There is no guarantee that the technique mentioned in this post will work forever. Travis-CI may change their system the way they want it to be. 
This is not at a sponsored post.

Tuesday, October 23, 2018

Explaining youtube down to 4 years old kid

Though I had written about explaining technical things to kids, this is the first time I had to try it in production. At the time of writing this post 16oct2018:10PM EST, Google's well established youtube.com is down thus I got computer from my 4 years old son.

https://twitter.com/TeamYouTube/status/1052373937839980544
https://www.cnbc.com/2018/10/17/googles-youtube-outage-affected-users-in-us-australia-asia-europe.html

He was angry and slowly moved to crying mode when he understood there issue which his dad cannot fix. Below were our attempts to make him understand the situation.

Attempt 1 - Sympathy

This is my attempt with over confidence that I had writing experience of how to explain tech things to kids. Though the words were not exactly same as we speak mostly in our mother tongue Malayalam at home along with English .

I - Son... you know the youtube is a website which is built and maintained by engineers like us. Your mom also an engineer though not working now. There are some troubles in their computers and those poor guys now will be working hard like me. We have to wait till they fix the issue. 

Son - What? youtube is not working. Fix it...

Attempt 2 - Tech explanation

My wife started laughing already. But I did one more attempt.

I - You know...the videos you are seeing in our computer is not actually in our computer. Someone else uploaded those videos into youtube's computer sitting far away. Those youtube's computers are down due to some issues. We cannot do any thing from here, they have to fix it. 

Son (with no hope on me) - Can you fix it?

Attempt 3 - Mom's version

Mom - Son we usually call your dad when he is in office. right?
Son - yes
Mom - What if his phone is not working? We keep calling but we cannot speak with him.
Son - yes
Mom - Our phone is good but dad's phone is not working. Think youtube is dad's phone and is not working.
Son (sad) - ok. Lets sleep.

Tuesday, October 16, 2018

Progressive Web Apps - Index

Intro

Progressive Web Apps or PWA technology is expected to end the nightmare of developing platform  specific apps for achieving one purpose. Currently this is tough for mobile developers as they have to develop for Android and iOS. Thanks to Microsoft for ending Windows phones. But still there is Windows app store where applications for Windows 10 can be downloaded. Still its nightmare to have one app working for all the platforms though there are many technologies are there to address the same such as Xamarin. Yes that is a big prediction that one day PWA will make Xamarin like platforms obsolete similar to how HTML5 made Flash & Silverlight into history.

https://en.wikipedia.org/wiki/Progressive_Web_Apps

The purpose of this post is to index all the links related to PWA in one place at least for my personal use. It will be including links my future PWA related posts as well. I am not the person doing it and I tried to include similar indexes at the end of this post.

Basics

Feature detection

Not all browsers support PWA also not all support all features. Since PWA included bunch of features, better do feature detection than checking the browser version.

Features

Below are the features of PWA. Not a complete list as its still evolving.

Navigation Preload

Offline Storage

This is not really PWA feature but can be leveraged to build offline application.

Service Worker

Highlight of PWA which help us to develop offline applications

This will take the web apps further towards native feel. Also help us to reengage users. 

Installation

Another highlight. This feature is going to help us to get our web apps installed as native apps.

Publishing to AppStores

The app stores are getting PWA apps along with native apps. One day there will be more PWA apps than native. The day where all the device capabilities/APIs are exposed via PWA specs.

Developing PWA

What developers needs to know about PWA.

Debugging and experiences

Seems little difficult to debug at this point. But will definitely get improvements over time.
https://developers.google.com/web/fundamentals/codelabs/debugging-service-workers/

Testing PWA

In the world of DevOps we need to have coded test cases to have continuous delivery. This space needs more innovations.

Platform specific

Not all platforms started supporting same way. Below goes platform specific details. Hope some day I can make this section obsolete.

Windows

Sample apps

We are not alone. There are apps out there which use PWA. Its reality.
https://pwa.rocks/

For quick demos

https://expensemanager.demo.vaadin.com/ - Keeps data in local cache, Installable

Source code

Some repos to browse for PWA.
https://github.com/GoogleChromeLabs/airhorn - This demonstrates the installation scenario

Other indexes like this

https://github.com/hemanth/awesome-pwa

Tuesday, October 2, 2018

Online diagramming tools

We are living in the age of easy software development and business friendly environment. Lot of things are free if we want to develop software or start a company than 10 years back. Diagramming was difficult earlier but now there are lot of tools to create good stunning diagrams. Below is a list of online browser based diagramming tools for software developers and architects. All are either free, or has freemium pricing model.

General

Below has general diagramming support as well as software engineering diagrams.

www.draw.io
https://www.lucidchart.com
https://cacoo.com

https://cloudcraft.co - AWS specific, 3D diagrams

Architecture as Code

https://structurizr.com/ - Used to draw C4 arch diagrams using code!


This list demands periodic update as new tools will appear and some fade away or move to paid model. Hopefully updates can be done at least once an year.