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

allow specifying external tester groups when uploading to test flight… #80

Merged
merged 1 commit into from
Nov 6, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"loc.input.help.shouldSkipSubmission": "Select to upload the IPA but not distribute it to testers.",
"loc.input.label.distributedToExternalTesters": "Distribute to External Testers",
"loc.input.help.distributedToExternalTesters": "Select to distribute the build to external testers (cannot be used with 'Skip Build Processing Wait' and 'Skip Submission'). Using this option requires setting release notes in 'What to Test?'",
"loc.input.label.externalTestersGroups": "Groups",
"loc.input.help.externalTestersGroups": "Optionally specify the group(s) of external testers this build should be distributed to. To specify multiple groups, separate group names by commas e.g. 'External Beta Testers,TestVendors'. If not specified the default 'External Testers' is used.",
"loc.input.label.teamId": "Team ID",
"loc.input.help.teamId": "The ID of your team if you are in multiple teams.",
"loc.input.label.teamName": "Team Name",
Expand All @@ -55,6 +57,8 @@
"loc.input.help.fastlaneToolsVersion": "Choose to install either the lastest version of fastlane or a specific version.",
"loc.input.label.fastlaneToolsSpecificVersion": "fastlane Specific Version",
"loc.input.help.fastlaneToolsSpecificVersion": "Provide the version of fastlane to install (e.g., 2.15.1). If a specific version of fastlane is installed, all previously installed versions will be uninstalled beforehand.",
"loc.input.label.fastlaneArguments": "Additional fastlane arguments",
"loc.input.help.fastlaneArguments": "Any additional arguments to pass to the fastlane command.",
"loc.messages.DarwinOnly": "The Apple App Store Release task can only run on a Mac computer.",
"loc.messages.SuccessfullyPublished": "Successfully published to %s",
"loc.messages.NoIpaFilesFound": "No IPA file found using pattern: %s",
Expand Down
41 changes: 41 additions & 0 deletions Tasks/app-store-release/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,18 @@ describe('app-store-release L0 Suite', function () {
done();
});

it('testflight - distribute external with groups', (done:MochaDone) => {
this.timeout(1000);

let tp = path.join(__dirname, 'L0TestFlightDistributeToExternalTestersWithGroups.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.invokedToolCount === 1, 'should have run fastlane pilot.');
assert(tr.succeeded, 'task should have succeeded');
done();
});

it('testflight - one ipa file', (done:MochaDone) => {
this.timeout(1000);

Expand Down Expand Up @@ -355,6 +367,21 @@ describe('app-store-release L0 Suite', function () {
done();
});

it('testflight - additional arguments', (done:MochaDone) => {
this.timeout(1000);

let tp = path.join(__dirname, 'L0TestFlightFastlaneArguments.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.ran('fastlane pilot upload -u creds-username -i mypackage.ipa -args someadditioanlargs'), 'fastlane pilot upload with one ip file should have been run.');
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane pilot.');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

done();
});

it('production - no bundle id', (done:MochaDone) => {
this.timeout(1000);

Expand Down Expand Up @@ -545,6 +572,20 @@ describe('app-store-release L0 Suite', function () {
done();
});

it('production - fastlane arguments', (done:MochaDone) => {
this.timeout(1000);

let tp = path.join(__dirname, 'L0ProductionFastlaneArguments.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.invokedToolCount === 3, 'should have run gem install, gem update and fastlane deliver.');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

done();
});

//No tests for every combination of uploadMetadata and metadataPath (one true, one false)
//No tests for every combination of uploadScreenshots and screenshotsPath (one true, one false)

Expand Down
72 changes: 72 additions & 0 deletions Tasks/app-store-release/Tests/L0ProductionFastlaneArguments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';

import ma = require('vsts-task-lib/mock-answer');
import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import os = require('os');

let taskPath = path.join(__dirname, '..', 'app-store-release.js');
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

tmr.setInput('authType', 'UserAndPass');
tmr.setInput('username', 'creds-username');
tmr.setInput('password', 'creds-password');
tmr.setInput('appIdentifier', 'com.microsoft.test.appId');
tmr.setInput('releaseTrack', 'Production');
tmr.setInput('installFastlane', 'true');
tmr.setInput('fastlaneToolsVersion', 'LatestVersion');
tmr.setInput('fastlaneArguments', '-args someadditioanlargs');

tmr.setInput('ipaPath', '**/*.ipa');

process.env['MOCK_NORMALIZE_SLASHES'] = true;
process.env['HOME'] = '/usr/bin';
let gemCache: string = '/usr/bin/.gem-cache';

//construct a string that is JSON, call JSON.parse(string), send that to ma.TaskLibAnswers
let myAnswers: string = `{
"which": {
"ruby": "/usr/bin/ruby",
"gem": "/usr/bin/gem",
"fastlane": "/usr/bin/fastlane"
},
"checkPath" : {
"/usr/bin/ruby": true,
"/usr/bin/gem": true,
"/usr/bin/fastlane": true
},
"glob": {
"**/*.ipa": [
"mypackage.ipa"
]
},
"exec": {
"/usr/bin/gem install fastlane": {
"code": 0,
"stdout": "1 gem installed"
},
"/usr/bin/gem update fastlane -i ${gemCache}": {
"code": 0,
"stdout": "1 gem installed"
},
"fastlane deliver --force -u creds-username -a com.microsoft.test.appId -i mypackage.ipa --skip_metadata true --skip_screenshots true -args someadditioanlargs": {
"code": 0,
"stdout": "consider it delivered!"
}
}
}`;
let json: any = JSON.parse(myAnswers);
// Cast the json blob into a TaskLibAnswers
tmr.setAnswers(<ma.TaskLibAnswers>json);

// This is how you can mock NPM packages...
os.platform = () => {
return 'darwin';
};
tmr.registerMock('os', os);

tmr.run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';

import ma = require('vsts-task-lib/mock-answer');
import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import os = require('os');
import fs = require('fs');
let stats = require('fs').Stats;

let taskPath = path.join(__dirname, '..', 'app-store-release.js');
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

tmr.setInput('authType', 'UserAndPass');
tmr.setInput('username', 'creds-username');
tmr.setInput('password', 'creds-password');
tmr.setInput('releaseTrack', 'TestFlight');
tmr.setInput('ipaPath', 'mypackage.ipa');
tmr.setInput('appIdentifier', 'com.microsoft.test.appId');
tmr.setInput('distributedToExternalTesters', 'true');
tmr.setInput('releaseNotes', '/usr/build/releasenotes');
tmr.setInput('externalTestersGroups', 'Group1,Group 2');

process.env['MOCK_NORMALIZE_SLASHES'] = true;
process.env['HOME'] = '/usr/bin';
let gemCache: string = '/usr/bin/.gem-cache';

tmr.registerMock('fs', {
statSync: () => {
let stat = new stats;
stat.isFile = () => {
return true;
};
return stat;
},
readFileSync: () => {
return Buffer.from('Release notes for beta release.');
},
writeFileSync: fs.writeFileSync
});

//construct a string that is JSON, call JSON.parse(string), send that to ma.TaskLibAnswers
let myAnswers: string = `{
"which": {
"ruby": "/usr/bin/ruby",
"gem": "/usr/bin/gem",
"fastlane": "/usr/bin/fastlane",
"pilot": "/usr/bin/pilot"
},
"checkPath" : {
"/usr/bin/ruby": true,
"/usr/bin/gem": true,
"/usr/bin/fastlane": true,
"/usr/bin/pilot": true
},
"glob": {
"mypackage.ipa": [
"mypackage.ipa"
]
},
"exec": {
"/usr/bin/gem install fastlane": {
"code": 0,
"stdout": "1 gem installed"
},
"/usr/bin/gem update fastlane -i ${gemCache}": {
"code": 0,
"stdout": "1 gem installed"
},
"fastlane pilot upload -u creds-username -i mypackage.ipa --changelog Release notes for beta release. -a com.microsoft.test.appId --distribute_external true --groups Group1,Group 2": {
"code": 0,
"stdout": "consider it uploaded!"
}
}
}`;
let json: any = JSON.parse(myAnswers);
// Cast the json blob into a TaskLibAnswers
tmr.setAnswers(<ma.TaskLibAnswers>json);

// This is how you can mock NPM packages...
os.platform = () => {
return 'darwin';
};
tmr.registerMock('os', os);

tmr.run();
72 changes: 72 additions & 0 deletions Tasks/app-store-release/Tests/L0TestFlightFastlaneArguments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';

import ma = require('vsts-task-lib/mock-answer');
import tmrm = require('vsts-task-lib/mock-run');
import path = require('path');
import os = require('os');

let taskPath = path.join(__dirname, '..', 'app-store-release.js');
let tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

tmr.setInput('authType', 'UserAndPass');
tmr.setInput('username', 'creds-username');
tmr.setInput('password', 'creds-password');
tmr.setInput('releaseTrack', 'TestFlight');
tmr.setInput('installFastlane', 'true');
tmr.setInput('fastlaneToolsVersion', 'LatestVersion');
tmr.setInput('fastlaneArguments', '-args someadditioanlargs');

// let ipaPath: string = tl.getInput('ipaPath', true);
tmr.setInput('ipaPath', '**/*.ipa');

process.env['MOCK_NORMALIZE_SLASHES'] = true;
process.env['HOME'] = '/usr/bin';
let gemCache: string = '/usr/bin/.gem-cache';

//construct a string that is JSON, call JSON.parse(string), send that to ma.TaskLibAnswers
let myAnswers: string = `{
"which": {
"ruby": "/usr/bin/ruby",
"gem": "/usr/bin/gem",
"fastlane": "/usr/bin/fastlane"
},
"checkPath" : {
"/usr/bin/ruby": true,
"/usr/bin/gem": true,
"/usr/bin/fastlane": true
},
"glob": {
"**/*.ipa": [
"mypackage.ipa"
]
},
"exec": {
"/usr/bin/gem install fastlane": {
"code": 0,
"stdout": "1 gem installed"
},
"/usr/bin/gem update fastlane -i ${gemCache}": {
"code": 0,
"stdout": "1 gem installed"
},
"fastlane pilot upload -u creds-username -i mypackage.ipa -args someadditioanlargs": {
"code": 0,
"stdout": "consider it uploaded!"
}
}
}`;
let json: any = JSON.parse(myAnswers);
// Cast the json blob into a TaskLibAnswers
tmr.setAnswers(<ma.TaskLibAnswers>json);

// This is how you can mock NPM packages...
os.platform = () => {
return 'darwin';
};
tmr.registerMock('os', os);

tmr.run();
7 changes: 7 additions & 0 deletions Tasks/app-store-release/app-store-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ async function run() {
tl.debug('Skipped fastlane installation.');
}

let fastlaneArguments: string = tl.getInput('fastlaneArguments');
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: const over let

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are other spots in this file too, will update all of them next time.


//gem update fastlane -i ~/.gem-cache
if (releaseTrack === 'TestFlight') {
// Run pilot (via fastlane) to upload to testflight
Expand All @@ -191,7 +193,11 @@ async function run() {
if (shouldSkipSubmission || shouldSkipWaitingForProcessing) {
tl.warning(tl.loc('ExternalTestersCannotSkipWarning'));
}

let externalTestersGroups: string = tl.getInput('externalTestersGroups');
pilotCommand.argIf(externalTestersGroups, ['--groups', externalTestersGroups]);
}
pilotCommand.argIf(fastlaneArguments, fastlaneArguments);
await pilotCommand.exec();
} else if (releaseTrack === 'Production') {
let bundleIdentifier: string = tl.getInput('appIdentifier', true);
Expand All @@ -216,6 +222,7 @@ async function run() {
deliverCommand.argIf(teamName, ['-e', teamName]);
deliverCommand.argIf(shouldSubmitForReview, ['--submit_for_review', 'true']);
deliverCommand.argIf(shouldAutoRelease, ['--automatic_release', 'true']);
deliverCommand.argIf(fastlaneArguments, fastlaneArguments);
await deliverCommand.exec();
}

Expand Down
21 changes: 20 additions & 1 deletion Tasks/app-store-release/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"demands": [ "xcode" ],
"version": {
"Major": "1",
"Minor": "116",
"Minor": "126",
"Patch": "0"
},
"minimumAgentVersion": "1.95.3",
Expand Down Expand Up @@ -236,6 +236,16 @@
"groupName": "releaseOptions",
"visibleRule": "releaseTrack = TestFlight"
},
{
"name": "externalTestersGroups",
"type": "string",
"label": "Groups",
"required": false,
"defaultValue": "",
"helpMarkDown": "Optionally specify the group(s) of external testers this build should be distributed to. To specify multiple groups, separate group names by commas e.g. 'External Beta Testers,TestVendors'. If not specified the default 'External Testers' is used.",
"groupName": "releaseOptions",
"visibleRule": "distributedToExternalTesters = true"
},
{
"name": "teamId",
"type": "string",
Expand Down Expand Up @@ -283,6 +293,15 @@
"groupName": "advanced",
"helpMarkDown": "Provide the version of fastlane to install (e.g., 2.15.1). If a specific version of fastlane is installed, all previously installed versions will be uninstalled beforehand.",
"visibleRule": "fastlaneToolsVersion = SpecificVersion"
},
{
"name": "fastlaneArguments",
"type": "string",
"label": "Additional fastlane arguments",
"defaultValue": "",
"required": false,
"groupName": "advanced",
"helpMarkDown": "Any additional arguments to pass to the fastlane command."
}
],
"execution": {
Expand Down
Loading