Skip to content

Commit b918c7d

Browse files
committed
Merge branch 'main' of https://github.com/swiftlang/swiftly into build-swiftly-release-cleanup
2 parents 7c9dadb + bd30c05 commit b918c7d

33 files changed

+1904
-296
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Smoke Test - Nightly Swift Toolchain
2+
3+
on:
4+
schedule:
5+
- cron: '30 3 * * *'
6+
7+
env:
8+
SWIFTLY_BOOTSTRAP_VERSION: 1.0.0
9+
10+
jobs:
11+
tests-selfhosted:
12+
name: Test (Smoke Test - Nightly Swift Toolchain) / ${{ matrix.container }}
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
container: ["ubuntu:20.04", "ubuntu:22.04", "ubuntu:24.04", "redhat/ubi9", "debian:12", "fedora:39"]
18+
container:
19+
image: ${{ matrix.container }}
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
- name: Prepare the action
24+
run: ./scripts/prep-gh-action.sh --install-swiftly --swift-main-snapshot
25+
- name: Build and Test
26+
# UBI 9 and Ubuntu 20.04 - See https://github.com/swiftlang/swift/issues/80908
27+
# UBI 9 - See https://github.com/swiftlang/swift/issues/80909
28+
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'

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

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,81 @@ The script will receive the argument '+abcde' followed by '+xyz'.
545545

546546

547547

548+
## link
549+
550+
Link swiftly so it resumes management of the active toolchain.
551+
552+
```
553+
swiftly link [<toolchain-selector>] [--assume-yes] [--verbose] [--version] [--help]
554+
```
555+
556+
**toolchain-selector:**
557+
558+
*Links swiftly if it has been disabled.*
559+
560+
561+
Links swiftly if it has been disabled.
562+
563+
564+
**--assume-yes:**
565+
566+
*Disable confirmation prompts by assuming 'yes'*
567+
568+
569+
**--verbose:**
570+
571+
*Enable verbose reporting from swiftly*
572+
573+
574+
**--version:**
575+
576+
*Show the version.*
577+
578+
579+
**--help:**
580+
581+
*Show help information.*
582+
583+
584+
585+
586+
## unlink
587+
588+
Unlinks swiftly so it no longer manages the active toolchain.
589+
590+
```
591+
swiftly unlink [<toolchain-selector>] [--assume-yes] [--verbose] [--version] [--help]
592+
```
593+
594+
**toolchain-selector:**
595+
596+
*Unlinks swiftly, allowing the system default toolchain to be used.*
597+
598+
599+
Unlinks swiftly until swiftly is linked again with:
600+
601+
$ swiftly link
602+
603+
604+
**--assume-yes:**
605+
606+
*Disable confirmation prompts by assuming 'yes'*
607+
608+
609+
**--verbose:**
610+
611+
*Enable verbose reporting from swiftly*
612+
613+
614+
**--version:**
615+
616+
*Show the version.*
617+
618+
619+
**--help:**
620+
621+
*Show help information.*
622+
623+
624+
625+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ This command checks to see if there are new versions of swiftly itself and upgra
6161

6262
Welcome to the Swift community!
6363

64-
Contributions to Swiftly are welcomed and encouraged! Please see the [Contributing to Swift guide](swift.org/contributing) and check out the [structure of the community](https://www.swift.org/community/#community-structure).
64+
Contributions to Swiftly are welcomed and encouraged! Please see the [Contributing to Swift guide](https://www.swift.org/contributing) and check out the [structure of the community](https://www.swift.org/community/#community-structure).
6565

6666
To be a truly great community, Swift needs to welcome developers from all walks of life, with different backgrounds, and with a wide range of experience. A diverse and friendly community will have more great ideas, more unique perspectives, and produce more great code. We will work diligently to make the Swift community welcoming to everyone.
6767

Sources/LinuxPlatform/Linux.swift

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,11 @@ public struct Linux: Platform {
275275
try await fs.withTemporary(files: tmpFile) {
276276
try await ctx.httpClient.getGpgKeys().download(to: tmpFile)
277277
if let mockedHomeDir = ctx.mockedHomeDir {
278-
try self.runProgram(
279-
"gpg", "--import", "\(tmpFile)", quiet: true,
280-
env: ["GNUPGHOME": (mockedHomeDir / ".gnupg").string]
281-
)
278+
var env = ProcessInfo.processInfo.environment
279+
env["GNUPGHOME"] = (mockedHomeDir / ".gnupg").string
280+
try await sys.gpg()._import(keys: tmpFile).run(self, env: env, quiet: true)
282281
} else {
283-
try self.runProgram("gpg", "--import", "\(tmpFile)", quiet: true)
282+
try await sys.gpg()._import(keys: tmpFile).run(self, quiet: true)
284283
}
285284
}
286285
}
@@ -417,12 +416,11 @@ public struct Linux: Platform {
417416
await ctx.print("Verifying toolchain signature...")
418417
do {
419418
if let mockedHomeDir = ctx.mockedHomeDir {
420-
try self.runProgram(
421-
"gpg", "--verify", "\(sigFile)", "\(archive)", quiet: false,
422-
env: ["GNUPGHOME": (mockedHomeDir / ".gnupg").string]
423-
)
419+
var env = ProcessInfo.processInfo.environment
420+
env["GNUPGHOME"] = (mockedHomeDir / ".gnupg").string
421+
try await sys.gpg().verify(detachedSignature: sigFile, signedData: archive).run(self, env: env, quiet: false)
424422
} else {
425-
try self.runProgram("gpg", "--verify", "\(sigFile)", "\(archive)", quiet: !verbose)
423+
try await sys.gpg().verify(detachedSignature: sigFile, signedData: archive).run(self, quiet: !verbose)
426424
}
427425
} catch {
428426
throw SwiftlyError(message: "Signature verification failed: \(error).")
@@ -447,12 +445,11 @@ public struct Linux: Platform {
447445
await ctx.print("Verifying swiftly signature...")
448446
do {
449447
if let mockedHomeDir = ctx.mockedHomeDir {
450-
try self.runProgram(
451-
"gpg", "--verify", "\(sigFile)", "\(archive)", quiet: false,
452-
env: ["GNUPGHOME": (mockedHomeDir / ".gnupg").string]
453-
)
448+
var env = ProcessInfo.processInfo.environment
449+
env["GNUPGHOME"] = (mockedHomeDir / ".gnupg").string
450+
try await sys.gpg().verify(detachedSignature: sigFile, signedData: archive).run(self, env: env, quiet: false)
454451
} else {
455-
try self.runProgram("gpg", "--verify", "\(sigFile)", "\(archive)", quiet: !verbose)
452+
try await sys.gpg().verify(detachedSignature: sigFile, signedData: archive).run(self, quiet: !verbose)
456453
}
457454
} catch {
458455
throw SwiftlyError(message: "Signature verification failed: \(error).")

Sources/MacOSPlatform/MacOS.swift

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ public struct MacOS: Platform {
7070
if toolchainsDir == self.defaultToolchainsDirectory {
7171
// If the toolchains go into the default user location then we use the installer to install them
7272
await ctx.print("Installing package in user home directory...")
73-
try runProgram(
74-
"installer", "-verbose", "-pkg", "\(tmpFile)", "-target", "CurrentUserHomeDirectory",
75-
quiet: !verbose
76-
)
73+
74+
try await sys.installer(.verbose, pkg: tmpFile, target: "CurrentUserHomeDirectory").run(self, quiet: !verbose)
7775
} else {
7876
// Otherwise, we extract the pkg into the requested toolchains directory.
7977
await ctx.print("Expanding pkg...")
@@ -86,7 +84,7 @@ public struct MacOS: Platform {
8684

8785
await ctx.print("Checking package signature...")
8886
do {
89-
try runProgram("pkgutil", "--check-signature", "\(tmpFile)", quiet: !verbose)
87+
try await sys.pkgutil().checkSignature(pkgPath: tmpFile).run(self, quiet: !verbose)
9088
} catch {
9189
// If this is not a test that uses mocked toolchains then we must throw this error and abort installation
9290
guard ctx.mockedHomeDir != nil else {
@@ -96,7 +94,7 @@ public struct MacOS: Platform {
9694
// We permit the signature verification to fail during testing
9795
await ctx.print("Signature verification failed, which is allowable during testing with mocked toolchains")
9896
}
99-
try runProgram("pkgutil", "--verbose", "--expand", "\(tmpFile)", "\(tmpDir)", quiet: !verbose)
97+
try await sys.pkgutil(.verbose).expand(pkgPath: tmpFile, dirPath: tmpDir).run(self, quiet: !verbose)
10098

10199
// There's a slight difference in the location of the special Payload file between official swift packages
102100
// and the ones that are mocked here in the test framework.
@@ -106,7 +104,7 @@ public struct MacOS: Platform {
106104
}
107105

108106
await ctx.print("Untarring pkg Payload...")
109-
try runProgram("tar", "-C", "\(toolchainDir)", "-xvf", "\(payload)", quiet: !verbose)
107+
try await sys.tar(.directory(toolchainDir)).extract(.verbose, .archive(payload)).run(self, quiet: !verbose)
110108
}
111109
}
112110

@@ -119,16 +117,19 @@ public struct MacOS: Platform {
119117

120118
if ctx.mockedHomeDir == nil {
121119
await ctx.print("Extracting the swiftly package...")
122-
try runProgram("installer", "-pkg", "\(archive)", "-target", "CurrentUserHomeDirectory")
123-
try? runProgram("pkgutil", "--volume", "\(userHomeDir)", "--forget", "org.swift.swiftly")
120+
try await sys.installer(
121+
pkg: archive,
122+
target: "CurrentUserHomeDirectory"
123+
)
124+
try? await sys.pkgutil(.volume(userHomeDir)).forget(packageId: "org.swift.swiftly").run(self)
124125
} else {
125126
let installDir = userHomeDir / ".swiftly"
126127
try await fs.mkdir(.parents, atPath: installDir)
127128

128129
// In the case of a mock for testing purposes we won't use the installer, perferring a manual process because
129130
// the installer will not install to an arbitrary path, only a volume or user home directory.
130131
let tmpDir = fs.mktemp()
131-
try runProgram("pkgutil", "--expand", "\(archive)", "\(tmpDir)")
132+
try await sys.pkgutil().expand(pkgPath: archive, dirPath: tmpDir).run(self)
132133

133134
// There's a slight difference in the location of the special Payload file between official swift packages
134135
// and the ones that are mocked here in the test framework.
@@ -138,7 +139,7 @@ public struct MacOS: Platform {
138139
}
139140

140141
await ctx.print("Extracting the swiftly package into \(installDir)...")
141-
try runProgram("tar", "-C", "\(installDir)", "-xvf", "\(payload)", quiet: false)
142+
try await sys.tar(.directory(installDir)).extract(.verbose, .archive(payload)).run(self, quiet: false)
142143
}
143144

144145
try self.runProgram((userHomeDir / ".swiftly/bin/swiftly").string, "init")
@@ -161,9 +162,7 @@ public struct MacOS: Platform {
161162

162163
try await fs.remove(atPath: toolchainDir)
163164

164-
try? runProgram(
165-
"pkgutil", "--volume", "\(fs.home)", "--forget", pkgInfo.CFBundleIdentifier, quiet: !verbose
166-
)
165+
try? await sys.pkgutil(.volume(fs.home)).forget(packageId: pkgInfo.CFBundleIdentifier).run(self, quiet: !verbose)
167166
}
168167

169168
public func getExecutableName() -> String {

Sources/Swiftly/Init.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,7 @@ struct Init: SwiftlyCommand {
297297
}
298298

299299
if let postInstall {
300-
await ctx.print("""
301-
There are some dependencies that should be installed before using this toolchain.
302-
You can run the following script as the system administrator (e.g. root) to prepare
303-
your system:
304-
305-
\(postInstall)
306-
307-
""")
300+
await ctx.print(Messages.postInstall(postInstall))
308301
}
309302
}
310303
}

0 commit comments

Comments
 (0)