Explaining how the real world works!     RSS Feed The Automated Tester on Twitter The Automated Tester on LinkedIn The AutomatedTester on github

Build, test and deploy Firefox OS apps for 0

Thu 03 Jan 2013

Building Software can be a very expensive thing to do! Especially if you are building a web application that needs to be deployed.

An EC2 micro instance or Linode 512 machine will cost ~USD20 a month. This then needs to have all monitoring apps installed and maintained which costs more money. This might not be a lot to some of us but growing up in South Africa, that always felt like a lot of money. When you are building a new app for Firefox OS, paying for a server to serve your app might not be in your costs for building, testing and deploying your app.

What if you could limit your development and deployment costs to £0? Note your app needs to be open source to make the cost £0.

Source Control

The current "go-to" source control at the moment is GitHub. I quite like it and for our free CI and deployment, we are going to have to have to use GitHub.

Project template

The FirefoxOS Marketplace team have created some template projects called mortar that give you all the necessary pieces to build an app. There are a number of different templates, from normal to games, for all your different needs.

Continuous Integration

Travis-CI is my favourite CI as a service at the moment. They are running the company as an open source company so I have a lot of love for these guys but I am digressing.

If you are using mortar then your .travis.yml will look like the following

language: node_js
node_js:
  - 0.8

And you will also need to update your package.json file to specify how to run tests. I wrote my tests with python so it's the following

  "scripts": {
    "test": "py.test -n 3"
  }

Now, if you want to maximise the use of your app you will need to make sure it works on as many browsers as possible. My friends at Saucelabs have recently created an Open Sauce account giving you free usage and it works well with Travis CI. To get it working you just add the following to your .travis.yml

env:
  global:
    - secure: "sauce user name"
    - secure: "sauce labs key"
  matrix:
      - SAUCE_PLATFORM='Windows 2003' SAUCE_BROWSER_VERSION=18

You can see a working example here.

And the have something like the following in your test setup. It will also set the browser size to the default FirefoxOS view port

    def setUp(self):
        try:
            os.environ['SAUCE_USERNAME']
            desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
            desired_capabilities['version'] = os.environ['SAUCE_BROWSER_VERSION']
            desired_capabilities['platform'] = os.environ['SAUCE_PLATFORM']
            desired_capabilities['name'] = 'Testing Get In The Habit'

            self.driver = webdriver.Remote(
                desired_capabilities=desired_capabilities,
                command_executor="http://%s:%s@ondemand.saucelabs.com:80/wd/hub" % \
                              (os.environ['SAUCE_USERNAME'],
                              os.environ['SAUCE_ACCESS_KEY'])
            )
        except Exception as e:
            print e
            self.driver = webdriver.Firefox()
        self.driver.set_window_size(320, 480)
        self.driver.get("http://localhost:8008")

Now that we have built and tested our app it's time to deploy!

Deployment

One of the things about our apps for Firefox OS is that it can be packaged on to the phone or can be served from a web server. GitHub pages make this a rather trivial exercise and also allows you to grow your user base without having to know how to maintain servers. You can also have a look at things like Launcher.io / AppFog / Heroku that have free tiers. If you need to have a backend for your app for synchronising of data then I highly recommend one of them.

    Area: blog

blog comments powered by Disqus