Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-23926] Improve Ti SDK handling during CI builds #75

Merged
merged 3 commits into from
Sep 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I like different signatures between versions, but I guess you only have the 5_5_X check for this one release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the master build script is already different anyway as it now uses commander and allows selecting the branch which causes the different method signature. This makes it more flexible for future releases and i don't think we need to backport that to 1.2.X.

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