GitLab CI and iOS Testing

I’m in the process of developing a d20 Treasure Tracking app and wanted to take advantage of the GitLab CI testing. Yea I know, I can just test right in Xcode and don’t need it. But I also have other projects with other developers and having a CI Runner do the work lets us ALL know what is going on.

Portions of this article were taken from this post and modified/updated with changes I had to make to get it working with Xcode 7.1 and my setup. YMMV.

What I’m running

  1. El Capitan (10.11.2b3 as of this post)
  2. Xcode 7.1.1
  3. iOS 9.1 Simulators
  4. GitLab 8.1.4 with CI Turned on.

Runner Setup

First and foremost, you must install the gitlab-ci-runner. To run iOS/OS X tests, you need a mac to run it on (obviously). It can either be your local dev machine (how I have it setup), a home server, or a co-located server. What ever you choose, it needs OS X and Xcode installed.

Just follow the instructions here to install the runner with 1 change. When asked which executioner to use, choose `shell` so it’ll run the local toolset. We’re going to make a change in the GitLab UI to limit this running to just running iOS tests so any other projects you have, it won’t pick up the extra work.

After the runner is installed, install XCPretty on the runner machine. This will help cleanup the output so you can see what is failing where.

gem install xcpretty

Once the runner (and XCPretty) is installed, and registered with your GitLab instance, we need to make a quick change to make sure it’ll run just jobs for iOS/OS X. Log into your instance and do the following:

  1. Go to the Admin Area -> Continues Integration -> Runners
  2. Find the runner you just created and hit Edit
  3. Under tags, add `iOS` and hit save.
  4. You can also restrict the runner from the Edit screen to only certain projects if security is a bigger issue.

Project Setup on GitLab

Once you have pushed some code to GitLab, it’s time to get it plugged into the CI system. Navigate to your project and go to Settings -> Services. Under this, you should have a service calls `GitLab CI` and under that you’ll have 3 checkboxes.

  1. Active
  2. Push Events
  3. Tag Push Events

I have all 3 enabled so that any time I do a push or anytime I create a tag it’ll test the code. Although it’s possible to test to much (say it ain’t so!!!), this helps ensure nothing gets changed somehow along the way.

To ensure this is setup correctly, go under the admin area under Continues Integration and make sure your project is listed under the Projects tab.

Note: Some where during this process it may ask to use a shared runner. I hit enable as it gets restricted via the Tag field above for the runner. Sorry it wasn’t inline but I just don’t remember where I saw it.

Project Setup

In your project settings, under schemes, need to make sure the project is `Shared`. This is what it looks like here.

Shared Project
Shared Project settings.

A folder calls `xcscheme` (or something similar) will be created/modified. Add this to your repository as it’ll be needed later.

GitLab CI YAML File

This is the last part before seeing if everything works or the world is coming to a grinding halt. Probably somewhere in the middle. The GitLab CI system uses a YAML file ( .gitlab-ci.yml) at the root of the repository to handle all the commands and settings for building. Yes it’s a dot-file. I’ve pasted mine below (modify as you need to).

  - test

  stage: test
    - ios
    - xcodebuild clean test -project ProjectName.xcodeproj -scheme ProjectScheme -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6S,OS=9.1' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c && exit ${PIPESTATUS[0]}

Push everything to the GitLab instance and under Builds for the project, it should appear in the list of running. Under it you can watch it as it runs. If all goes well, it should come up as success. Or if you want to test failure, you can do like I did and get this:

Sample Error
Sample deliberate error

A few notes:

  1. The Code Signing commands are to allow building/testing without needing the certificates. Important if you don’t want to pass your developer certs around.
  2. The script command can be duplicated as many times as you want for each iOS/device configuration you want to test with. It’ll test each one and give output of each.
  3. Clean is done before each build to ensure an empty starting point as the runner will re-download/update the existing code without cleaning out the old code.

Quick Update…

It’s been awhile since my last post.  What can I say, I’ve been busy.  Had a contract that started late last year that was suppose to be 6 weeks that took 6 months.  Then another project right after that that was another 6 week one that took another 7 months.  So yea, those were some fun 12+ hour days.  Anyways, I never really left, just couldn’t do much.

During that time though, I launched a couple sites and an iPad app so it wasn’t a total waste.

I also have a few more iOS apps in the works.  A companion app for the Arlington 4th of July Parade Association’s website, a digital version of the 90 Day Planner offered by PFS, a game based on the D20 rule book that will fully utilize several features of iOS 4, the iPad, and the iPhone 4.

Got more news to come as well as some informative posts in the works.

Google Voice

I just received an invite for Google Voice and got it setup.  To the right is the widget Google provides for websites to allow people to call it.  By all means use it to get in touch with me.  Just please respect times (Only call between 8a and 8p central).

I may send some of you to voicemail just to see how the transcribing works, just don’t take offense if I do.  Either way, I will still get in touch with you.

If you want the direct line, it’s (682) 478-5088. I may change the number later once business expands to other areas (such as CO, AR, CA, or any other state).  I still have my GoSolo number (866) 887-1060.  I may cancel that if Google adds 800 support and fax support.

Stay tuned, I do have more posts coming including one to start a 90 day challenge.

I’m Back!

I’m Back!!!

Despite a short reprieve, I am back and ready to go.  I had to take the last site down due to a request from home office.  No biggie, no threats, just a request.  Since it was basically a “take it down” or “you’re fired” move, I decided my clients were more important.

I’ve changed the overall aspect of the site, look, feel, content, etc.  There will still be some finance related posts, just more generic.  There will be additional posts for my personal life as well as PR stunts related to my computer business.  I may even throw in some stuff about the little OS I’m working on.

Anyways, to make a short post shorter, I’m back with plenty of good stuff to come!