Sunday, March 16, 2014

Continuous Integration and Deployment with Github

[CODE]


Jenkins:


I didn't have good experience with Jenkins. In summary, something caused Jenkins to crash and I had to reinstall again... I repeated a few times and I decided that this should be done by someone else.
So I then went for hosted Jenkins. It was better but things weren't working everything perfectly just yet especially when creating test database.


I need super easy way to achieve Continuous Integration:


My co-worker mentioned that people at one conference was raving about codeship. Tested out free subscription. It is ridiculously simple and intuitive (just like when I found ansible while I was struggling with puppet). Best of all, there is small "?" button on bottom right corner and you can ask questions when you stuck and knowledgeable engineer would respond to you within 24 hours or so. Just fantastic.

Now to achieve Continuous Deployment:


What I end up doing is to setup deploy server which runs small flask (python micro framework) application and listens one type of request which is POST request from Github Webhooks.
Flask app will read payload from github and trigger ansible deployment script (via fabric) if commit / merge is made to master.
Once deployment is completed, it will post to private twitter account (this piece of code also on fabirc which is wrapper to ansible) that our team subscribes. The post message includes dev's commit message as well. I like this so far.
Because we are python shop and this approach will give us not only flexibility but ability to debug any issues easily.


Saturday, March 8, 2014

Play with Angular: Get help from YEOMAN and Debugging with WebStorm


note: AngularJS is amazing.
warning: don't think in jQuery, think in AngularJS 

the developer is trying to "do jQuery" in the context of AngularJS. That's never going to work well. The view is the official record. Outside of a directive, you never, ever, never change the DOM. And directives are applied in the view, so intent is clear.

1. Let's start on the right foot: scaffolding workflow
2. Configure grunt server on WebStorm: so no need to start server from terminal app
3. Productive: 
Install AngularJS extension: more autocomplete to be productive
4. Debugging: 
Setup Debugger: so that we can be stress free (or minimum stress)
5. Process: Let generator do the job
6. Learning: Study & Get Help


1. Let's start on the right foot

Let Yeoman do the job. Yeoman will help us "scaffolding workflows for creating modern webapps, while at the same time mixing in many of the best practices that have evolved within the industry."

Install the required tools globally by running:

$ npm install -g yo

above command will installs grunt, karma etc
Karma: unit test framework specifically made for angular based application
Grunt: JavaScript task runner - automate various repetitive tasks such as js minification, reload server on change etc

$ npm install -g generator-webapp
$ npm install -g generator-angular 

I am going to call my application angular_play for this test project 
$ mkdir angular_play

open the directory you just created (angular_play in this case) from WebStorm

from WebStorm terminal interface, run the following to scaffold out a AngularJS project

$ yo angular  


install a dependency for your project from Bower
$ bower install angular-ui    

test your app     
$ grunt test

preview your app (formerly `grunt server`)              
$ grunt serve 


build the application for deployment             
$ grunt                            

Thank you YEOMAN!

2. Configure grunt server on WebStorm


"edit configuration"

"add new configuration" (command + N)
select Node.js and enter following parameters:


play "Grunt Server"


3. Install AngularJS extension 

WebStorm > Preferences > Install JetBeans plugins > Browse Repositories > "angluarjs" > double click search result and install

Ta-da! nice autocomplete and other support for all of the ng-goodness 




4. Setup Debugger

4.1. with WebStorm:
WebStorm > Edit Config > add "JavaScript Debug" > Specify file you want to debug > Click debug

Every time you reload page, it stops at breakpoint you specified!

4.2. with AngularJS Batarang Chrome Extension:

You can install AngularJS Batarang Chrome debugging extension for debugging and profiling. This performance tab comes in handy when you use function like $watch (listen for change)



4.3. Set "Pause on all exceptions" to halt when an exception occurs

Chrome > Dev Tools > Sources > toggle with icon looks like pig nose 

5. Let generator do the job

Why not use generator? 
from WebStorm terminal, just run command available 

6. Study & Get Help

egghead.io: web development training with AngularJS


Lastly....
feeling about AngularJS shown below (from Mr. Ben Nadel's blog) seems to be fairly common among devs. So let's not give up until you feel like "this is most awesome framework ever!"