Feed aggregator

Setting Up Jenkins on Amazon Linux for PHP Testing

Ben Ramsey - Thu, 07/08/2014 - 16:45

One of my first tasks at ShootProof was to set up a Jenkins server for continuous integration and get it ready to run unit tests for PHP and JavaScript code. There are plenty of tutorials around the web to help you do just that. This is yet another one, but it’s primarily my cleaned-up notes—and less of a tutorial—placed here for my future self to find and provided publicly for all to benefit.

These instructions are specifically tailored for setting up Jenkins on an Amazon Linux EC2 instance. If that’s not what you’re running, your mileage may vary. These commands should run on RHEL-based systems, and with modifications to the package manager and names of packages, they should work on other Unix-like systems.

1. Launch and Prepare an EC2 Instance

The Amazon Linux AMI I used was the latest (at the time) paravirtual, 64-bit, instance store AMI (ami-ed8e9284), but choosing the latest for your region should work just fine. You can use an EBS-backed volume instead and set up regular snapshots of it, or you can follow these directions, create an AMI from your configured instance, and set up regular snapshots of the EBS volume we attach to the instance. Either way will work fine. I just happened to use an instance store with an EBS volume attached.

  1. Launch an EC2 instance (use this link to launch one, if you like)
  2. Create an EBS volume
  3. Attach the EBS volume to the instance you launched
  4. SSH to the instance, format and mount the EBS volume (see below)

I’m using XFS for the EBS volume’s file system, but you may use what you prefer. We’ll mount the volume at /var/lib/jenkins, so that we don’t have to do any complex trickery with the default jenkins user, home, and permissions. The EBS volume may exist at /dev/xvdf, as it does in the following example, or it may be attached at another point. See also Amazon’s guide to “Making an Amazon EBS Volume Available for Use.”

Note: All of these instructions require root access. You may prefix them with sudo, or you may change to the root user.

1 2 3 4 $ yum install xfsprogs $ mkfs -t xfs /dev/xvdf $ mkdir -p /var/lib/jenkins $ mount /dev/xvdf /var/lib/jenkins

Now, the volume is mounted at /var/lib/jenkins. We want to ensure it always gets mounted there when we restart the instance, so let’s add a line to /etc/fstab:

1 2 3 $ cp /etc/fstab /etc/fstab.orig $ sh -c 'echo "/dev/xvdf /var/lib/jenkins xfs defaults,nofail 0 2" >> /etc/fstab' $ mount -a 2. Install and Start Jenkins

Installing and starting Jenkins is fairly simple. We need to add the official Jenkins project repository to the list of yum repos, and then we install with yum, start the service, and ensure that Jenkins starts up on a reboot.

1 2 3 4 5 6 $ wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo $ rpm --import http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key $ yum update $ yum install jenkins $ service jenkins start $ chkconfig jenkins on 3. Configure the Server for Running Tests

Now, we need to install some stuff on the system so that Jenkins can do its thing. These instructions are intended for tests that use the Template for Jenkins Jobs for PHP Projects. This will give you a basic PHP installation with all the tools necessary to run the template. If you need to use anything that deviates from the stock template, then you’ll need to make changes.

1 2 3 4 $ yum install ant git graphviz gcc gcc-c++ $ yum install php55 php55-devel php55-common php55-cli php55-intl php55-gd php55-pecl-imagick php55-mbstring php55-mcrypt php55-mysqlnd php55-pdo php55-pecl-xdebug $ sh -c 'sed -i "s/^memory_limit =.*/memory_limit = 256M/" /etc/php.ini' $ sh -c 'sed -i "s/^;date\.timezone =.*/date\.timezone = America\/New_York/" /etc/php.ini' Node.js

Since I want to use Node.js for various build tools and to run JavaScript tests, I installed Node.js from source (yum always seems to have an outdated package). If you don’t need Node.js, you may skip this.

1 2 3 4 5 6 7 $ wget http://nodejs.org/dist/v0.10.30/node-v0.10.30.tar.gz $ tar zxf node-v0.10.30.tar.gz && cd node-v0.10.30 $ ./configure $ make $ make install $ ln -s /usr/local/bin/node /usr/bin/node $ ln -s /usr/local/bin/npm /usr/bin/npm

See those last two lines where I’m creating symlinks? This is because the jenkins user doesn’t have /usr/local/bin in its PATH. Rather than adjusting the user’s PATH, I chose to create symbolic links in /usr/bin, so that jenkins can find the node and npm programs.

PhantomJS and CasperJS

Finally, I also want to install PhantomJS and CasperJS to supplement and aid in my JavaScript testing. If you don’t need these, you may skip this.

1 2 3 4 5 6 7 $ yum install fontconfig freetype libfreetype.so.6 libfontconfig.so.1 libstdc++.so.6 $ wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 --no-check-certificate $ tar jxf phantomjs-1.9.7-linux-x86_64.tar.bz2 $ cp phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs $ npm install -g casperjs $ ln -s /usr/local/bin/phantomjs /usr/bin/phantomjs $ ln -s /usr/local/bin/casperjs /usr/bin/casperjs

Notice the symbolic links created in the last two lines again. This is for the same reason I mentioned earlier: to help the jenkins user find these programs in its PATH.

4. Configure Jenkins

Now, we’ve got Jenkins running, and the server has been configured to run our tests. You can go to Jenkins in a web browser to do the rest. By default, Jenkins runs on port 8080, so you can go to http://ec2-x-x-x-x.compute-1.amazonaws.com:8080/ to set it up.

The first thing you’ll want to do is enable security. I prefer to install the GitHub OAuth Plugin and use GitHub to authenticate with Jenkins. I would also recommend setting up a proxy to Jenkins through Apache or Nginx and installing an SSL certificate to encrypt your communications with Jenkins. You might also consider using AWS security groups to restrict access to Jenkins by IP addresses. All of these are outside the scope of this post.

  1. Install the Jenkins plugins required by the Template for Jenkins Jobs for PHP Projects. You’ll also need to install the required PHP tools listed on that page, or you may choose to use my jenkins-php meta-package with Composer to install them for you when you run Jenkins builds. If you choose the latter, be sure to set up your Ant build.xml script to also run composer install on each build during the “prepare” stage and point the executable for each tool to the vendor/bin/ directory (where Composer installs them).
  2. Create the Ant build.xml script for your project.
  3. Install the job template for PHP jobs and set up your first job using the template.

Here are a few other plugins that might come in handy:

  • GitHub Plugin: this plugin allows you to configure a job to pull source from a GitHub project, and you can set up GitHub web hooks to trigger builds on each code push to the repo
  • GitHub pull request builder plugin: this plugin will allow you to trigger a build on a pull request
  • HipChat Plugin / IRC Plugin / Slack Notification Plugin: these plugins allow you to configure a job to send messages to channels on your favorite team chat servers
Categories: Not PHP-GTK

My First Month at ShootProof

Ben Ramsey - Mon, 04/08/2014 - 04:00

It’s difficult to write a blog post about a new gig without coming across as sounding critical of past employers. That’s not my intent, but this first month I’ve spent at ShootProof has been one of the best months I’ve had in a long time, career-wise.

My first day at ShootProof was July 1st, and as I’ve come to my one-month anniversary with the company, I wanted to share some of the reasons that attracted me to ShootProof and why I’m still excited about it, after a month of working here.

The Team

The primary reason I joined ShootProof was for the team. I had worked with Robert Swarthout and Brian DeShong previously at Schematic (now POSSIBLE). We worked well together then, and the opportunity to work with them again was almost too good to be true. On top of that, ShootProof hires the best. With folks like Jenn Downs, Terry Allen, Kevin Bandy, Josh Davies, Colin Breece, and the rest of the ShootProof team, ShootProof really is a dream team.

At PHP Tek 2009, my friend Sean Coates gave me some awesome career advice. He said, “You need to work with people who know you.” At ShootProof, I am doing just that, and it’s a great working relationship.

Bootstrapped

Another thing that attracted me to ShootProof is its funding. As of today, it’s 100% bootstrapped. Ideologically, I’m not one of those who say your company must be bootstrapped or VC funded. There are pros and cons to both types of funding. But having experienced VC funding, a bootstrapped company had a certain appeal to me: all the investors have “skin in the game” in both the monetary investment sense, as well as the agile “pig” sense.

What this means for me is that I work on a daily basis with the primary decision makers in the company, and these decision makers answer only to themselves (and our customers). There’s a great deal of freedom and trust in this relationship.

Will we always remain bootstrapped? That’s not a question for me to answer or even to presume to know the answer. There are a variety of reasons we may or may not consider funding in the future, and that’s a question for our founders to tackle, but for now, the fact that we’re bootstrapped is important to me. It all comes back to the team. We’re intimate. We’re lean. We’re agile. We’re not tied down by VC money. We work only for our customers and ourselves.

Top-notch Support Team

After meeting with Colin, I realized that ShootProof not only prides itself in building a great product, but our special sauce is our customer support team. Our loyalty builders will do whatever it takes to ensure the happiness of our customers. I know this makes me sound rather dense and naïve, having worked in the industry for so many years, but after hearing about the work of our customer support team, I realized that customer support is just as much a part of our product as the code that makes up our web properties. I’m proud of the work they do, and I’m excited to be a part of their team.

User Experience

Along with customer support, ShootProof is working to ensure we have the best possible user experience for our customers. That’s why we have ace UX folks on our team.

User experience has always been an important cornerstone of software development to me. How users feel when they interact with your software interface determines whether they want to continue using it or not. Working at Schematic showed me how UX must be a discipline to any software company. I am more than thrilled that ShootProof feels the same way and has made it a crucial tenet of our process.

Product

As Brian said in his “Joining ShootProof” blog post, I also sought out ShootProof because I love to build products. I want to work for a company that is product-focused. Not only is ShootProof product-focused, they know their customer so well that they have been able to hone in on exactly what product to build for those customers. In fact, many of our team members are professional photographers themselves. That expertise and specificity is another reason I was attracted to ShootProof.

Revenue

ShootProof is a startup and a bootstrapped start-up at that. While I said earlier that the bootstrapped nature of the company attracted me, I would be lying if I said that revenue was not important. Many times, we hear “bootstrapped startup” and assume this means the company is not making any money. That is not the case with ShootProof. I can’t share numbers, but I can say that year-over-year growth has been sizable.

Culture

I’m not interested in joining a fly-by-night startup whose desire is to jump into a market, disrupt it, and get out quickly, making tons of money. Those get-rich schemes rarely succeed and don’t appeal to me. Money is nice, but not at the expense of my family, health, and relationships. ShootProof is a company with focus, a clear direction, and respect for its team members.

Recently, Cal Evans wrote a blog post entitled, “It’s All About Culture.” In it, he wrote:

The bedrock of a good developer culture is respect. Respect for the fact that you have developers to build things on which the company is based. Respect for the fact that without developers, the company most likely would not exist. Culture is not putting developers on a pedestal and offering them trinkets as tribute. Culture is understanding that developers aren’t cogs in a machine that can be replaced on a whim.

Culture is one of those things that’s difficult to define and hard to articulate, but I think Cal hits the nail on the head here. A good culture focuses on the people who make up the team. ShootProof’s culture is one of respect for each other. The focus is on people. One of the things Robert said to me when we were first discussing the possibility of me joining ShootProof is that he wants to build a first-class team that makes others say to themselves, “That’s a great team! I want to work with that team, too.”

The people and the focus on the people are what attracted me to ShootProof, and that’s why I’m still excited about ShootProof a month after joining them.

Categories: Not PHP-GTK

Change error on gtk_init to report the actual error from gtk for better debugging

PHP-GTK on Github - Tue, 24/06/2014 - 16:50
Change error on gtk_init to report the actual error from gtk for better debugging Also line ending fixes for all tests and a .gitattributes file (really should have been it's own commit)
Categories: Community

Rest of missing gtkgenerator changes

PHP-GTK on Github - Tue, 24/06/2014 - 16:44
Rest of missing gtkgenerator changes
Categories: Community

Normalize line endings for tests

PHP-GTK on Github - Tue, 24/06/2014 - 16:31
Normalize line endings for tests
Categories: Community

Improved gtk_init error handling

PHP-GTK on Github - Mon, 23/06/2014 - 19:07
Improved gtk_init error handling Replaced gtk_init_check with gtk_init_with_args so that we can return the actual GTK error if it fails instead of a generic error.
Categories: Community

Additional changes for generator.php => gtkgenerator.php rename

PHP-GTK on Github - Mon, 23/06/2014 - 16:37
Additional changes for generator.php => gtkgenerator.php rename
Categories: Community

Update docgen.php

PHP-GTK on Github - Mon, 23/06/2014 - 16:33
Update docgen.php Fixed forgotten renamed file generator.php --> gtkgenerator.php
Categories: Community

Update Makefile.frag

PHP-GTK on Github - Mon, 23/06/2014 - 16:32
Update Makefile.frag Fixed forgotten renamed file generator.php --> gtkgenerator.php
Categories: Community

Update config.w32

PHP-GTK on Github - Mon, 23/06/2014 - 16:31
Update config.w32 Fixed forgotten renamed file generator.php --> gtkgenerator.php
Categories: Community

Update config.w32

PHP-GTK on Github - Mon, 23/06/2014 - 16:31
Update config.w32 Fixed forgotten renamed file generator.php --> gtkgenerator.php
Categories: Community

Update Makefile.frag

PHP-GTK on Github - Mon, 23/06/2014 - 16:30
Update Makefile.frag Fixed forgotten renamed file generator.php --> gtkgenerator.php
Categories: Community

Update Makefile.frag

PHP-GTK on Github - Mon, 23/06/2014 - 16:30
Update Makefile.frag Fixed forgotten renamed file generator.php --> gtkgenerator.php
Categories: Community

Update Makefile.frag

PHP-GTK on Github - Mon, 23/06/2014 - 16:29
Update Makefile.frag Fixed forgotten renamed file generator.php --> gtkgenerator.php
Categories: Community

Update Makefile.frag

PHP-GTK on Github - Mon, 23/06/2014 - 16:29
Update Makefile.frag Fixed forgotten renamed file generator.php --> gtkgenerator.php
Categories: Community

Update Makefile.frag

PHP-GTK on Github - Mon, 23/06/2014 - 16:28
Update Makefile.frag Fixed forgotten renamed file generator.php --> gtkgenerator.php
Categories: Community

Update Makefile.frag

PHP-GTK on Github - Mon, 23/06/2014 - 16:28
Update Makefile.frag Fixed forgotten renamed file generator.php --> gtkgenerator.php
Categories: Community

cleanup of outdated files

PHP-GTK on Github - Mon, 23/06/2014 - 16:05
cleanup of outdated files libmozembed hasn't existed for years, we're in git not cvs, and .dsp files do not work
Categories: Community

Generator fix, round 2

PHP-GTK on Github - Mon, 23/06/2014 - 15:07
Generator fix, round 2 Removed remaining references to generator.php (excluding changelog and mozembed)
Categories: Community

Fix generator now being a reserved word and support newer MSVC versions

PHP-GTK on Github - Fri, 20/06/2014 - 21:07
Fix generator now being a reserved word and support newer MSVC versions
Categories: Community
Syndicate content