Top Banner
Xcode Server / Xcode 7 Bots @forbze
18
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Xcode Server & Xcode 7 Bots

Xcode Server / Xcode 7 Bots

@forbze

Page 2: Xcode Server & Xcode 7 Bots

Xcode Server• Part of OS X Server - Installed from Mac App Store

• CI

• Testing (Unit / Functional)

• Static Analysis

• Build Archiving

• Can also host Git Repo

http://localhost/

Page 3: Xcode Server & Xcode 7 Bots
Page 4: Xcode Server & Xcode 7 Bots

Bots• Xcode Server Service hosts bots

• Configured and created in Xcode

• Product > Create Bot

• Configuration Set which includes “integration” parameters

• build trigger

• output path

• etc.

• Pre/Post Build Triggers

Page 5: Xcode Server & Xcode 7 Bots

Xcode 7• Much nicer API for managing bots in Xcode

• JSON API for interacting with Xcode service

• Code Coverage

• UI Testing

• Xcode UI Updates - Can show results over time in a graph

Page 6: Xcode Server & Xcode 7 Bots
Page 7: Xcode Server & Xcode 7 Bots

UI Testinghttp://www.mokacoding.com/blog/xcode-7-ui-testing/

Page 8: Xcode Server & Xcode 7 Bots

Coverage Report

Page 9: Xcode Server & Xcode 7 Bots

Problems• Xcode 7 is still beta - had lots of weird install

bugs (beta 2 fixed some of these)

• Running tests on devices is not straight forward - build logs aren’t always obvious (maybe because my Xcode server was on a VM?)

• If you shut down the server temporarily and then launch Xcode - it forgets all the bots you have set up.

Page 10: Xcode Server & Xcode 7 Bots

Benefits• Bots live in the same IDE as the code

• Simple to use / configured

• Trigger scripts can be written in any scripting language bash / perl / swift etc.

• Reporting is available to all team members within Xcode

• Reporting is inline with code (i.e. code coverage)

• Multiple bots - per branch, different schedules & build triggers

Page 11: Xcode Server & Xcode 7 Bots

Nice Integration• Triggers provide very simple manner to integrate

with existing tools - such as HockeyApp upload… i.e.

#!/bin/sh

mkdir -p /tmp/$XCS_BOT_NAME/$XCS_INTEGRATION_NUMBER/

cd /tmp/$XCS_BOT_NAME/$XCS_INTEGRATION_NUMBER/

wget -O upload$XCS_INTEGRATION_NUMBER.ipa $XCS_PRODUCT

curl \ -F "status=2" \ -F "notify=1" \ -F "notes=Some new features and fixed bugs." \ -F "notes_type=0" \ -F "ipa=@upload$XCS_INTEGRATION_NUMBER.ipa" \ -H "X-HockeyAppToken: 4567abcd8901ef234567abcd8901ef23" \ https://rink.hockeyapp.net/api/2/apps/1234567890abcdef1234567890abcdef/app_versions/upload

Page 12: Xcode Server & Xcode 7 Bots

Lots of integration opportunities

JSON API too if environment variables aren’t enough…

Page 13: Xcode Server & Xcode 7 Bots

Integration Example• Using IFTTT to send SMS

on build success / failure #!/bin/sh

curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"$XCS_BOT_NAME\",\"value2\":\"$XCS_INTEGRATION_RESULT\"}" https://maker.ifttt.com/trigger/Build_Complete/with/key/aBCDeFgHHiJKl123noP

• Could have used any IFTTT channel instead of SMS - or direct native API’s (i.e. HipChat / Slack)

Page 14: Xcode Server & Xcode 7 Bots

More Integration• Using the JSON API - we can also trigger

integrations.

• Xcode Server can be integrated into an existing build pipeline

• e.g. Bamboo triggers a build via the JSON API

Page 15: Xcode Server & Xcode 7 Bots

Issues• Xcode client / server need to be able to

communicate - on same network, or with network changes

• Tests can’t be easily re-used for an Android project

• Code based tests - not BDD…

• Unit tests still work with Specta / Kiwi

• Not clear how well it performs & scales

Page 16: Xcode Server & Xcode 7 Bots

xcodebuild• Build / Test / Coverage is also available using

xcodebuild outside of Xcode Server

• Coverage Data is also available, but messy - NSKeyedArchiver

Page 17: Xcode Server & Xcode 7 Bots

Recommendation• Wait for stable build of Xcode

• Start using Xcode Server on projects where the environment suits it - local network, Mac Mini, no Android project etc.

• Build an “centralised” Xcode server which is available externally for other projects (VPN / HTTPS)

Page 18: Xcode Server & Xcode 7 Bots

Want to learn more?• Watch WWDC15 presentation - “Continuous

Integration and Code Coverage in Xcode”

@forbzeThanks!