Skip to content

Commit f358c3a

Browse files
authored
Merge branch 'main' into self_update_with_url
2 parents 3d93a51 + cbc8bdc commit f358c3a

28 files changed

+556
-256
lines changed

.github/workflows/nightly_snapshot_check.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@ on:
44
schedule:
55
- cron: '30 3 * * *'
66

7-
env:
8-
SWIFTLY_BOOTSTRAP_VERSION: 1.0.0
9-
107
jobs:
118
tests-selfhosted-linux:
129
name: Test (Smoke Test - Nightly Swift Toolchain) / ${{ matrix.container }}
1310
runs-on: ubuntu-latest
1411
strategy:
1512
fail-fast: false
1613
matrix:
17-
container: ["ubuntu:20.04", "ubuntu:22.04", "ubuntu:24.04", "redhat/ubi9", "debian:12", "fedora:39"]
14+
container: ["ubuntu:20.04", "ubuntu:22.04", "ubuntu:24.04", "redhat/ubi9", "debian:12"]
1815
container:
1916
image: ${{ matrix.container }}
2017
steps:
@@ -36,4 +33,4 @@ jobs:
3633
- name: Prepare the action
3734
run: ./scripts/prep-gh-action.sh --install-swiftly --swift-main-snapshot
3835
- name: Build and Test
39-
run: swift test
36+
run: swiftly run +main-snapshot swift test

.github/workflows/pull_request.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
push:
77
branches: [main]
88

9-
env:
10-
SWIFTLY_BOOTSTRAP_VERSION: 1.0.1-dev
11-
129
jobs:
1310
soundness:
1411
name: Soundness

Documentation/SwiftlyDocs.docc/swiftly-cli-reference.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Note that listing available snapshots before the latest release (major and minor
152152
Set the in-use or default toolchain. If no toolchain is provided, print the currently in-use toolchain, if any.
153153

154154
```
155-
swiftly use [--print-location] [--global-default] [--assume-yes] [--verbose] [<toolchain>] [--version] [--help]
155+
swiftly use [--print-location] [--global-default] [--format=<format>] [--assume-yes] [--verbose] [<toolchain>] [--version] [--help]
156156
```
157157

158158
**--print-location:**
@@ -165,6 +165,11 @@ swiftly use [--print-location] [--global-default] [--assume-yes] [--verbose] [<t
165165
*Set the global default toolchain that is used when there are no .swift-version files.*
166166

167167

168+
**--format=\<format\>:**
169+
170+
*Output format (text, json)*
171+
172+
168173
**--assume-yes:**
169174

170175
*Disable confirmation prompts by assuming 'yes'*

Sources/LinuxPlatform/Linux.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public struct Linux: Platform {
342342
try await fs.mkdir(atPath: self.swiftlyToolchainsDir(ctx))
343343
}
344344

345-
await ctx.print("Extracting toolchain...")
345+
await ctx.message("Extracting toolchain...")
346346
let toolchainDir = self.swiftlyToolchainsDir(ctx) / version.name
347347

348348
if try await fs.exists(atPath: toolchainDir) {
@@ -376,7 +376,7 @@ public struct Linux: Platform {
376376
let tmpDir = self.getTempFilePath()
377377
try await fs.mkdir(.parents, atPath: tmpDir)
378378
try await fs.withTemporary(files: tmpDir) {
379-
await ctx.print("Extracting new swiftly...")
379+
await ctx.message("Extracting new swiftly...")
380380
try extractArchive(atPath: archive) { name in
381381
// Extract to the temporary directory
382382
tmpDir / String(name)
@@ -405,15 +405,15 @@ public struct Linux: Platform {
405405
_ ctx: SwiftlyCoreContext, toolchainFile: ToolchainFile, archive: FilePath, verbose: Bool
406406
) async throws {
407407
if verbose {
408-
await ctx.print("Downloading toolchain signature...")
408+
await ctx.message("Downloading toolchain signature...")
409409
}
410410

411411
let sigFile = self.getTempFilePath()
412412
try await fs.create(file: sigFile, contents: nil)
413413
try await fs.withTemporary(files: sigFile) {
414414
try await ctx.httpClient.getSwiftToolchainFileSignature(toolchainFile).download(to: sigFile)
415415

416-
await ctx.print("Verifying toolchain signature...")
416+
await ctx.message("Verifying toolchain signature...")
417417
do {
418418
if let mockedHomeDir = ctx.mockedHomeDir {
419419
var env = ProcessInfo.processInfo.environment
@@ -432,7 +432,7 @@ public struct Linux: Platform {
432432
_ ctx: SwiftlyCoreContext, archiveDownloadURL: URL, archive: FilePath, verbose: Bool
433433
) async throws {
434434
if verbose {
435-
await ctx.print("Downloading swiftly signature...")
435+
await ctx.message("Downloading swiftly signature...")
436436
}
437437

438438
let sigFile = self.getTempFilePath()
@@ -442,7 +442,7 @@ public struct Linux: Platform {
442442
url: archiveDownloadURL.appendingPathExtension("sig")
443443
).download(to: sigFile)
444444

445-
await ctx.print("Verifying swiftly signature...")
445+
await ctx.message("Verifying swiftly signature...")
446446
do {
447447
if let mockedHomeDir = ctx.mockedHomeDir {
448448
var env = ProcessInfo.processInfo.environment
@@ -461,19 +461,19 @@ public struct Linux: Platform {
461461
-> PlatformDefinition
462462
{
463463
if let platformPretty {
464-
print(
464+
await ctx.message(
465465
"\(platformPretty) is not an officially supported platform, but the toolchains for another platform may still work on it."
466466
)
467467
} else {
468-
print(
468+
await ctx.message(
469469
"This platform could not be detected, but a toolchain for one of the supported platforms may work on it."
470470
)
471471
}
472472

473473
let selections = self.linuxPlatforms.enumerated().map { "\($0 + 1)) \($1.namePretty)" }.joined(
474474
separator: "\n")
475475

476-
print(
476+
await ctx.message(
477477
"""
478478
Please select the platform to use for toolchain downloads:
479479
@@ -526,7 +526,7 @@ public struct Linux: Platform {
526526
if disableConfirmation {
527527
throw SwiftlyError(message: message)
528528
} else {
529-
print(message)
529+
await ctx.message(message)
530530
}
531531
return await self.manualSelectPlatform(ctx, platformPretty)
532532
}
@@ -557,7 +557,7 @@ public struct Linux: Platform {
557557
if disableConfirmation {
558558
throw SwiftlyError(message: message)
559559
} else {
560-
print(message)
560+
await ctx.message(message)
561561
}
562562
return await self.manualSelectPlatform(ctx, platformPretty)
563563
}
@@ -568,7 +568,7 @@ public struct Linux: Platform {
568568
if disableConfirmation {
569569
throw SwiftlyError(message: message)
570570
} else {
571-
print(message)
571+
await ctx.message(message)
572572
}
573573
return await self.manualSelectPlatform(ctx, platformPretty)
574574
}
@@ -580,7 +580,7 @@ public struct Linux: Platform {
580580
if disableConfirmation {
581581
throw SwiftlyError(message: message)
582582
} else {
583-
print(message)
583+
await ctx.message(message)
584584
}
585585
return await self.manualSelectPlatform(ctx, platformPretty)
586586
}
@@ -596,7 +596,7 @@ public struct Linux: Platform {
596596
if disableConfirmation {
597597
throw SwiftlyError(message: message)
598598
} else {
599-
print(message)
599+
await ctx.message(message)
600600
}
601601
return await self.manualSelectPlatform(ctx, platformPretty)
602602
}

Sources/MacOSPlatform/MacOS.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ public struct MacOS: Platform {
6969

7070
if toolchainsDir == self.defaultToolchainsDirectory {
7171
// If the toolchains go into the default user location then we use the installer to install them
72-
await ctx.print("Installing package in user home directory...")
72+
await ctx.message("Installing package in user home directory...")
7373

7474
try await sys.installer(.verbose, .pkg(tmpFile), .target("CurrentUserHomeDirectory")).run(self, quiet: !verbose)
7575
} else {
7676
// Otherwise, we extract the pkg into the requested toolchains directory.
77-
await ctx.print("Expanding pkg...")
77+
await ctx.message("Expanding pkg...")
7878
let tmpDir = fs.mktemp()
7979
let toolchainDir = toolchainsDir / "\(version.identifier).xctoolchain"
8080

8181
if !(try await fs.exists(atPath: toolchainDir)) {
8282
try await fs.mkdir(atPath: toolchainDir)
8383
}
8484

85-
await ctx.print("Checking package signature...")
85+
await ctx.message("Checking package signature...")
8686
do {
8787
try await sys.pkgutil().checksignature(pkg_path: tmpFile).run(self, quiet: !verbose)
8888
} catch {
@@ -92,7 +92,7 @@ public struct MacOS: Platform {
9292
}
9393

9494
// We permit the signature verification to fail during testing
95-
await ctx.print("Signature verification failed, which is allowable during testing with mocked toolchains")
95+
await ctx.message("Signature verification failed, which is allowable during testing with mocked toolchains")
9696
}
9797
try await sys.pkgutil(.verbose).expand(pkg_path: tmpFile, dir_path: tmpDir).run(self, quiet: !verbose)
9898

@@ -103,7 +103,7 @@ public struct MacOS: Platform {
103103
payload = tmpDir / "\(version.identifier)-osx-package.pkg/Payload"
104104
}
105105

106-
await ctx.print("Untarring pkg Payload...")
106+
await ctx.message("Untarring pkg Payload...")
107107
try await sys.tar(.directory(toolchainDir)).extract(.verbose, .archive(payload)).run(self, quiet: !verbose)
108108
}
109109
}
@@ -116,7 +116,7 @@ public struct MacOS: Platform {
116116
let userHomeDir = ctx.mockedHomeDir ?? fs.home
117117

118118
if ctx.mockedHomeDir == nil {
119-
await ctx.print("Extracting the swiftly package...")
119+
await ctx.message("Extracting the swiftly package...")
120120
try await sys.installer(
121121
.pkg(archive),
122122
.target("CurrentUserHomeDirectory")
@@ -138,7 +138,7 @@ public struct MacOS: Platform {
138138
throw SwiftlyError(message: "Payload file could not be found at \(tmpDir).")
139139
}
140140

141-
await ctx.print("Extracting the swiftly package into \(installDir)...")
141+
await ctx.message("Extracting the swiftly package into \(installDir)...")
142142
try await sys.tar(.directory(installDir)).extract(.verbose, .archive(payload)).run(self, quiet: false)
143143
}
144144

@@ -149,7 +149,7 @@ public struct MacOS: Platform {
149149
async throws
150150
{
151151
if verbose {
152-
await ctx.print("Uninstalling package in user home directory... ")
152+
await ctx.message("Uninstalling package in user home directory... ")
153153
}
154154

155155
let toolchainDir = self.swiftlyToolchainsDir(ctx) / "\(toolchain.identifier).xctoolchain"

Sources/Swiftly/Init.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct Init: SwiftlyCommand {
124124
"""
125125
}
126126

127-
await ctx.print(msg)
127+
await ctx.message(msg)
128128

129129
guard await ctx.promptForConfirmation(defaultBehavior: true) else {
130130
throw SwiftlyError(message: "swiftly installation has been cancelled")
@@ -193,7 +193,7 @@ struct Init: SwiftlyCommand {
193193
let envFileExists = try await fs.exists(atPath: envFile)
194194

195195
if overwrite || !envFileExists {
196-
await ctx.print("Creating shell environment file for the user...")
196+
await ctx.message("Creating shell environment file for the user...")
197197
var env = ""
198198
if shell.hasSuffix("fish") {
199199
env = """
@@ -221,7 +221,7 @@ struct Init: SwiftlyCommand {
221221
}
222222

223223
if !noModifyProfile {
224-
await ctx.print("Updating profile...")
224+
await ctx.message("Updating profile...")
225225

226226
let userHome = ctx.mockedHomeDir ?? fs.home
227227

@@ -275,7 +275,7 @@ struct Init: SwiftlyCommand {
275275
}
276276

277277
if !quietShellFollowup {
278-
await ctx.print("""
278+
await ctx.message("""
279279
To begin using installed swiftly from your current shell, first run the following command:
280280
\(sourceLine)
281281
@@ -284,7 +284,7 @@ struct Init: SwiftlyCommand {
284284

285285
// Fish doesn't have path caching, so this might only be needed for bash/zsh
286286
if pathChanged && !quietShellFollowup && !shell.hasSuffix("fish") {
287-
await ctx.print("""
287+
await ctx.message("""
288288
Your shell caches items on your path for better performance. Swiftly has added
289289
items to your path that may not get picked up right away. You can update your
290290
shell's environment by running
@@ -297,7 +297,7 @@ struct Init: SwiftlyCommand {
297297
}
298298

299299
if let postInstall {
300-
await ctx.print(Messages.postInstall(postInstall))
300+
await ctx.message(Messages.postInstall(postInstall))
301301
}
302302
}
303303
}

0 commit comments

Comments
 (0)