Skip to content

Commit 49a2702

Browse files
authored
Adopt NIO formatting rules & enable CI (#1178)
1 parent 68a1ec7 commit 49a2702

File tree

266 files changed

+7985
-7153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+7985
-7153
lines changed

.github/workflows/pull_request.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ jobs:
99
name: Soundness
1010
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
1111
with:
12-
format_check_enabled: false
1312
license_header_check_project_name: "Swift Distributed Actors"
1413
# We need to move to 6.0 here but have to fix the new warnings first
1514
docs_check_container_image: "swift:5.10-noble"

InternalPlugins/FishyDocs/Package.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ let package = Package(
1515
.plugin(
1616
name: "FishyDocsPlugin",
1717
targets: [
18-
"FishyDocsPlugin",
18+
"FishyDocsPlugin"
1919
]
20-
),
20+
)
2121
],
2222
dependencies: [
2323
.package(url: "https://github.com/apple/swift-markdown.git", branch: "main"),
@@ -26,10 +26,10 @@ let package = Package(
2626
targets: [
2727
.plugin(
2828
name: "FishyDocsPlugin",
29-
// capability: .command(intent: .custom(verb: "fishy-docs", description: "Extracts source snippets from fishy-docs annotated docc documentation files")),
29+
// capability: .command(intent: .custom(verb: "fishy-docs", description: "Extracts source snippets from fishy-docs annotated docc documentation files")),
3030
capability: .buildTool(),
3131
dependencies: [
32-
"FishyDocs",
32+
"FishyDocs"
3333
]
3434
),
3535
.executableTarget(
@@ -42,7 +42,7 @@ let package = Package(
4242
.testTarget(
4343
name: "FishyDocsTests",
4444
dependencies: [
45-
"FishyDocs",
45+
"FishyDocs"
4646
]
4747
),
4848
]

InternalPlugins/FishyDocs/Sources/FishyDocs/FishyDocsMain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ struct ConcatCodeBlocks: MarkupWalker {
151151

152152
codeBlockStrings.append(s)
153153
}
154-
codeBlockStrings.append("}") // end of __test()
154+
codeBlockStrings.append("}") // end of __test()
155155

156156
return codeBlockStrings.joined(separator: "\n")
157157
}

InternalPlugins/FishyDocs/Tests/FishyDocsTests/FishyDocsTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
// SPDX-License-Identifier: Apache-2.0
1212
//
1313
//===----------------------------------------------------------------------===//
14-
@testable import FishyDocsLib
1514
import XCTest
1615

16+
@testable import FishyDocsLib
17+
1718
final class FishyDocsTests: XCTestCase {
1819
func testExample() throws {}
1920
}

MultiNodeTests/DistributedActorsMultiNodeTests/MultiNode+ClusterSingletonTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ public final class MultiNodeClusterSingletonTests: MultiNodeTestSuite {
5959
TheSingleton(greeting: "Hello-\(actorSystem.name)", actorSystem: actorSystem)
6060
}
6161

62-
try await multiNode.checkPoint("Hosted singleton") // ----------------------------------------------------------
62+
try await multiNode.checkPoint("Hosted singleton") // ----------------------------------------------------------
6363
let reply = try await ref.greet(name: "Hello from \(multiNode.system.name)")
6464
print("[ON: \(multiNode.system.name)] Got reply: \(reply)")
6565

66-
try await multiNode.checkPoint("Got reply from singleton") // --------------------------------------------------
66+
try await multiNode.checkPoint("Got reply from singleton") // --------------------------------------------------
6767
// Since now all nodes have made a message exchange with the singleton, we can exit this process.
6868
// This barrier is important in so that we don't exit the host of the singleton WHILE the others are still getting to talking to it.
6969
}

MultiNodeTests/DistributedActorsMultiNodeTests/MultiNode+MultiNodeConductorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public final class MultiNodeConductorTests: MultiNodeTestSuite {
4545
}
4646

4747
public static func configureActorSystem(settings: inout ClusterSystemSettings) {
48-
// settings.logging.logLevel = .debug
48+
// settings.logging.logLevel = .debug
4949
}
5050

5151
public let testCrashSecondNode = MultiNodeTest(MultiNodeConductorTests.self) { multiNode in

MultiNodeTests/DistributedActorsMultiNodeTests/MultiNode+ReceptionistTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public final class MultiNodeReceptionistTests: MultiNodeTestSuite {
4646
// *All* nodes spawn an echo actor
4747
let localEcho = await DistributedEcho(greeting: "Hi from \(multiNode.system.name), ", actorSystem: multiNode.system)
4848

49-
try await multiNode.checkPoint("Spawned actors") // ------------------------------------------------------------
49+
try await multiNode.checkPoint("Spawned actors") // ------------------------------------------------------------
5050

5151
let expectedCount = Nodes.allCases.count
5252
var discovered: Set<DistributedEcho> = []
@@ -59,7 +59,7 @@ public final class MultiNodeReceptionistTests: MultiNodeTestSuite {
5959
}
6060
}
6161

62-
try await multiNode.checkPoint("All members found \(expectedCount) actors") // ---------------------------------
62+
try await multiNode.checkPoint("All members found \(expectedCount) actors") // ---------------------------------
6363
}
6464

6565
distributed actor DistributedEcho {

Package.swift

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// swift-tools-version:5.10
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

4-
import class Foundation.ProcessInfo
54
import PackageDescription
65

6+
import class Foundation.ProcessInfo
7+
78
// Workaround: Since we cannot include the flat just as command line options since then it applies to all targets,
89
// and ONE of our dependencies currently produces one warning, we have to use this workaround to enable it in _our_
910
// targets when the flag is set. We should remove the dependencies and then enable the flag globally though just by passing it.
@@ -16,7 +17,7 @@ let products: [PackageDescription.Product] = [
1617
.library(
1718
name: "DistributedCluster",
1819
targets: ["DistributedCluster"]
19-
),
20+
)
2021
]
2122

2223
// ==== ----------------------------------------------------------------------------------------------------------------
@@ -30,7 +31,7 @@ var targets: [PackageDescription.Target] = [
3031
name: "DistributedCluster",
3132
dependencies: [
3233
"DistributedActorsConcurrencyHelpers",
33-
"CDistributedActorsMailbox", // TODO(swift): remove mailbox runtime, use Swift actors directly
34+
"CDistributedActorsMailbox", // TODO(swift): remove mailbox runtime, use Swift actors directly
3435
.product(name: "OrderedCollections", package: "swift-collections"),
3536
.product(name: "Atomics", package: "swift-atomics"),
3637
.product(name: "SWIM", package: "swift-cluster-membership"),
@@ -88,7 +89,7 @@ var targets: [PackageDescription.Target] = [
8889
name: "MultiNodeTestPlugin",
8990
capability: .command(
9091
intent: .custom(verb: "multi-node", description: "Run MultiNodeTestKit based tests across multiple processes or physical compute nodes")
91-
/* permissions: needs full network access */
92+
// permissions: needs full network access
9293
),
9394
dependencies: []
9495
),
@@ -122,7 +123,7 @@ var targets: [PackageDescription.Target] = [
122123
.target(
123124
name: "DistributedActorsMultiNodeTests",
124125
dependencies: [
125-
"MultiNodeTestKit",
126+
"MultiNodeTestKit"
126127
],
127128
path: "MultiNodeTests/DistributedActorsMultiNodeTests"
128129
),
@@ -134,7 +135,7 @@ var targets: [PackageDescription.Target] = [
134135
.executableTarget(
135136
name: "it_Clustered_swim_suspension_reachability",
136137
dependencies: [
137-
"DistributedCluster",
138+
"DistributedCluster"
138139
],
139140
path: "IntegrationTests/tests_01_cluster/it_Clustered_swim_suspension_reachability"
140141
),
@@ -155,7 +156,7 @@ var targets: [PackageDescription.Target] = [
155156
name: "DistributedActorsConcurrencyHelpers",
156157
dependencies: [],
157158
exclude: [
158-
"README.md",
159+
"README.md"
159160
]
160161
),
161162
]
@@ -164,7 +165,7 @@ var dependencies: [Package.Dependency] = [
164165
.package(url: "https://github.com/apple/swift-atomics", from: "1.1.0"),
165166

166167
// .package(url: "https://github.com/apple/swift-cluster-membership", from: "0.3.0"),
167-
// .package(name: "swift-cluster-membership", path: "Packages/swift-cluster-membership"), // FIXME: just work in progress
168+
// .package(name: "swift-cluster-membership", path: "Packages/swift-cluster-membership"), // FIXME: just work in progress
168169
.package(url: "https://github.com/apple/swift-cluster-membership", branch: "main"),
169170

170171
.package(url: "https://github.com/apple/swift-nio", from: "2.61.1"),
@@ -184,7 +185,7 @@ var dependencies: [Package.Dependency] = [
184185
// ~~~ Observability ~~~
185186
.package(url: "https://github.com/apple/swift-log", from: "1.0.0"),
186187
// swift-metrics 1.x and 2.x are almost API compatible, so most clients should use
187-
.package(url: "https://github.com/apple/swift-metrics", "1.0.0" ..< "3.0.0"),
188+
.package(url: "https://github.com/apple/swift-metrics", "1.0.0"..<"3.0.0"),
188189
.package(url: "https://github.com/apple/swift-service-discovery", from: "1.3.0"),
189190

190191
// ~~~ SwiftPM Plugins ~~~
@@ -207,13 +208,13 @@ if ProcessInfo.processInfo.environment["VALIDATE_DOCS"] != nil {
207208
.testTarget(
208209
name: "DocsTests",
209210
dependencies: [
210-
"DistributedCluster",
211+
"DistributedCluster"
211212
],
212213
exclude: [
213-
"README.md",
214+
"README.md"
214215
],
215216
plugins: [
216-
.plugin(name: "FishyDocsPlugin", package: "FishyDocsPlugin"),
217+
.plugin(name: "FishyDocsPlugin", package: "FishyDocsPlugin")
217218
]
218219
)
219220
)

Plugins/MultiNodeTestPlugin/plugin.swift

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,20 @@ final class MultiNodeTestPlugin: CommandPlugin {
8787
}
8888

8989
func usage(arguments: [String]) throws -> Never {
90-
throw UsageError(message: """
91-
ILLEGAL INVOCATION: \(arguments)
92-
USAGE:
93-
> swift package --disable-sandbox multi-node [OPTIONS] COMMAND
94-
95-
OPTIONS:
96-
-c release/debug - to build in release or debug mode (default: \(self.buildConfiguration))
97-
98-
COMMAND:
99-
test - run multi-node tests
100-
_exec
101-
""")
90+
throw UsageError(
91+
message: """
92+
ILLEGAL INVOCATION: \(arguments)
93+
USAGE:
94+
> swift package --disable-sandbox multi-node [OPTIONS] COMMAND
95+
96+
OPTIONS:
97+
-c release/debug - to build in release or debug mode (default: \(self.buildConfiguration))
98+
99+
COMMAND:
100+
test - run multi-node tests
101+
_exec
102+
"""
103+
)
102104
}
103105
}
104106

@@ -114,14 +116,14 @@ struct UsageError: Error, CustomStringConvertible {
114116
extension Process {
115117
var binaryPath: String? {
116118
get {
117-
if #available(macOS 10.13, /* Linux */ *) {
119+
if #available(macOS 10.13, *) { // '*' covers Linux
118120
return self.executableURL?.path
119121
} else {
120122
return self.launchPath
121123
}
122124
}
123125
set {
124-
if #available(macOS 10.13, /* Linux */ *) {
126+
if #available(macOS 10.13, *) { // '*' covers Linux
125127
self.executableURL = newValue.map { URL(fileURLWithPath: $0) }
126128
} else {
127129
self.launchPath = newValue

Samples/Package.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import PackageDescription
66
var globalSwiftSettings: [SwiftSetting]
77

88
var globalConcurrencyFlags: [String] = [
9-
"-Xfrontend", "-disable-availability-checking", // TODO(distributed): remove this flag
9+
"-Xfrontend", "-disable-availability-checking", // TODO(distributed): remove this flag
1010
]
1111

1212
globalSwiftSettings = [
13-
SwiftSetting.unsafeFlags(globalConcurrencyFlags),
13+
SwiftSetting.unsafeFlags(globalConcurrencyFlags)
1414
]
1515

1616
var targets: [PackageDescription.Target] = [
@@ -20,7 +20,7 @@ var targets: [PackageDescription.Target] = [
2020
.executableTarget(
2121
name: "SampleDiningPhilosophers",
2222
dependencies: [
23-
.product(name: "DistributedCluster", package: "swift-distributed-actors"),
23+
.product(name: "DistributedCluster", package: "swift-distributed-actors")
2424
],
2525
path: "Sources/SampleDiningPhilosophers",
2626
exclude: [
@@ -29,20 +29,19 @@ var targets: [PackageDescription.Target] = [
2929
]
3030
),
3131

32-
/* --- tests --- */
32+
// --- tests ---
3333

3434
// no-tests placeholder project to not have `swift test` fail on Samples/
3535
.testTarget(
3636
name: "NoopTests",
37-
dependencies: [
38-
],
37+
dependencies: [],
3938
path: "Tests/NoopTests"
4039
),
4140
]
4241

4342
var dependencies: [Package.Dependency] = [
4443
// ~~~~~~~ parent ~~~~~~~
45-
.package(name: "swift-distributed-actors", path: "../"),
44+
.package(name: "swift-distributed-actors", path: "../")
4645

4746
// ~~~~~~~ only for samples ~~~~~~~
4847
]
@@ -57,12 +56,12 @@ let package = Package(
5756
.watchOS(.v9),
5857
],
5958
products: [
60-
/* --- samples --- */
59+
// --- samples ---
6160

6261
.executable(
6362
name: "SampleDiningPhilosophers",
6463
targets: ["SampleDiningPhilosophers"]
65-
),
64+
)
6665
],
6766

6867
dependencies: dependencies,

0 commit comments

Comments
 (0)