Skip to content
This repository was archived by the owner on Aug 14, 2020. It is now read-only.

Commit b7667ca

Browse files
author
Ignacio Bonafonte
committed
Allow selecting the version of the Scope agent to use
1 parent 2dab0c0 commit b7667ca

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ configuration: configuration for testing, by default: 'Debug'
3838
sdk: Sdk used for building, by default: 'iphonesimulator' will be used
3939
destination: destination for testing, by default: 'platform=iOS Simulator,name=iPhone 11'
4040
instrumentHttpPayloads: Whether Scope should instrument HTTP payloads, 'false' by default
41+
agentVersion: Version of the Scope agent to use for testing, by default the latest stable
4142
```
4243
4344
<!--For SPM packages, in the case of multiplatform projects, executable targets are not supported in iOS. Desabling targets per platform is still not supported in SPM, so in the meantime you can put a Package_iOS.swift beside de original Package.swift and the action will use this for building-->

dist/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ async function run() {
6868
const sdk = core.getInput('sdk') || 'iphonesimulator';
6969
const destination = core.getInput('destination') || 'platform=iOS Simulator,name=iPhone 11';
7070
const configuration = core.getInput('configuration') || 'Debug';
71+
const agentVersion = core.getInput('agentVersion');
7172

7273
//Read project
7374
const workspace = await getWorkspace();
@@ -105,10 +106,10 @@ async function run() {
105106
createXCConfigFile(configFilePath);
106107

107108
//enableCodeCoverage in xcodebuild doesn't work with test plans, configure them before
108-
configureTestPlansForCoverage(projectParameter, scheme)
109+
configureTestPlansForCoverage(projectParameter, scheme);
109110

110111
//download scope
111-
await downloadLatestScope();
112+
await downloadLatestScope(agentVersion);
112113

113114
//build for testing
114115
let buildCommand = 'xcodebuild build-for-testing -enableCodeCoverage YES -xcconfig ' + configFilePath + ' ' + projectParameter + ' -configuration '+ configuration +
@@ -284,7 +285,7 @@ function createXCConfigFile(path) {
284285
fs.writeFileSync(path, configText,null);
285286
}
286287

287-
async function downloadLatestScope() {
288+
async function downloadLatestScope(agentVersion) {
288289
const versionsUrl = 'https://releases.undefinedlabs.com/scope/agents/ios/ScopeAgent.json';
289290
const jsonResponse = await fetch(versionsUrl);
290291
const versions = await jsonResponse.json();
@@ -294,7 +295,7 @@ async function downloadLatestScope() {
294295
currentVersion = name
295296
}
296297
});
297-
const scopeURL = versions[currentVersion];
298+
const scopeURL = versions[agentVersion] || versions[currentVersion];
298299
const scopePath = scopeDir + '/scopeAgent.zip';
299300
await downloadFile(scopeURL, scopePath);
300301

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async function run() {
2020
const sdk = core.getInput('sdk') || 'iphonesimulator';
2121
const destination = core.getInput('destination') || 'platform=iOS Simulator,name=iPhone 11';
2222
const configuration = core.getInput('configuration') || 'Debug';
23+
const agentVersion = core.getInput('agentVersion');
2324

2425
//Read project
2526
const workspace = await getWorkspace();
@@ -57,10 +58,10 @@ async function run() {
5758
createXCConfigFile(configFilePath);
5859

5960
//enableCodeCoverage in xcodebuild doesn't work with test plans, configure them before
60-
configureTestPlansForCoverage(projectParameter, scheme)
61+
configureTestPlansForCoverage(projectParameter, scheme);
6162

6263
//download scope
63-
await downloadLatestScope();
64+
await downloadLatestScope(agentVersion);
6465

6566
//build for testing
6667
let buildCommand = 'xcodebuild build-for-testing -enableCodeCoverage YES -xcconfig ' + configFilePath + ' ' + projectParameter + ' -configuration '+ configuration +
@@ -236,7 +237,7 @@ function createXCConfigFile(path) {
236237
fs.writeFileSync(path, configText,null);
237238
}
238239

239-
async function downloadLatestScope() {
240+
async function downloadLatestScope(agentVersion) {
240241
const versionsUrl = 'https://releases.undefinedlabs.com/scope/agents/ios/ScopeAgent.json';
241242
const jsonResponse = await fetch(versionsUrl);
242243
const versions = await jsonResponse.json();
@@ -246,7 +247,7 @@ async function downloadLatestScope() {
246247
currentVersion = name
247248
}
248249
});
249-
const scopeURL = versions[currentVersion];
250+
const scopeURL = versions[agentVersion] || versions[currentVersion];
250251
const scopePath = scopeDir + '/scopeAgent.zip';
251252
await downloadFile(scopeURL, scopePath);
252253

0 commit comments

Comments
 (0)