Skip to content

Commit

Permalink
Merge pull request #75 from janvennemann/TIMOB-23926
Browse files Browse the repository at this point in the history
[TIMOB-23926] Improve Ti SDK handling during CI builds
  • Loading branch information
hansemannn committed Sep 20, 2016
2 parents 2e5c475 + 1b35f70 commit b57e73c
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 15 deletions.
3 changes: 3 additions & 0 deletions iphone/hyperloop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
};
2461FD9A1BB0C286006D4D9E = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -424,6 +425,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "tests/Tests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -436,6 +438,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.appcelerator.hyperloop.tests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "tests/Tests-Bridging-Header.h";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
6 changes: 3 additions & 3 deletions iphone/tests/TestView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import Foundation
import UIKit


public class TestView : UIView {
open class TestView : UIView {

public func foo (x : CGFloat, y : CGFloat) -> CGFloat {
open func foo (_ x : CGFloat, y : CGFloat) -> CGFloat {
return x + y;
}
}
}
76 changes: 64 additions & 12 deletions tools/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,55 @@ function extract(filename, installLocation, keepFiles, callback) {
* @param {String} branch SDK branch to install from
* @param {Function} next callback
*/
function installSDK(branch, next) {
console.log(('Checking for updated Ti SDK from ' + branch).green);
var args = ['sdk', 'install', '-b', branch, '-d', '--no-banner'],
prc;
function installAndSelectLatestTiSDK(branch, next) {
console.log(('Checking for updated Ti SDK from ' + branch + ' branch.').green);
var args = ['sdk', 'install', '-b', branch, '-d', '--no-banner'];
var isUpToDate = false;
var installedVersion;
if (!progressBars) {
args.push('--no-progress-bars');
}
prc = spawn(titanium, args, {stdio:'inherit'});
prc.on('exit', function (code) {
var child = spawn(titanium, args);
child.stdout.on('data', function(buffer) {
var message = buffer.toString();
if (message.indexOf('You\'re up-to-date') !== -1) {
isUpToDate = true;
versionMatch = message.match(/Version\s([\d\.v]+)/);
installedVersion = versionMatch[1];
}
});
child.on('exit', function (code) {
if (code !== 0) {
next('Failed to install ' + branch + ' SDK. Exit code: ' + code);
} else {
if (isUpToDate && installedVersion) {
console.log('Latest version ' + installedVersion + ' already installed, select it!');
return selectTiSDKVersion(installedVersion, next);
}
console.log('Installed and selected latest Ti SDK build from branch ' + branch + '.');
next();
}
});
prc.on('error', next);
child.on('error', next);
}

/**
* Selects a specific Ti SDK version
*
* @param {String} version The version to select
* @param {Function} next
*/
function selectTiSDKVersion(version, next) {
var child = spawn(titanium, ['sdk', 'select', version, '--no-banner']);
child.on('exit', function (code) {
if (code !== 0) {
next(new Error('Failed to select SDK ' + version + '. Exit code: ' + code));
} else {
console.log('Selected Ti SDK ' + version);
next();
}
});
child.on('error', next);
}

// Grab the Android home location
Expand Down Expand Up @@ -372,7 +405,8 @@ function writeAndroidPluginPackage (next) {
function build(branch, callback) {
var tiSDKPath,
androidSDKPath,
androidNDKPath;
androidNDKPath,
preBuildSelectedTiSDKVersion;

// set the environment variable CI during build
process.env.CI = 1;
Expand All @@ -385,13 +419,24 @@ function build(branch, callback) {
wrench.mkdirSyncRecursive(buildTempDir);
next();
},
// Install latest Titanium SDK from target branch
// Install latest Titanium SDK
function (next) {
installSDK(branch, next);
async.waterfall([
tiver.getActivePath,
function savePreviouslySelectedTiSDKVersion(sdkPath, version, callback) {
preBuildSelectedTiSDKVersion = version;
callback();
},
function (callback) {
installAndSelectLatestTiSDK(branch, callback);
}
], function(err) {
next(err);
});
},
// Grab location it got installed
function (next) {
tiver.getActivePath(function (err, sdkPath, minVersion) {
tiver.getActivePath(function (err, sdkPath, version) {
if (err) {
return next(err);
}
Expand Down Expand Up @@ -467,8 +512,15 @@ function build(branch, callback) {
function (next) {
wrench.rmdirSyncRecursive(buildTempDir);
next();
}
},
// TODO Remove the Titanium SDK we installed to avoid cluttering up HDD?
function (next) {
if (!preBuildSelectedTiSDKVersion) {
return next();
}
console.log('Switching back to Ti SDK that was selected before our build.');
selectTiSDKVersion(preBuildSelectedTiSDKVersion, next);
}
], callback);
}

Expand Down

0 comments on commit b57e73c

Please sign in to comment.