Skip to content

Commit 312f5d4

Browse files
committed
Adopt github actions
1 parent 005194a commit 312f5d4

Some content is hidden

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

48 files changed

+1537
-823
lines changed

.github/workflows/pull_request.yml

+4
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ jobs:
2727
matrix_windows_6_0_enabled: false
2828
matrix_windows_nightly_6_0_enabled: false
2929
matrix_windows_nightly_main_enabled: false
30+
31+
integration-tests:
32+
name: Integration tests
33+
run:

.swift-format

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
},
2929
"rules" : {
3030
"NoBlockComments" : false,
31-
"EndOfLineComment" : false,
3231
"ReplaceForEachWithForLoop" : false,
3332

3433
"AllPublicDeclarationsHaveDocumentation" : false,
@@ -71,4 +70,4 @@
7170
"UseWhereClausesInForLoops" : false,
7271
"ValidateDocumentationComments" : false
7372
}
74-
}
73+
}

.swiftformat

-20
This file was deleted.

IntegrationTests/tests_01_cluster/it_Clustered_swim_suspension_reachability/main.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
import SWIM
1616

17-
// TODO: implement me
17+
// TODO: implement me

Package.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
// swift-tools-version:5.7
1+
// swift-tools-version:5.9
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.
1011
let globalSwiftSettings: [SwiftSetting]
1112
if ProcessInfo.processInfo.environment["WARNINGS_AS_ERRORS"] != nil {
1213
print("WARNINGS_AS_ERRORS enabled, passing `-warnings-as-errors`")
1314
globalSwiftSettings = [
14-
SwiftSetting.unsafeFlags(["-warnings-as-errors"]),
15+
SwiftSetting.unsafeFlags(["-warnings-as-errors"])
1516
]
1617
} else {
1718
globalSwiftSettings = []
@@ -23,8 +24,7 @@ var targets: [PackageDescription.Target] = [
2324

2425
.target(
2526
name: "ClusterMembership",
26-
dependencies: [
27-
]
27+
dependencies: []
2828
),
2929

3030
.target(
@@ -59,7 +59,7 @@ var targets: [PackageDescription.Target] = [
5959
.testTarget(
6060
name: "ClusterMembershipDocumentationTests",
6161
dependencies: [
62-
"SWIM",
62+
"SWIM"
6363
]
6464
),
6565

@@ -69,7 +69,7 @@ var targets: [PackageDescription.Target] = [
6969
.testTarget(
7070
name: "ClusterMembershipTests",
7171
dependencies: [
72-
"ClusterMembership",
72+
"ClusterMembership"
7373
]
7474
),
7575

@@ -106,7 +106,7 @@ var targets: [PackageDescription.Target] = [
106106
.executableTarget(
107107
name: "it_Clustered_swim_suspension_reachability",
108108
dependencies: [
109-
"SWIM",
109+
"SWIM"
110110
],
111111
path: "IntegrationTests/tests_01_cluster/it_Clustered_swim_suspension_reachability"
112112
),
@@ -123,7 +123,7 @@ var dependencies: [Package.Dependency] = [
123123

124124
// ~~~ SSWG APIs ~~~
125125
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
126-
.package(url: "https://github.com/apple/swift-metrics.git", "2.3.2" ..< "3.0.0"), // since latest
126+
.package(url: "https://github.com/apple/swift-metrics.git", "2.3.2"..<"3.0.0"), // since latest
127127

128128
// ~~~ SwiftPM Plugins ~~~
129129
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),

Samples/Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var targets: [PackageDescription.Target] = [
2222
.testTarget(
2323
name: "NoopTests",
2424
dependencies: [
25-
"SWIM",
25+
"SWIM"
2626
],
2727
path: "Tests/NoopTests"
2828
),
@@ -48,7 +48,7 @@ let package = Package(
4848
.executable(
4949
name: "SWIMNIOSampleCluster",
5050
targets: ["SWIMNIOSampleCluster"]
51-
),
51+
)
5252

5353
],
5454

Samples/Sources/SWIMNIOSampleCluster/SWIMNIOSampleNode.swift

+10-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import ClusterMembership
16+
import Logging
17+
import NIO
1618
import SWIM
1719
import SWIMNIOExample
18-
import NIO
19-
import Logging
2020

2121
struct SampleSWIMNIONode {
2222
let port: Int
@@ -63,10 +63,13 @@ final class SWIMNIOSampleHandler: ChannelInboundHandler {
6363
let change: SWIM.MemberStatusChangedEvent = self.unwrapInboundIn(data)
6464

6565
// we log each event (in a pretty way)
66-
self.log.info("Membership status changed: [\(change.member.node)] is now [\(change.status)]", metadata: [
67-
"swim/member": "\(change.member.node)",
68-
"swim/member/previousStatus": "\(change.previousStatus.map({"\($0)"}) ?? "unknown")",
69-
"swim/member/status": "\(change.status)",
70-
])
66+
self.log.info(
67+
"Membership status changed: [\(change.member.node)] is now [\(change.status)]",
68+
metadata: [
69+
"swim/member": "\(change.member.node)",
70+
"swim/member/previousStatus": "\(change.previousStatus.map({"\($0)"}) ?? "unknown")",
71+
"swim/member/status": "\(change.status)",
72+
]
73+
)
7174
}
7275
}

Samples/Sources/SWIMNIOSampleCluster/main.swift

+19-19
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
import ArgumentParser
1516
import ClusterMembership
16-
import SWIM
17+
import Lifecycle
18+
import Logging
1719
import Metrics
20+
import NIO
1821
import Prometheus
22+
import SWIM
1923
import SWIMNIOExample
20-
import NIO
21-
import Logging
22-
import Lifecycle
23-
import ArgumentParser
2424

2525
struct SWIMNIOSampleCluster: ParsableCommand {
2626
@Option(name: .shortAndLong, help: "The number of nodes to start, defaults to: 1")
2727
var count: Int?
2828

2929
@Argument(help: "Hostname that node(s) should bind to")
3030
var host: String?
31-
31+
3232
@Option(help: "Determines which this node should bind to; Only effective when running a single node")
3333
var port: Int?
3434

@@ -47,17 +47,17 @@ struct SWIMNIOSampleCluster: ParsableCommand {
4747
//
4848
// Note though that this will be a bit noisy, since logs are also emitted to the stdout by default, however it's a nice way
4949
// to learn and explore what the metrics are and how they behave when toying around with a local cluster.
50-
// let prom = PrometheusClient()
51-
// MetricsSystem.bootstrap(prom)
52-
//
53-
// group.next().scheduleRepeatedTask(initialDelay: .seconds(1), delay: .seconds(10)) { _ in
54-
// prom.collect { (string: String) in
55-
// print("")
56-
// print("")
57-
// print(string)
58-
// }
59-
// }
60-
50+
// let prom = PrometheusClient()
51+
// MetricsSystem.bootstrap(prom)
52+
//
53+
// group.next().scheduleRepeatedTask(initialDelay: .seconds(1), delay: .seconds(10)) { _ in
54+
// prom.collect { (string: String) in
55+
// print("")
56+
// print("")
57+
// print(string)
58+
// }
59+
// }
60+
6161
let lifecycle = ServiceLifecycle()
6262
lifecycle.registerShutdown(
6363
label: "eventLoopGroup",
@@ -101,7 +101,7 @@ struct SWIMNIOSampleCluster: ParsableCommand {
101101
)
102102
}
103103
}
104-
104+
105105
try lifecycle.startAndWait()
106106
}
107107

@@ -116,7 +116,7 @@ struct SWIMNIOSampleCluster: ParsableCommand {
116116
guard self.initialContactPoints.trimmingCharacters(in: .whitespacesAndNewlines) != "" else {
117117
return []
118118
}
119-
119+
120120
let contactPoints: [Node] = self.initialContactPoints.split(separator: ",").map { hostPort in
121121
let host = String(hostPort.split(separator: ":")[0])
122122
let port = Int(String(hostPort.split(separator: ":")[1]))!

Samples/Tests/LinuxMain.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import XCTest
2525

2626
XCTMain(
2727
[
28-
testCase(SampleTest.allTests),
28+
testCase(SampleTest.allTests)
2929
]
3030
)
3131
#endif

Sources/SWIM/Events.swift

+13-8
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,24 @@ extension SWIM {
3838
/// Create new event, representing a change of the member's status from a previous state to its current state.
3939
public init(previousStatus: SWIM.Status?, member: SWIM.Member<Peer>) {
4040
if let from = previousStatus, from == .dead {
41-
precondition(member.status == .dead, "Change MUST NOT move status 'backwards' from [.dead] state to anything else, but did so, was: \(member)")
41+
precondition(
42+
member.status == .dead,
43+
"Change MUST NOT move status 'backwards' from [.dead] state to anything else, but did so, was: \(member)"
44+
)
4245
}
4346

4447
self.previousStatus = previousStatus
4548
self.member = member
4649

4750
switch (self.previousStatus, member.status) {
4851
case (.dead, .alive),
49-
(.dead, .suspect),
50-
(.dead, .unreachable):
51-
fatalError("SWIM.Membership MUST NOT move status 'backwards' from .dead state to anything else, but did so, was: \(self)")
52+
(.dead, .suspect),
53+
(.dead, .unreachable):
54+
fatalError(
55+
"SWIM.Membership MUST NOT move status 'backwards' from .dead state to anything else, but did so, was: \(self)"
56+
)
5257
default:
53-
() // ok, all other transitions are valid.
58+
() // ok, all other transitions are valid.
5459
}
5560
}
5661
}
@@ -73,13 +78,13 @@ extension SWIM.MemberStatusChangedEvent {
7378
// alive and suspect does NOT affect high-level reachability).
7479
switch (fromStatus, self.status) {
7580
case (.alive, .unreachable),
76-
(.alive, .dead):
81+
(.alive, .dead):
7782
return true
7883
case (.suspect, .unreachable),
79-
(.suspect, .dead):
84+
(.suspect, .dead):
8085
return true
8186
case (.unreachable, .alive),
82-
(.unreachable, .suspect):
87+
(.unreachable, .suspect):
8388
return true
8489
default:
8590
return false

Sources/SWIM/Member.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import ClusterMembership
16+
1617
@preconcurrency import struct Dispatch.DispatchTime
1718

1819
// ==== ----------------------------------------------------------------------------------------------------------------
@@ -43,7 +44,7 @@ extension SWIM {
4344
///
4445
/// - Note: Only suspect members may have this value set, but having the actual field in SWIM.Member feels more natural.
4546
/// - Note: This value is never carried across processes, as it serves only locally triggering suspicion timeouts.
46-
public let localSuspicionStartedAt: DispatchTime? // could be "status updated at"?
47+
public let localSuspicionStartedAt: DispatchTime? // could be "status updated at"?
4748

4849
/// Create a new member.
4950
public init(peer: Peer, status: SWIM.Status, protocolPeriod: UInt64, suspicionStartedAt: DispatchTime? = nil) {
@@ -86,9 +87,7 @@ extension SWIM {
8687
/// Manual Hashable conformance since we omit `suspicionStartedAt` from identity
8788
extension SWIM.Member: Hashable, Equatable {
8889
public static func == (lhs: SWIM.Member<Peer>, rhs: SWIM.Member<Peer>) -> Bool {
89-
lhs.peer.node == rhs.peer.node &&
90-
lhs.protocolPeriod == rhs.protocolPeriod &&
91-
lhs.status == rhs.status
90+
lhs.peer.node == rhs.peer.node && lhs.protocolPeriod == rhs.protocolPeriod && lhs.status == rhs.status
9291
}
9392

9493
public func hash(into hasher: inout Hasher) {

Sources/SWIM/Metrics.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,26 @@ extension SWIM {
110110
self.messageInboundCount = Counter(
111111
label: settings.metrics.makeLabel("message", "count"),
112112
dimensions: [
113-
("direction", "in"),
113+
("direction", "in")
114114
]
115115
)
116116
self.messageInboundBytes = Recorder(
117117
label: settings.metrics.makeLabel("message", "bytes"),
118118
dimensions: [
119-
("direction", "in"),
119+
("direction", "in")
120120
]
121121
)
122122

123123
self.messageOutboundCount = Counter(
124124
label: settings.metrics.makeLabel("message", "count"),
125125
dimensions: [
126-
("direction", "out"),
126+
("direction", "out")
127127
]
128128
)
129129
self.messageOutboundBytes = Recorder(
130130
label: settings.metrics.makeLabel("message", "bytes"),
131131
dimensions: [
132-
("direction", "out"),
132+
("direction", "out")
133133
]
134134
)
135135
}
@@ -200,7 +200,7 @@ extension SWIM.Metrics {
200200
case .unreachable:
201201
unreachables += 1
202202
case .dead:
203-
() // dead is reported as a removal when they're removed and tombstoned, not as a gauge
203+
() // dead is reported as a removal when they're removed and tombstoned, not as a gauge
204204
}
205205
}
206206
self.membersAlive.record(alives)

0 commit comments

Comments
 (0)