Skip to content

Commit e366f14

Browse files
committed
Fix ci, hopefully in a pretty forwards compat way
1 parent 5c66d0a commit e366f14

File tree

4 files changed

+39
-30
lines changed

4 files changed

+39
-30
lines changed

.github/workflows/checks.yml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ jobs:
177177
action: ${{ matrix.action }}
178178

179179
configurations:
180-
runs-on: macos-13
180+
runs-on: macos-latest
181181
needs: [verify-dist]
182182
strategy:
183183
matrix:
@@ -238,8 +238,8 @@ jobs:
238238
requires: ${{ matrix.x.swift }}
239239

240240
xcode:
241-
name: ${{ matrix.platform }} (${{ matrix.action }}, ${{ matrix.xcode }}${{ matrix.codecov && ', cc' || ''}}${{ matrix.job-name-sufix }})
242-
runs-on: ${{ matrix.os || 'macos-latest' }}
241+
name: ${{ matrix.platform }} (${{ matrix.action }} ${{ matrix.xcode }} ${{ matrix.codecov && 'cc' || ''}}${{ matrix.job-name-sufix }})
242+
runs-on: macos-latest
243243
needs: [verify-dist]
244244
continue-on-error: true
245245
strategy:
@@ -250,29 +250,21 @@ jobs:
250250
- macOS
251251
- watchOS
252252
xcode:
253-
- ^14
254-
- ^15
253+
- ^16
255254
codecov:
256255
- false
257256
action:
258257
- test
259258
warnings-as-errors:
260259
- false
261260
include:
262-
- job-name-sufix: ', platform-version ^16'
261+
- job-name-sufix: ' platform-version ^17'
263262
platform: iOS
264-
platform-version: ^16
265-
os: macos-14
263+
platform-version: ^17
266264
- platform: mac-catalyst
267265
codecov: false
268-
action: test
269-
warnings-as-errors: false
270266
- platform: visionOS
271-
os: macos-14
272-
xcode: ^15
273267
codecov: false
274-
action: test
275-
warnings-as-errors: false
276268
steps:
277269
- uses: actions/checkout@v4
278270
- uses: ./
@@ -283,13 +275,13 @@ jobs:
283275
working-directory: fixtures/${{ matrix.platform }}
284276
code-coverage: ${{ matrix.codecov }}
285277
action: ${{ matrix.action }}
286-
warnings-as-errors: ${{ matrix.warnings-as-errors }}
278+
warnings-as-errors: ${{ matrix.warnings-as-errors || 'false' }}
287279
- run: |
288280
xcode-select --print-path
289281
290282
verify-codecov:
291-
name: ${{ matrix.platform }} (${{ matrix.action }}${{ matrix.codecov && ', cc' || ''}}${{ matrix.warnings-as-errors && ', warnings-as-errors' || ''}})
292-
runs-on: macos-13
283+
name: ${{ matrix.platform }} (${{ matrix.action }}${{ matrix.codecov && ', cc' || ''}}
284+
runs-on: macos-latest
293285
needs: [verify-dist]
294286
strategy:
295287
matrix:
@@ -301,9 +293,6 @@ jobs:
301293
action:
302294
- build
303295
- test
304-
warnings-as-errors:
305-
# - true
306-
- false
307296
steps:
308297
- uses: actions/checkout@v4
309298
- uses: ./
@@ -312,7 +301,6 @@ jobs:
312301
working-directory: fixtures/${{ matrix.platform }}
313302
code-coverage: ${{ matrix.codecov }}
314303
action: ${{ matrix.action }}
315-
warnings-as-errors: ${{ matrix.warnings-as-errors }}
316304

317305
verify-dot-swift-version:
318306
name: .swift-version

dist/index.js

Lines changed: 1 addition & 1 deletion
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/lib.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as fs from 'fs'
77
import semver, { Range } from 'semver'
88
import type { SemVer } from 'semver'
99

10-
async function mdls(path: string): Promise<SemVer | undefined> {
10+
async function mdls(path: string): Promise<SemVer | undefined | null> {
1111
try {
1212
const v = await exec('mdls', ['-raw', '-name', 'kMDItemVersion', path])
1313
if (core.getInput('verbosity') == 'verbose') {
@@ -18,15 +18,30 @@ async function mdls(path: string): Promise<SemVer | undefined> {
1818
return semver.coerce(v) ?? undefined
1919
} catch (e) {
2020
const match = path.match(/Xcode_(.*)\.app/)
21-
if (!match?.[1]) throw e
22-
return semver.coerce(match[1]) ?? undefined
21+
if (match?.[1]) {
22+
return semver.coerce(match[1])
23+
}
2324
}
2425
}
2526

2627
async function xcodes(): Promise<[string, SemVer][]> {
27-
const paths = (
28-
await exec('mdfind', ['kMDItemCFBundleIdentifier = com.apple.dt.Xcode'])
29-
).split('\n')
28+
const paths = await (async () => {
29+
const output = await exec('mdfind', [
30+
'kMDItemCFBundleIdentifier = com.apple.dt.Xcode',
31+
]).catch(() => '')
32+
const rv = output
33+
.split('\n')
34+
.map((path) => path.trim())
35+
.filter((x) => x)
36+
if (rv.length == 0) {
37+
for (const entry of fs.readdirSync('/Applications')) {
38+
if (!/Xcode.*\.app$/.test(entry)) continue
39+
rv.push(path.join('/Applications', entry))
40+
}
41+
}
42+
return rv
43+
})()
44+
3045
const rv: [string, SemVer][] = []
3146
for (const path of paths) {
3247
if (!path.trim()) continue
@@ -35,6 +50,7 @@ async function xcodes(): Promise<[string, SemVer][]> {
3550
rv.push([path, v])
3651
}
3752
}
53+
3854
return rv
3955
}
4056

@@ -96,7 +112,12 @@ export async function xcselect(xcode?: Range, swift?: Range): Promise<SemVer> {
96112
.sort((a, b) => semver.compare(a[1], b[1]))
97113
.pop()
98114

99-
if (!rv3) throw new Error(`No Xcode with Swift ~> ${range}`)
115+
if (!rv3)
116+
throw new Error(
117+
`No Xcode with Swift ~> ${range} (Xcodes: ${rv1.join(
118+
','
119+
)} (Swifts: ${rv2.join(',')})`
120+
)
100121

101122
core.info(`» Selected Swift ${rv3[2]}`)
102123

0 commit comments

Comments
 (0)