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

Fail early when XamariniOS builds are run on hosted windows or linux #7184

Merged
merged 7 commits into from
May 30, 2018

Conversation

madhurig
Copy link
Contributor

Since demands are not validated in Hosted pools now, users can run iOS builds on windows and linux hosted pools. Our tasks don't handle that since they were written assuming demand validation would be done.
I started modifying the Xamarin iOS task but Xcode, InstallAppleCertificate, InstallAppleProvisioningProfile will also need to be updated to complete this experience.

The legacy tests are not fixed, so they will fail on windows and linux runs.

@madhurig madhurig force-pushed the users/madhurig/xamarinios branch from 73e1e35 to 1072c08 Compare May 11, 2018 20:14
@madhurig madhurig force-pushed the users/madhurig/xamarinios branch from 1072c08 to 4f8330e Compare May 29, 2018 18:33
@madhurig madhurig changed the title [WIP]Fail early when run XamariniOS builds are run on windows or linux Fail early when run XamariniOS builds are run on windows or linux May 29, 2018
@madhurig madhurig changed the title Fail early when run XamariniOS builds are run on windows or linux Fail early when XamariniOS builds are run on hosted windows or linux May 29, 2018
@@ -28,6 +29,11 @@ async function run() {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));

// Check platform is macOS since demands are not evaluated on Hosted pools
if (!/^darwin/.test(os.platform())) {
throw tl.loc('BuildRequiresMac');
Copy link
Contributor

Choose a reason for hiding this comment

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

An improvement is throw new Error(tl.loc('BuildRequiresMac')); It will preserve the stack trace correctly.

@madhurig madhurig force-pushed the users/madhurig/xamarinios branch from 433b53d to 4fc2282 Compare May 30, 2018 13:52
@madhurig madhurig merged commit 5e2b0e0 into master May 30, 2018
@madhurig
Copy link
Contributor Author

Builds passed on re-run, so merging.

@@ -14,6 +14,24 @@ describe('XamariniOS L0 Suite', function () {

});

it('run XamariniOSV2 with all default inputs', (done) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be a function for this.timeout(1000) to do anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I recollect now that timeouts don't apply otherwise. Will fix in my next PR.

@madhurig madhurig deleted the users/madhurig/xamarinios branch May 30, 2018 16:11

assert(tr.ran('/home/bin/nuget restore src/project.sln'), 'it should have run nuget restore');
assert(tr.ran('/home/bin/msbuild src/project.sln /p:Configuration=Release /p:Platform=iPhone'), 'it should have run msbuild');
assert(tr.invokedToolCount == 3, 'should have only run 3 commands');
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use === here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, these were legacy tests I moved.

assert(tr.stderr.length == 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

done();
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to call done unless you are running async code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Inside the function, done() needs to be called.

tr.setInput('provProfileUuid', '');

// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
Copy link
Contributor

Choose a reason for hiding this comment

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

I made a change to TaskLibAnswers so we shouldn't have to type assert anymore. Removing the type assertion will catch mocks that don't work (getVariable in this case).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This task in on older version of the lib!

@@ -46,5 +47,10 @@ let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{
};
tr.setAnswers(a);

os.platform = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: extra space after =

}
}

async function run() {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));

// Check platform is macOS since demands are not evaluated on Hosted pools
if (!/^darwin/.test(os.platform())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use a regex? The list of possible platforms is documented, so you can just check === 'darwin'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing to !== 'darwin'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants