Skip to content

Commit fa72e3c

Browse files
authored
Bump swift version to 6.2.0 to support new macOS SDK in CI (#426)
* Bump swiftly version to 6.2.0 to support new macOS SDK in CI * In preparation for swift 6.2 remove Ubuntu 20.04 verification * Fix shell pull request shell script * Fix nightly shell script * Fix test failures by chcecking for throwing of UninstallCancelledError * Update uninstall xcode test to check for case where the xcode system toolchain is not present
1 parent 78f71b0 commit fa72e3c

File tree

7 files changed

+44
-23
lines changed

7 files changed

+44
-23
lines changed

.github/workflows/62_snapshot_check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
container: ["ubuntu:20.04", "ubuntu:22.04", "ubuntu:24.04", "redhat/ubi9", "debian:12"]
14+
container: ["ubuntu:22.04", "ubuntu:24.04", "redhat/ubi9", "debian:12"]
1515
container:
1616
image: ${{ matrix.container }}
1717
steps:
@@ -20,9 +20,9 @@ jobs:
2020
- name: Prepare the action
2121
run: ./scripts/prep-gh-action.sh --install-swiftly --swift-snapshot 6.2
2222
- name: Build and Test
23-
# UBI 9 and Ubuntu 20.04 - See https://github.com/swiftlang/swift/issues/80908
23+
# UBI 9 - See https://github.com/swiftlang/swift/issues/80908
2424
# UBI 9 - See https://github.com/swiftlang/swift/issues/80909
25-
run: bash -c 'if [[ "${{ matrix.container }}" == "redhat/ubi9" ]]; then swiftly run +6.2-snapshot swift build --build-tests; elif [[ "${{ matrix.container }}" == "ubuntu:20.04" ]]; then swiftly run +6.2-snapshot swift build --build-tests; else swiftly run +6.2-snapshot swift test; fi'
25+
run: bash -c 'if [[ "${{ matrix.container }}" == "redhat/ubi9" ]]; then swiftly run +6.2-snapshot swift build --build-tests; else swiftly run +6.2-snapshot swift test; fi'
2626

2727
tests-selfhosted-macos:
2828
name: Test (Smoke Test - Nightly Swift Toolchain) / macOS Sequoia ARM64

.github/workflows/nightly_snapshot_check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
container: ["ubuntu:20.04", "ubuntu:22.04", "ubuntu:24.04", "redhat/ubi9", "debian:12"]
14+
container: ["ubuntu:22.04", "ubuntu:24.04", "redhat/ubi9", "debian:12"]
1515
container:
1616
image: ${{ matrix.container }}
1717
steps:
@@ -20,9 +20,9 @@ jobs:
2020
- name: Prepare the action
2121
run: ./scripts/prep-gh-action.sh --install-swiftly --swift-snapshot main
2222
- name: Build and Test
23-
# UBI 9 and Ubuntu 20.04 - See https://github.com/swiftlang/swift/issues/80908
23+
# UBI 9 - See https://github.com/swiftlang/swift/issues/80908
2424
# UBI 9 - See https://github.com/swiftlang/swift/issues/80909
25-
run: bash -c 'if [[ "${{ matrix.container }}" == "redhat/ubi9" ]]; then swiftly run +main-snapshot swift build --build-tests; elif [[ "${{ matrix.container }}" == "ubuntu:20.04" ]]; then swiftly run +main-snapshot swift build --build-tests; else swiftly run +main-snapshot swift test; fi'
25+
run: bash -c 'if [[ "${{ matrix.container }}" == "redhat/ubi9" ]]; then swiftly run +main-snapshot swift build --build-tests; else swiftly run +main-snapshot swift test; fi'
2626

2727
tests-selfhosted-macos:
2828
name: Test (Smoke Test - Nightly Swift Toolchain) / macOS Sequoia ARM64

.github/workflows/pull_request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
container: ["ubuntu:20.04", "ubuntu:22.04", "ubuntu:24.04", "redhat/ubi9", "debian:12", "fedora:39"]
42+
container: ["ubuntu:22.04", "ubuntu:24.04", "redhat/ubi9", "debian:12", "fedora:39"]
4343
container:
4444
image: ${{ matrix.container }}
4545
steps:
@@ -48,9 +48,9 @@ jobs:
4848
- name: Prepare the action
4949
run: ./scripts/prep-gh-action.sh --install-swiftly
5050
- name: Build and Test
51-
# UBI 9 and Ubuntu 20.04 - See https://github.com/swiftlang/swift/issues/80908
51+
# UBI 9 - See https://github.com/swiftlang/swift/issues/80908
5252
# UBI 9 - See https://github.com/swiftlang/swift/issues/80909
53-
run: bash -c 'if [[ "${{ matrix.container }}" == "redhat/ubi9" ]]; then swift build --build-tests; elif [[ "${{ matrix.container }}" == "ubuntu:20.04" ]]; then swift build --build-tests; else swift test; fi'
53+
run: bash -c 'if [[ "${{ matrix.container }}" == "redhat/ubi9" ]]; then swift build --build-tests; else swift test; fi'
5454

5555
releasebuildcheck:
5656
name: Release Build Check / Linux

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.1.0
1+
6.2.0

Sources/Swiftly/Uninstall.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct Uninstall: SwiftlyCommand {
1010
static let allSelector = "all"
1111
}
1212

13-
private struct UninstallCancelledError: Error {}
13+
package struct UninstallCancelledError: Error {}
1414

1515
private struct ToolchainSelectionResult {
1616
let validToolchains: Set<ToolchainVersion>

Tests/SwiftlyTests/SwiftlyTests.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,11 @@ public enum SwiftlyTests {
237237
try await cmd.run(Self.ctx)
238238
}
239239

240+
public struct NoError: Error {}
241+
240242
/// Run this command, using the provided input as the stdin (in lines). Returns an array of captured
241243
/// output lines.
242-
static func runWithMockedIO<T: SwiftlyCommand>(_ commandType: T.Type, _ arguments: [String], quiet: Bool = false, input: [String]? = nil, format: SwiftlyCore.OutputFormat = .text) async throws -> [String] {
244+
static func runWithMockedIO<T: SwiftlyCommand, E: Error>(_ commandType: T.Type, _ arguments: [String], quiet: Bool = false, input: [String]? = nil, format: SwiftlyCore.OutputFormat = .text, throws expectedError: E.Type = NoError.self) async throws -> [String] {
243245
let handler = TestOutputHandler(quiet: quiet)
244246
let provider: (any InputProvider)? = if let input {
245247
TestInputProvider(lines: input)
@@ -263,7 +265,13 @@ public enum SwiftlyTests {
263265
)
264266
}
265267

266-
try await cmd.run(ctx)
268+
if expectedError != NoError.self {
269+
try await #expect(throws: expectedError) {
270+
try await cmd.run(ctx)
271+
}
272+
} else {
273+
try await cmd.run(ctx)
274+
}
267275

268276
return await handler.lines
269277
}

Tests/SwiftlyTests/UninstallTests.swift

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import Testing
88

99
/// Tests that `swiftly uninstall` successfully handles being invoked when no toolchains have been installed yet.
1010
@Test(.mockHomeToolchains(Self.homeName, toolchains: []), .mockedSwiftlyVersion()) func uninstallNoInstalledToolchains() async throws {
11-
_ = try await SwiftlyTests.runWithMockedIO(Uninstall.self, ["uninstall", "1.2.3"], input: ["y"])
11+
try await #require(throws: Uninstall.UninstallCancelledError.self) {
12+
_ = try await SwiftlyTests.runWithMockedIO(Uninstall.self, ["uninstall", "1.2.3"], input: ["y"])
13+
}
1214

1315
try await SwiftlyTests.validateInstalledToolchains(
1416
[],
@@ -33,7 +35,9 @@ import Testing
3335
}
3436

3537
// Ensure that uninstalling when no toolchains are installed is handled gracefully.
36-
try await SwiftlyTests.runCommand(Uninstall.self, ["uninstall", "latest"])
38+
try await #require(throws: Uninstall.UninstallCancelledError.self) {
39+
try await SwiftlyTests.runCommand(Uninstall.self, ["uninstall", "latest"])
40+
}
3741
}
3842
}
3943

@@ -51,7 +55,9 @@ import Testing
5155
)
5256
}
5357

54-
_ = try await SwiftlyTests.runWithMockedIO(Uninstall.self, ["uninstall", "1.2.3"], input: ["y"])
58+
try await #require(throws: Uninstall.UninstallCancelledError.self) {
59+
_ = try await SwiftlyTests.runWithMockedIO(Uninstall.self, ["uninstall", "1.2.3"], input: ["y"])
60+
}
5561

5662
try await SwiftlyTests.validateInstalledToolchains(
5763
installed,
@@ -73,7 +79,9 @@ import Testing
7379
)
7480
}
7581

76-
_ = try await SwiftlyTests.runWithMockedIO(Uninstall.self, ["uninstall", "main-snapshot-2022-01-01"], input: ["y"])
82+
try await #require(throws: Uninstall.UninstallCancelledError.self) {
83+
_ = try await SwiftlyTests.runWithMockedIO(Uninstall.self, ["uninstall", "main-snapshot-2022-01-01"], input: ["y"])
84+
}
7785

7886
try await SwiftlyTests.validateInstalledToolchains(
7987
installed,
@@ -239,7 +247,9 @@ import Testing
239247
/// Tests that aborting an uninstall works correctly.
240248
@Test(.mockedSwiftlyVersion(), .mockHomeToolchains(Self.homeName, toolchains: .allToolchains(), inUse: .oldStable)) func uninstallAbort() async throws {
241249
let preConfig = try await Config.load()
242-
_ = try await SwiftlyTests.runWithMockedIO(Uninstall.self, ["uninstall", ToolchainVersion.oldStable.name], input: ["n"])
250+
try await #require(throws: Uninstall.UninstallCancelledError.self) {
251+
_ = try await SwiftlyTests.runWithMockedIO(Uninstall.self, ["uninstall", ToolchainVersion.oldStable.name], input: ["n"])
252+
}
243253
try await SwiftlyTests.validateInstalledToolchains(
244254
.allToolchains(),
245255
description: "abort uninstall"
@@ -282,8 +292,8 @@ import Testing
282292
}
283293

284294
@Test(.mockedSwiftlyVersion(), .mockHomeToolchains(Self.homeName, toolchains: [])) func uninstallXcode() async throws {
285-
let output = try await SwiftlyTests.runWithMockedIO(Uninstall.self, ["uninstall", "-y", ToolchainVersion.xcodeVersion.name])
286-
#expect(!output.filter { $0.contains("No toolchains can be uninstalled that match \"xcode\"") }.isEmpty)
295+
let output = try await SwiftlyTests.runWithMockedIO(Uninstall.self, ["uninstall", "-y", ToolchainVersion.xcodeVersion.name], throws: Uninstall.UninstallCancelledError.self)
296+
#expect(!output.filter { $0.contains("No toolchains can be uninstalled that match \"xcode\"") || $0.contains("No toolchains match these selectors: xcode") }.isEmpty)
287297
}
288298

289299
// MARK: - Multiple Selector Tests
@@ -379,7 +389,8 @@ import Testing
379389
let output = try await SwiftlyTests.runWithMockedIO(
380390
Uninstall.self,
381391
["uninstall", ToolchainVersion.oldStable.name, "invalid-selector"],
382-
input: ["n"] // Abort at error prompt
392+
input: ["n"], // Abort at error prompt
393+
throws: Uninstall.UninstallCancelledError.self
383394
)
384395

385396
// Should show error and abort
@@ -398,7 +409,8 @@ import Testing
398409
func uninstallNoMatchSelectors() async throws {
399410
let output = try await SwiftlyTests.runWithMockedIO(
400411
Uninstall.self,
401-
["uninstall", "main-snapshot", "5.99.0"] // Neither installed
412+
["uninstall", "main-snapshot", "5.99.0"], // Neither installed
413+
throws: Uninstall.UninstallCancelledError.self
402414
)
403415

404416
#expect(output.contains { $0.contains("No toolchains match these selectors: main-snapshot, 5.99.0") })
@@ -416,7 +428,8 @@ import Testing
416428
func uninstallAllInvalidSelectors() async throws {
417429
let output = try await SwiftlyTests.runWithMockedIO(
418430
Uninstall.self,
419-
["uninstall", "invalid-1", "invalid-2"]
431+
["uninstall", "invalid-1", "invalid-2"],
432+
throws: Uninstall.UninstallCancelledError.self
420433
)
421434

422435
#expect(output.contains { $0.contains("Invalid toolchain selectors: invalid-1, invalid-2") })

0 commit comments

Comments
 (0)