Travis CI config for Python + NodeJS

I currently work with the Gluu Federation – an open source company. My present job is to build a Web UI for the cluster management using the available API.

We use Python Flask for the Backend and AngularJS+Bootstrap for the Frontend. Pretty much a standard affair these days. Testing is crucial and we have the backend tests in Python Nose and the Frontend Unit tests using Karma and Jasmine running on NodeJS.

Now the question is how does one configure the Travis CI .yml file to perform tests in a both Python and Javascript. I initially set up using language: node_js and ran only the frontend tests. Then I went around searching and stumbled on travis-ci – issue#4090 – Support multiple languages. Thanks to the tip from @BanzaiMan I now have both frontend and backend tests running with a simple yml file.


language: python
python:
– 2.7
install:
– pip install -r requirements.txt
– nvm install 0.10
– npm install
before_script:
– export DISPLAY=:99.0
– sh -e /etc/init.d/xvfb start
script:
– nosetests –with-coverage –cover-package=gluuwebui
– npm test

view raw

.travis.yml

hosted with ❤ by GitHub

Getting ready for planet CODE

With the end of TeachForIndia Fellowship around the corner, I am contemplating on jumping into the programming world. So here is a checklist of things that I am going to put up in place and document it along the way.

Get a decent mail ID

Though not strictly related to planet code, I wanted to have a decent email id. The one I used ~~aruntheguy at gmail~~ was created when I was 15 and not so professional. Hence I have moved the mail to arunmozhi.in.

Creating a online presence

These days online presence is mostly Social Media. I deleted my Facebook account and have only Twitter, but that alone isn’t sufficient.

So,
Moved blog from static-site Pelican back to wordpress for easy theming and maintanence
Created a home page where I can showcase stuff

Customer Research

Making use of a skillset is all about selling it. So what do the buyers look for? Being a follower of Coding Horror I started of with his post on How to hire a programmer.

Here are the things I learnt:
1. Know to really write a program – I pass
2. Should have a portfolio – Need to create a portfolio page
3. Be culturally fit for the role – Depends on the company
4. Answer computer science theoritical/tricky/nerdy qustions – Well you can’t really prepare for them, can you? May be the theory part, but again when was the last time I thought about hash tables, 3rd year of my college?
5. Expect an audition project or a real world problem to solve.
6. Pitch in front of small group – have mixed feelings about this. But good to know this might be coming.

1 is done, 2 requires some work, 3 can’t really be worked on, 4 is subjective on how we look at it, solving puzzles and learning nerdy jokes is not the point, it shows the recruiter how we approach a problem and how much passionate about programming is a person. I will leave them at that. Finally, the points 5 and 6 are subjective to personal preference and circumstances as outlined in the comments by various people. I am sort of going to forget them for now.

Product preparation

I am the product, in case you are wondering. The article cited above and others linked in that article give a general idea about the product.
With that in mind, and my long time personal goals, here is the list of things I have in mind to do:

  1. Learn touch-typing!! Yeah, I am a pecker – albeit a fast one. – Done
  2. Learn Vim to the extent I am not going into v mode everytime to delete a set of words. – Ever learning
  3. Get core commit rights for QGIS – its time to work on itCouldn’t fit in time.
  4. Create a Portfolio/Resume/HireMe page
  5. Learn some tools of trade:
    • Plain text manipulations – Regex
    • Shell scripting
    • Code Editor – Vim
    • Version Control – Git + Github
    • Debugging Tools
    • Unit Testing Frameworks
  6. …….

I guess I will add more to the list as I set the goals. For now this should keep me focused.

Apparix – Bookmarking in terminal

When working in a large code base like Quantum GIS or when dealing with a lot of repositories in the machine, it is always tedious to cd all the way to the folder we require to move to. Enter apparix, an excellent linux tool I found by googling “bookmarking in the terminal”. This blog post has the complete details of how to use it.

Yay, no longer cd goto/project/src/core/of/module1 and again cd ../../../test/number/three. I can simply do

$ bm projectsrc
$ bm test3
$ bm fancypants4

to bookmark my locations and simply

$ to projectsrc
$ to test3
$ to fancypants4

One more tool added in the arsenal to improve productivity.

Unit Testing with CasperJS

Today I sat down to create a JavaScript library. I wanted to do it the way I have long dreamed of – TDD (Test Driven Development). There is no dearth of Unit testing libraries and frameworks for JavaScript, so after some reading on the internet settled on CasperJS and PhantomJS combination. CasperJS is just awesome for functional testing, but Unit testing? Even though it supports Unit Testing, it as such is not a dedicated unit testing framework like Karma or Protractor. Read this for more information on TTD frameworks for JS libraries.

Loading plain JavaScript files in CasperJS for unit testing seems to be completely undocumented. I tend to think it is because it wasn’t meant to be webpage-less. But the note on docs of tester module says:

The best way to learn how to use the Tester API and see it in action is probably to have a look at CasperJS’ own test suites.

Thanks for this quote, I found that using the fs module one can load local filesystem files as modules to be used. Using that now I could write unit tests while developing the library and later on write functional tests while using the library.

Here is the file structure

library
--test
  |--unit
  |--test.js
  |--index.html
--src
  |--livetransit.js

And here is are the two tests – i) uses a webpage based approach; ii) uses module approach
https://gist.github.com/tecoholic/937f51b6889448836db8