Skip to content

Commit ef2a64f

Browse files
authored
Merge pull request #80 from allisonmoyer/add-workspace
Add a workspace input
2 parents f3cecd8 + 27cbe49 commit ef2a64f

6 files changed

Lines changed: 71 additions & 31 deletions

File tree

.github/workflows/checks.yml

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
on:
22
pull_request:
33
paths:
4-
- '*.ts'
5-
- 'fixtures/**/*.swift'
4+
- src/*.ts
5+
- fixtures/**/*.swift
66
- .github/workflows/checks.yml
77
- dist/*
88
schedule:
@@ -14,18 +14,28 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17+
verify-dist:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- run: npm i
22+
- run: npm run prepare
23+
- run: git diff --exit-code
24+
1725
defaults:
1826
runs-on: macos-latest
27+
needs: [verify-dist]
1928
steps:
20-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v3
2130
- uses: ./
2231
with:
2332
working-directory: fixtures/debug
2433

2534
xcodebuild-has-exited:
2635
runs-on: macos-latest
36+
needs: [verify-dist]
2737
steps:
28-
- uses: actions/checkout@v2
38+
- uses: actions/checkout@v3
2939
- uses: ./
3040
with:
3141
working-directory: fixtures/debug
@@ -37,8 +47,9 @@ jobs:
3747
3848
executable-runs:
3949
runs-on: macos-latest
50+
needs: [verify-dist]
4051
steps:
41-
- uses: actions/checkout@v2
52+
- uses: actions/checkout@v3
4253
- uses: ./
4354
with:
4455
action: build
@@ -52,8 +63,9 @@ jobs:
5263
5364
invalid-action-fails:
5465
runs-on: macos-latest
66+
needs: [verify-dist]
5567
steps:
56-
- uses: actions/checkout@v2
68+
- uses: actions/checkout@v3
5769
- uses: ./
5870
id: xcodebuild
5971
with:
@@ -67,8 +79,9 @@ jobs:
6779
6880
invalid-platform-fails:
6981
runs-on: macos-latest
82+
needs: [verify-dist]
7083
steps:
71-
- uses: actions/checkout@v2
84+
- uses: actions/checkout@v3
7285
- uses: ./
7386
id: xcodebuild
7487
with:
@@ -82,8 +95,9 @@ jobs:
8295
8396
invalid-swift-fails:
8497
runs-on: macos-latest
98+
needs: [verify-dist]
8599
steps:
86-
- uses: actions/checkout@v2
100+
- uses: actions/checkout@v3
87101
- uses: ./
88102
id: xcodebuild
89103
with:
@@ -97,8 +111,9 @@ jobs:
97111
98112
invalid-xcode-fails:
99113
runs-on: macos-latest
114+
needs: [verify-dist]
100115
steps:
101-
- uses: actions/checkout@v2
116+
- uses: actions/checkout@v3
102117
- uses: ./
103118
id: xcodebuild
104119
with:
@@ -112,8 +127,9 @@ jobs:
112127
113128
missing-api-key-id-fails:
114129
runs-on: macos-latest
130+
needs: [verify-dist]
115131
steps:
116-
- uses: actions/checkout@v2
132+
- uses: actions/checkout@v3
117133
- uses: ./
118134
id: xcodebuild
119135
with:
@@ -128,8 +144,9 @@ jobs:
128144
129145
missing-api-key-issuer-id-fails:
130146
runs-on: macos-latest
147+
needs: [verify-dist]
131148
steps:
132-
- uses: actions/checkout@v2
149+
- uses: actions/checkout@v3
133150
- uses: ./
134151
id: xcodebuild
135152
with:
@@ -144,6 +161,7 @@ jobs:
144161
145162
null-none-action:
146163
runs-on: macos-latest
164+
needs: [verify-dist]
147165
strategy:
148166
matrix:
149167
action:
@@ -152,21 +170,22 @@ jobs:
152170
- ''
153171
- none
154172
steps:
155-
- uses: actions/checkout@v2
173+
- uses: actions/checkout@v3
156174
- uses: ./
157175
with:
158176
working-directory: fixtures/debug
159177
action: ${{ matrix.action }}
160178

161179
configurations:
162180
runs-on: macos-latest
181+
needs: [verify-dist]
163182
strategy:
164183
matrix:
165184
configuration:
166185
- debug
167186
- release
168187
steps:
169-
- uses: actions/checkout@v2
188+
- uses: actions/checkout@v3
170189
- uses: ./
171190
with:
172191
configuration: ${{ matrix.configuration }}
@@ -177,14 +196,15 @@ jobs:
177196

178197
verbosity:
179198
runs-on: macos-latest
199+
needs: [verify-dist]
180200
strategy:
181201
matrix:
182202
verbosity:
183203
- xcpretty
184204
- quiet
185205
- verbose
186206
steps:
187-
- uses: actions/checkout@v2
207+
- uses: actions/checkout@v3
188208
- uses: ./
189209
with:
190210
verbosity: ${{ matrix.verbosity }}
@@ -193,6 +213,7 @@ jobs:
193213
swift:
194214
name: swift ${{ matrix.swift }}
195215
runs-on: ${{ matrix.os }}
216+
needs: [verify-dist]
196217
strategy:
197218
matrix:
198219
swift:
@@ -210,7 +231,7 @@ jobs:
210231
- swift: ~5.6
211232
os: macos-12
212233
steps:
213-
- uses: actions/checkout@v2
234+
- uses: actions/checkout@v3
214235
- uses: ./
215236
with:
216237
swift: ${{ matrix.swift }}
@@ -223,6 +244,7 @@ jobs:
223244
xcode:
224245
name: ${{ matrix.platform }} (${{ matrix.action }}, ${{ matrix.xcode }}${{ matrix.codecov && ', cc' || ''}})
225246
runs-on: ${{ matrix.os || 'macos-11' }}
247+
needs: [verify-dist]
226248
strategy:
227249
matrix:
228250
platform:
@@ -252,7 +274,7 @@ jobs:
252274
action: test
253275
warnings-as-errors: false
254276
steps:
255-
- uses: actions/checkout@v2
277+
- uses: actions/checkout@v3
256278
- uses: ./
257279
with:
258280
platform: ${{ matrix.platform }}
@@ -268,6 +290,7 @@ jobs:
268290
more-xcode:
269291
name: ${{ matrix.platform }} (${{ matrix.action }}, ${{ matrix.xcode }}${{ matrix.codecov && ', cc' || ''}}, ${{ matrix.os }})
270292
runs-on: ${{ matrix.os }}
293+
needs: [verify-dist]
271294
strategy:
272295
matrix:
273296
os:
@@ -285,7 +308,7 @@ jobs:
285308
warnings-as-errors:
286309
- false
287310
steps:
288-
- uses: actions/checkout@v2
311+
- uses: actions/checkout@v3
289312
- uses: ./
290313
with:
291314
platform: ${{ matrix.platform }}
@@ -298,6 +321,7 @@ jobs:
298321
verify-codecov:
299322
name: ${{ matrix.platform }} (${{ matrix.action }}${{ matrix.codecov && ', cc' || ''}}${{ matrix.warnings-as-errors && ', warnings-as-errors' || ''}})
300323
runs-on: macos-latest
324+
needs: [verify-dist]
301325
strategy:
302326
matrix:
303327
platform:
@@ -312,7 +336,7 @@ jobs:
312336
- true
313337
- false
314338
steps:
315-
- uses: actions/checkout@v2
339+
- uses: actions/checkout@v3
316340
- uses: ./
317341
with:
318342
platform: ${{ matrix.platform }}
@@ -325,8 +349,9 @@ jobs:
325349
verify-swift-version:
326350
name: .swift-version
327351
runs-on: macos-10.15
352+
needs: [verify-dist]
328353
steps:
329-
- uses: actions/checkout@v2
354+
- uses: actions/checkout@v3
330355
- uses: mxcl/get-swift-version@v1
331356
with:
332357
requires: '>5.1'

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ inputs:
9999
A scheme defined by an Xcode project or workspace.
100100
If not specified, xcodebuild builds only the first target.
101101
required: false
102+
workspace:
103+
description: |
104+
The name of your workspace.
105+
Use this option when your scheme is contained in an Xcode workspace.
106+
required: false
102107
warnings-as-errors:
103108
description: Fails the build if any warnings in *non test targets*.
104109
required: false

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async function main() {
4444
const destination = await getDestination(selected, platform)
4545
const identity = getIdentity(core.getInput('code-sign-identity'), platform)
4646
const xcpretty = verbosity() == 'xcpretty'
47+
const workspace = core.getInput('workspace')
4748

4849
core.info(`» Selected Xcode ${selected}`)
4950

@@ -57,7 +58,7 @@ async function main() {
5758
await configureKeychain()
5859
await configureProvisioningProfiles()
5960

60-
await build(await getScheme())
61+
await build(await getScheme(workspace), workspace)
6162

6263
if (core.getInput('upload-logs') == 'always') {
6364
await uploadLogs()
@@ -178,22 +179,27 @@ async function main() {
178179
await createProvisioningProfiles(profiles, mobileProfiles)
179180
}
180181

181-
async function build(scheme?: string) {
182+
async function build(scheme?: string, workspace?: string) {
182183
if (warningsAsErrors && actionIsTestable(action)) {
183-
await xcodebuild('build', scheme)
184+
await xcodebuild('build', scheme, workspace)
184185
}
185-
await xcodebuild(action, scheme)
186+
await xcodebuild(action, scheme, workspace)
186187
}
187188

188189
//// helper funcs
189190

190-
async function xcodebuild(action?: string, scheme?: string) {
191+
async function xcodebuild(
192+
action?: string,
193+
scheme?: string,
194+
workspace?: string
195+
) {
191196
if (action === 'none') return
192197

193198
const title = ['xcodebuild', action].filter((x) => x).join(' ')
194199
await core.group(title, async () => {
195200
let args = destination
196201
if (scheme) args = args.concat(['-scheme', scheme])
202+
if (workspace) args = args.concat(['-workspace', workspace])
197203
if (identity) args = args.concat(identity)
198204
if (verbosity() == 'quiet') args.push('-quiet')
199205
if (configuration) args = args.concat(['-configuration', configuration])
@@ -223,14 +229,14 @@ async function main() {
223229
}
224230

225231
//NOTE this is not nearly clever enough I think
226-
async function getScheme(): Promise<string | undefined> {
232+
async function getScheme(workspace?: string): Promise<string | undefined> {
227233
const scheme = core.getInput('scheme')
228234
if (scheme) {
229235
return scheme
230236
}
231237

232238
if (swiftPM) {
233-
return getSchemeFromPackage()
239+
return getSchemeFromPackage(workspace)
234240
}
235241
}
236242
}

src/lib.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,12 @@ interface Schemes {
159159
}
160160
}
161161

162-
export async function getSchemeFromPackage(): Promise<string> {
163-
const out = await exec('xcodebuild', ['-list', '-json'])
162+
export async function getSchemeFromPackage(
163+
workspace?: string
164+
): Promise<string> {
165+
let args = ['-list', '-json']
166+
if (workspace) args = args.concat(['-workspace', workspace])
167+
const out = await exec('xcodebuild', args)
164168
const json = parseJSON<Schemes>(out)
165169
const schemes = (json?.workspace ?? json?.project)?.schemes
166170
if (!schemes || schemes.length == 0)

0 commit comments

Comments
 (0)