Fast & Efficient Development Environment + Remote Build Server on the Cheap

Posted: October 19th, 2010 | Author: | Tags: , , | No Comments »

I’ve recently started working on some mobile web development ideas and decided it would be easiest for testing to have a continuously integrated public development site which I can hit directly from my Android smartphone for testing without the hassle of an emulator. The chrome-to-phone browser/device extensions out there make switching back and forth between testing locally in full-scale chrome as well as on my device a breeze.

Plan established, the only real unsolved angle of this for me was finding a way to get a public copy of my source online that would be updated instantly when I commit to my repository. I have been using Dreamhost for some time because of their awesome rates and unlimited SVN hosting that comes with my web-hosting package. As I have now discovered, setting up post-commit scripts on Dreamhost’s servers to perform CI tasks is not very difficult and can really maximize productivity once established.

Installed on my local dev environemnt

  • OSX
  • MacVim
  • Chrome
    • use chrome-to-phone plugin for easy android based testing
    • or for iphone try http://tomlerendu.com/chrometoiphone/
  • SCPlugin
    • Pretty basic but free SVN client for mac
  • EasyFind
    • One shortfall of VIM is the lack of global project searches. This great little app takes care of that quite well.

Remote hosting, source control & build server

  • Dreamhost is the way to go
    • unlimited SVN hosting
    • unlimited domains and subdomains
    • SSH access

Setting up continuous integration w/ Dreamhost

  1. create your SVN repository from the http://panel.dreamhost.com admin site.
    • usually somthing like… svn.mydomain.com
  2. create a domain or subdomain on which to host the dev version of your web project
    • usually somthing like… dev.mydomain.com
  3. checkout the trunk of your svn repo locally on your mac using SCPlugin
  4. ssh into your dreamhost account via mac terminal
  5. checkout the trunk of your svn repository into you new dev project sub-domain
    cd /home/dreamhost_user/dev.mydomain.com
    svn co --username your_svn_user --password your_svn_pass http://svn.mydomain.com/trunk ./
  6. create a cgi-bin folder under your new CI dev domain
    mkdir /home/dreamhost_user/dev.mydomain.com/cgi-bin
  7. add the following .htaccess file to your new cgi-bin
    AuthName "Dialog prompt"
    AuthType Basic
    AuthUserFile /home/dreamhost_user/dev.mydomain.com/cgi-bin/.htpasswd
    Require valid-user
  8. create a htpasswd file
    cd /home/dreamhost_user/dev.mydomain.com/cgi-bin
    htpasswd -bc .htpasswd username password
  9. add the following file called “do_update.cgi” to your cgi-bin folder
    note: this is where all your other fun CI stuff can go. For example maybe you want to rake db:migrate if you are working in rails. In this example we’re simply doing an svn update.

    #!/bin/sh
    set -f
    echo "Content-type: text/plain; charset=iso-8859-1"
    echo
    svn update /home/dreamhost_user/dev.mydomain.com
  10. set permissions on your shiny new cgi-bin setup
    chmod 755 -R /home/dreamhost_user/dev.mydomain.com/cgi-bin
  11. create a file called “post-commit” at the location /home/dreamhost_user/svn/repo_id/hooks/post-commit
  12. add the folowing to the “post-commit” file
    note: you’ll be using the username and password you setup in step # 8

    #!/bin/sh
    wget --http-user=user --http-passwd=pass -qO - http://dev.mydomain.com/cgi-bin/do_update.cgi
  13. make post-commit file executable
    chmod 755 post-commit

Essential SVN Command Line Examples

Posted: April 1st, 2010 | Author: | Tags: , , | No Comments »

Checking out a Repo

svn co --username USER --password PASS http://svn.yourrepo.com/svn/someproject/trunk mydir

This command will checkout the remote path to a folder named “mydir” under the directory in which the command is issued.

Committing changes

svn ci

Recursively checks in all added or modified files under the current working directory.  By default this command will open a text editor where you can confirm the items being checked in and type a message.

What has changed?

svn status

Shows modified, conflicted, and unknown files recursively starting from the current working directory.

svn diff --revision 87 filename.rb

This command will display a unified diff comparing the current working version to revision 87.

svn update

Updates working copy to latest revision.

Ignoring Files

svn propedit svn:ignore /path/to/directory/holding/your/file

This  command will bring up a nano edit screen where you can add line delimited ignore properties. If you want to ignore all files within a directory, you would simply enter “*” in this editor window. Save the file, return to the command line, and do a quick “svn status” to make sure your settings took.