Install Go on Ubuntu

Here is a quick gist that installs Go on Ubuntu.

  • Go root will be in usr/local/go
  • Go path will be in $HOME/go
wget https://go.googlecode.com/files/go1.1.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.1.2.linux-amd64.tar.gz
rm go1.1.2.linux-amd64.tar.gz

mkdir -p "$HOME/go/"{src,pkg,bin}
echo 'export GOPATH="$HOME/go"' >> "$HOME/.profile"

echo 'export GOROOT="/usr/local/go"' >> "$HOME/.profile"
echo 'export PATH="$GOROOT/bin:$GOPATH/bin:$PATH"' >> "$HOME/.profile"

source "$HOME/.profile"

Build and deploy status notification with the cctray feed

At wercker we have added build and deployment status output in the cctray.xml format, an RSS-like continuous integration server status feed, which was originally developed for CruiseControl.net. In this post I would like to share the details and how I leverage this to get notified on important wercker status changes via CCMenu.

image

Configuration

Wercker offers two endpoints per project that serve status information in the cctray.xml format. One for the build status, and one for the deployment status.

Buids status feed

The feed url that contains the build status from an project is:

https://app.wercker.com/api/v2/applications/{PROJECT-ID}/cc/build

You need to replace {PROJECT-ID} with the project id of the project you want to monitor.

Deploy status feed

The feed url that contains the deployment status of a project's deploy target is:

https://app.wercker.com/api/v2/applications/{PROJECT-ID}/cc/deploytargets/{DEPLOY-TARGET-NAME}

You need to replace {PROJECT-ID} with the project id of the project you want to monitor and {DEPLOY-TARGET-NAME} with the name of the deploy target. Read more about deploy targets on ou dev center

Tools

Here is a list of tools that allow you to monitor cctray.xml feeds and that can be used to monitor your build and deployment statuses of your wercker projects.

Using CCMenu

There are a lot of tools that support the cc status format. As I'm mostly working on a Mac I decided to use CCMenu. It allows you to monitor multiple projects at the same time, and identifies the overall build status with just a glance at the menu bar.

image

Download and install the latest version of ccmenu from the CCMenu project.

Finding your project id

Navigate to your project page at app.wercker.com and copy your project id from the url.

image

Add builds to CCMenu

Open CCMenu by clicking on the icon in the top menu bar and open preferences.

image

Enter feed details

Click on the plus sign in the preference window and enter your project cc feed url. It is important to follow the following steps closely because CCMenu was acting a bit weird when I entered my details.

  1. Enter your feed url
  2. Click Use URL as entered above option
  3. Enter your wercker credentials
  4. Check The server requires authentication
  5. Click Continue
  6. See the status of your project in your menu bar!

image

Other feeds

You can repeat the previous steps for other feeds as well.

Notification center

CCMenu supports Mac's Notification Center

image

Final result

image

Earn some stickers

Let me know about the applications you build with wercker. Don't forget to tweet out a screenshot of your first green build with #wercker and I'll send you some @wercker stickers.

Use Go reflection to get func type information

Here is a small code snipped that demonstrates how to get type information from a func type in Go. I prints the information to the console. More information about reflection can be found at the great Go docs article The Laws of Reflection.

Code

package main

import (
  "fmt"
  "reflect"
)

type Multiplier func(x int, y int) int

func main() {
  m := Multiplier(Multipli)
  mType := reflect.TypeOf(m)

  fmt.Printf("name: %v\n", mType.Name())
  fmt.Printf("number of in args: %v\n", mType.NumIn())
  fmt.Printf("number of out args: %v\n", mType.NumOut())
  fmt.Printf("in arg 1 type: %v\n", mType.In(0).Name())
  fmt.Printf("in arg 2 type: %v\n", mType.In(1).Name())
  fmt.Printf("out arg 1 type: %v\n", mType.Out(0).Name())
}

func Multipli(x int, y int) int {
  return x * y
}

Prints

$ go run method.go
name: Multiplier
number of in args: 2
number of out args: 1
in arg 1 type: int
in arg 2 type: int
out arg 1 type: int