Faster CI – Our Journey To Halving Our Test Runtimes

Warning, this post is a bit technical.  🙂

[Editors Notes] From time to time our engineers take a moment to write a post for our blog. From Adam our product manager writing about Scrum and Kaizen to Piotr writing about our Engineering Best Practices there is lots to read.  Vince has written on the blog before, his last post was about Adventure Engineering in Da Nang, Vietnam. Today, Vince thought that what he has learned about reducing our test runtimes might be helpful to startup community. Enjoy.

One of my biggest challenges for the past few weeks was to get our tests to complete within 10 minutes.

That doesn’t sound so bad, does it? There’s just one tiny detail which would make this journey all the more exciting: Our code takes 25 minutes on average to complete on 25 parallel build servers and It takes about 4 hours if you run it in one.

I made a quick survey with our engineers and we lose roughly around 3 hours per day waiting for CI to finish.

The plan was to selectively run tests and have cucumbers run only on specific branches — epic, develop and master. This means that every time something gets merged to those branches, cucumbers will run after rspecs. And of course, all this will run in parallel on 25 build servers.

How our code tree looks like:

|- master
|- develop
   |- epic/adding-a-thing-with-stuff
      |- feature/with-things  
      |- feature/with-stuff
   |- epic/the-thing-you-do
      |- feature/bla-bla-bla

We didn’t have a way to execute this plan with our current CI solution at that time so we had to find alternatives. We tried quite a few but most of them were either had limited features or were just simply too hard to get started.

Enter Codeship. It took me no more than 3 minutes to get my first build up and running…and of course, failing. Getting started with their ParallelCI wasn’t that hard either. How you configure your builds opened up a ton of possibilities including selective test runs.

To make our tests parallelize (is that even a word?) I had to use this neat little gem called parallel_tests.

Getting started with the gem is simple. You can execute a group of rspecs like so:

bundle exec parallel_test spec/ —verbose -n $TEST_GROUPS —only-group $TEST_GROUP —group-by $TEST_GROUP_BY —type rspec

$TEST_GROUP is an ENV variable that I set on each pipeline. Basically just the number of the pipeline. $TEST_GROUPS is the total number of parallel pipelines. This is 25 for us. $TEST_GROUP_BY is how we group our tests and that would beruntime for us.

That is one other thing you can do with parallel_tests is group by runtime information. Using this grouping took 2 minutes off of our test runtimes. Getting logs from parallel pipelines was a little bit tricky so I had to do a little scripting magic to gather logs from multiple pipelines and concatenating them back together.

It’s simple really, in the setup section I have two scripts: one to upload each log slice to S3 and the other to download the logs and put them together.

Links for reference, apologies for the terrible naming: – ConcatenateUpload

Now that the runtime logs are covered, it’s time to make the tests work. I have this bash script in our code:

#!/bin/bash

bundle exec parallel_test spec/ —verbose -n $TEST_GROUPS —only-group $TEST_GROUP —group-by $TEST_GROUP_BY —type rspec

if [[ “$CI_BRANCH” =~ .*”$BRANCH_FOR_CUKES”.* ]] || [[ “$CI_BRANCH” =~ .*”master”.* ]] || [[ “$CI_BRANCH” =~ .*”develop”.* ]]
then
  echo “Running Cucumber…”
  bundle exec parallel_cucumber features/ —verbose -n $TEST_GROUPS —only-group $TEST_GROUP —group-by $TEST_GROUP_BY —type cucumber || true
else
  echo “Not running Cucumber”
fi

Conveniently, Codeship has a bunch of ENV variables set inside test instances and one of those is $CI_BRANCH. I just simply check if the current branch running in CI matches either master, develop or what I configured in the settings, it will run Cucumbers after RSpecs.

Finally, this is what our setup and pipeline configuration looks like:

codeship vince paca

This entire approach got our RSpec builds down to an average of 6 minutes and our entire suite to 13 minutes from 25 minutes.

Huge props to the Codeship team for helping out with the transition and thanks for the swag! 🙂

Editors note: This post was originally published here.

Watch Our Singapore Payroll In Action

Would you like to see our Singapore payroll platform run a payroll? Rohit in our Singapore office put together a quick video to show you how easy it is to run a payroll for your Singapore based business. Check it out below:

Want to learn more about our Singapore payroll platform? Reach out and one of our team would be pleased to get on a call with you to discuss your needs.

Restaurant Executive: Karla Campos, CEO of Dell’s Foodhall

As we continue our series of interviews with successful restaurant and retail executives from Singapore and the Philippines I’m pleased to introduce Karla Campos from Dell’s Foodhall in the Philippines.  Karla was kind enough to share some of her experience about running a multi-location restaurant chain in the Philippines. 

karla campos dells foothallYou are the CEO of Dell’s Foodhall, can you tell us a bit more about the brand? 
We are a cafeteria chain with multiple locations all over Metro Manila, providing quality, home-style cooking to the country’s workforce, in a cool and hip atmosphere. While one would find most food chains inside malls, you will find Dell’s Foodhall in office buildings where we cater, primarily, to people at work — young professionals, executives, the BPOs and call center agents. Most of our locations are open 24 hours a day, 6 days a week.

Sounds exciting, can you tell us a bit more about how the brand came about, what you did to understand your customers needs, etc?
People often ask me, “Why Dell’s?” or “Are you Dell?” Uhm.. No. Haha! It’s actually my mom’s name, which is Adelfa.

I took over my mom’s single proprietorship business – then known as Dell’s Canteen & Catering Service, which made it big back in the 70’s and 80’s, catering to institutional accounts. By the time I took over the business in 1996, I had imagined something different.

After working and living in New York, where I dined in the office cafeteria every single day and witnessed how everything was nicely executed — I found myself not growing tired of dining in the office cafeteria since the food and service was great. This to me, was an eye opener. Then I came home and made my rounds in the office cafeterias here and discovered that we were behind — that there was something lacking in terms of the general approach and expectations. The cafeterias here were quite “old school” and sloppy, to be honest. So, I thought of creating something that was more upbeat, and probably more exciting in this segment of the food industry, with a desire to fill in the gap. I tried to duplicate the dining experience I had in New York, and didn’t realize I hit a home run. Now the general office crowd seems to know who we are and patronize us, Mondays thru Fridays. We have come to know who they are, the kind of food selections they are looking for, and the price points they are comfortable with.

dells foodhall philippinesI didn’t change the name anymore since it was a bit late in the game, given that we had already become quite popular with our customers. So instead, we re-branded by naming it Dell’s Foodhall — Foodhall being 1 word, the same way they have it in Sydney, Bangkok, London etc. Then we just sort of modernized the logo to make it more acceptable and recognizable within our target market.

You operate in the Philippines, what challenges come with that? what benefits?
Well, the reality is that our country is still pretty much “third world”. The internet is slow, public transportation needs a lot of work, and don’t even get me started on the traffic situation… Bottom line is, we still have a long ways to go.

On the other hand, as a business owner, I believe I am in a great position to contribute to society, to be a part of the nation building process and simply help make things better. We have hundreds of people in our payroll and as the CEO, I take this responsibility very seriously. Running a business or your own company allows you to create jobs and opportunities for other people. There is the multiplier effect, that every growing economy desperately needs. We are able to create more wealth to go around and have a positive impact in the lives, not only of our employees, but also that of our suppliers, while keeping Manila’s work force — our customers, happy and well fed.

What technology do you use in your businesses? 
We use POS, accounting systems that generally address the needs of our sales, inventory and payroll. We try to use systems that are more efficient, easy to understand and manage to be able to properly monitor the business flow.

How do you decide on a location? (mall? street level? stand alone business?)
We study the location by taking into account the general population in the area, the foot traffic, accessibility, and of course, rental rates.

At what point did the number of locations change how the business is run? I have been told, 1 or 2 locations is ok, but 3+ requires a different management approach, systems, procedures, etc. What was the tipping point for you?
I guess you grow to a certain size, get to a certain level and realize you can’t do everything by yourself anymore. That the “mom and pop” approach is no longer going to cut it. Too many things are happening at the same time — the stakes are higher, your market reach is wider, the public is now aware of your presence — including your competitors. As the leader of our organization, I had to change my management style or the business was not going to survive. In order for us to create the best all around product and be able to compete, I had to read up, studied and observed how other successful organizations conducted business, and was inspired at the thought of what we could become.

I remember going to the opening day of a new location and seeing the long lines.. And then it hit me — we had a brand that the public — at least our target market – was now very familiar with and were patronizing. That same week, I visited a food expo, gave out my business card to every potential supplier, and was surprised they knew exactly who we were and were very excited to do business with us. At that point, it became clear to me that Dell’s Foodhall had a name and reputation to protect, and that it was time to shift into high gear. It was time to professionalize. And so, I started hiring professionals to run our company. Now I have an executive committee, a team of experts, who help me in running and monitoring all areas of the business. It is still a lot of work, but I am not complaining.

What is next for Dell’s Foodhall?
We will continue to expand and open in new locations. As the owner, I am extremely pleased and grateful with what we’ve achieved, thus far, and will only persist in finding new ways of improving our systems and the quality of our food products and services. What can I say — it’s a never ending process. We are always a work in progress.

anything else to add?
To survive in the food business, one must be ready for the hard work that comes with it. You need to be ready to put in the hours and monitor every stage of the process very closely and diligently. You can make a lot of money here — but you can also lose a lot of money.

I always tell people who ask me about the food business that it is far from glamorous and that it is a very demanding industry. You deal with all kinds of people every day. I sometimes start the day meeting with a supplier from whom we order tons of meat items from, trying to agree on a locked in price and then end the day meeting with the a building owner whose rent I am also trying to negotiate — not to mention the managers who go in and out of my office for decisions that need to be made. It is a very tedious, very detail oriented business, with lots of moving pieces. Then again, it is also very rewarding and quite fulfilling. As in any business, you just have to stay the course, stay committed and passionate — as you grow in wisdom as an entrepreneur and as a human being. Be prepared to come to work every single day. I tell you, nothing comes easy in this business. Still, I cannot imagine doing anything else.

Continue reading