Skip to content

Commit 4c650a7

Browse files
authored
Use swift CI (#130)
* Use swift CI Signed-off-by: Adam Fowler <[email protected]> * Fix license header Signed-off-by: Adam Fowler <[email protected]> * Disable builds we don't want Signed-off-by: Adam Fowler <[email protected]> * Fixup shellcheck issues in scripts Signed-off-by: Adam Fowler <[email protected]> * Fix YAML Signed-off-by: Adam Fowler <[email protected]> * Fix more soundness issues Signed-off-by: Adam Fowler <[email protected]> * Resurrect old unit-tests Signed-off-by: Adam Fowler <[email protected]> * Fix swift-format, disable unacceptable language, fix shellcheck issue Signed-off-by: Adam Fowler <[email protected]> * Fix YAML comment issue Signed-off-by: Adam Fowler <[email protected]> * Use swift:latest for api-breakage Signed-off-by: Adam Fowler <[email protected]> * Disable benchmarks for api-breakage test, disable format and license header tests Signed-off-by: Adam Fowler <[email protected]> * Reverse DISABLE_VALKEY_BENCHMARKS to ENABLE_VALKEY_BENCHMARKS Signed-off-by: Adam Fowler <[email protected]> * Split soundness into its own action Signed-off-by: Adam Fowler <[email protected]> --------- Signed-off-by: Adam Fowler <[email protected]>
1 parent c3b126c commit 4c650a7

14 files changed

+157
-84
lines changed

.github/workflows/benchmark.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ on:
66
branches:
77
- main
88
paths:
9-
- '**.swift'
10-
- '**.yml'
9+
- '**.swift'
10+
- '**.yml'
1111

1212
concurrency:
1313
group: ${{ github.workflow }}-${{ github.ref }}-benchmark
1414
cancel-in-progress: true
15-
15+
16+
env:
17+
ENABLE_VALKEY_BENCHMARKS: true
18+
1619
jobs:
1720
benchmark-delta:
18-
1921
runs-on: ${{ matrix.os }}
2022
timeout-minutes: 15
2123
continue-on-error: true
@@ -28,10 +30,10 @@ jobs:
2830
matrix:
2931
os: [ubuntu-latest]
3032
image: ["swift:6.1"]
31-
33+
3234
container:
3335
image: ${{ matrix.image }}
34-
36+
3537
steps:
3638
- uses: actions/checkout@v4
3739
with:
@@ -45,7 +47,7 @@ jobs:
4547
# https://github.com/actions/checkout/issues/766
4648
- name: Mark the workspace as safe
4749
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
48-
50+
4951
- name: Miscellaneous
5052
run: |
5153
[ -d Benchmarks ] && echo "hasBenchmark=1" >> $GITHUB_ENV
@@ -56,7 +58,7 @@ jobs:
5658
swift package --allow-writing-to-directory .benchmarkBaselines/ benchmark baseline update pull_request
5759
- name: Checkout main
5860
run: |
59-
git checkout main
61+
git checkout main
6062
- name: Run benchmarks for branch 'main'
6163
if: ${{ env.hasBenchmark == '1' }}
6264
run: |
@@ -67,7 +69,7 @@ jobs:
6769
run: |
6870
set +e
6971
# if we had access to fd 3 we could do this in one call eg { var=$(cmd 3>&2 2>&1 1>&3); } 2>&1
70-
# but unfortunately we don't so we have to run the baseline check twice once to extract stdout
72+
# but unfortunately we don't so we have to run the baseline check twice once to extract stdout
7173
# and once to extract stderr
7274
BENCHMARK_STDERR=$(swift package benchmark baseline check main pull_request 2>&1)
7375
echo "exit-status=$?" >> $GITHUB_OUTPUT

.github/workflows/ci.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches:
6-
- main
7-
paths:
8-
- "**.swift"
9-
- "**.yml"
5+
branches: [main]
106
pull_request:
117
workflow_dispatch:
128
concurrency:
@@ -16,12 +12,12 @@ concurrency:
1612
env:
1713
VALKEY_HOSTNAME: valkey
1814
jobs:
19-
linux:
15+
unit-tests:
2016
runs-on: ubuntu-latest
2117
timeout-minutes: 15
2218
strategy:
2319
matrix:
24-
image: ["swift:6.1"]
20+
image: ["swift:6.1", "swiftlang/swift:nightly-6.2-noble"]
2521
container:
2622
image: ${{ matrix.image }}
2723
services:

.github/workflows/soundness.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Soundness
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
jobs:
8+
soundness:
9+
name: Soundness
10+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
11+
with:
12+
api_breakage_check_container_image: swift:latest
13+
unacceptable_language_check_enabled: false # Valkey commands contain unacceptable language
14+
license_header_check_enabled: false # Temporarily disable
15+
format_check_enabled: false # Temporarily disable

.license_header_template

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@@===----------------------------------------------------------------------===@@
2+
@@
3+
@@ This source file is part of the valkey-swift open source project
4+
@@
5+
@@ Copyright (c) YEARS the valkey-swift authors
6+
@@ Licensed under Apache License v2.0
7+
@@
8+
@@ See LICENSE.txt for license information
9+
@@ See CONTRIBUTORS.txt for the list of valkey-swift project authors
10+
@@
11+
@@ SPDX-License-Identifier: Apache-2.0
12+
@@
13+
@@===----------------------------------------------------------------------===@@

.licenseignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.gitignore
2+
**/.gitignore
3+
.licenseignore
4+
.gitattributes
5+
.git-blame-ignore-revs
6+
.mailfilter
7+
.mailmap
8+
.spi.yml
9+
.swift-format
10+
.swiftformatignore
11+
.editorconfig
12+
.github/*
13+
*.md
14+
*.txt
15+
*.yml
16+
*.yaml
17+
*.json
18+
Package.swift
19+
**/Package.swift
20+
Package@-*.swift
21+
**/Package@-*.swift
22+
Package.resolved
23+
**/Package.resolved
24+
Makefile
25+
*.modulemap
26+
**/*.modulemap
27+
**/*.docc/*
28+
*.xcprivacy
29+
**/*.xcprivacy
30+
*.symlink
31+
**/*.symlink
32+
Dockerfile
33+
**/Dockerfile
34+
Snippets/*
35+
dev/git.commit.template
36+
.unacceptablelanguageignore

.swift-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"NeverUseImplicitlyUnwrappedOptionals" : false,
3737
"NoAccessLevelOnExtensionDeclaration" : true,
3838
"NoAssignmentInExpressions" : true,
39-
"NoBlockComments" : true,
39+
"NoBlockComments" : false,
4040
"NoCasesWithOnlyFallthrough" : true,
4141
"NoEmptyTrailingClosureParentheses" : true,
4242
"NoLabelsInCasePatterns" : true,

Package.swift

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// swift-tools-version: 6.1
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

4+
import Foundation
45
import PackageDescription
56

67
let defaultSwiftSettings: [SwiftSetting] =
@@ -29,8 +30,6 @@ let package = Package(
2930
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.29.0"),
3031
.package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.23.0"),
3132
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.8.0"),
32-
33-
.package(url: "https://github.com/ordo-one/package-benchmark", from: "1.0.0"),
3433
],
3534
targets: [
3635
.target(
@@ -72,21 +71,6 @@ let package = Package(
7271
resources: [.process("Resources")],
7372
swiftSettings: defaultSwiftSettings
7473
),
75-
.executableTarget(
76-
name: "ValkeyBenchmarks",
77-
dependencies: [
78-
"Valkey",
79-
.product(name: "Benchmark", package: "package-benchmark"),
80-
.product(name: "Logging", package: "swift-log"),
81-
.product(name: "NIOCore", package: "swift-nio"),
82-
.product(name: "NIOPosix", package: "swift-nio"),
83-
],
84-
path: "Benchmarks/ValkeyBenchmarks",
85-
swiftSettings: defaultSwiftSettings,
86-
plugins: [
87-
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
88-
]
89-
),
9074
.testTarget(
9175
name: "IntegrationTests",
9276
dependencies: [
@@ -113,3 +97,26 @@ let package = Package(
11397
),
11498
]
11599
)
100+
101+
if ProcessInfo.processInfo.environment["ENABLE_VALKEY_BENCHMARKS"] != nil {
102+
package.dependencies.append(
103+
.package(url: "https://github.com/ordo-one/package-benchmark", from: "1.0.0"),
104+
)
105+
package.targets.append(
106+
.executableTarget(
107+
name: "ValkeyBenchmarks",
108+
dependencies: [
109+
"Valkey",
110+
.product(name: "Benchmark", package: "package-benchmark"),
111+
.product(name: "Logging", package: "swift-log"),
112+
.product(name: "NIOCore", package: "swift-nio"),
113+
.product(name: "NIOPosix", package: "swift-nio"),
114+
],
115+
path: "Benchmarks/ValkeyBenchmarks",
116+
swiftSettings: defaultSwiftSettings,
117+
plugins: [
118+
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
119+
]
120+
)
121+
)
122+
}

Sources/Valkey/Cluster/ValkeyClusterClientStateMachine.swift

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,16 @@ package struct ValkeyClusterClientStateMachine<
338338
useCase: .circuitBreaker,
339339
duration: self.configuration.circuitBreakerDuration
340340
)
341-
self.clusterState = .degraded(.init(
342-
start: self.clock.now,
343-
pendingSuccessNotifiers: [:],
344-
circuitBreakerTimer: .init(id: circuitBreakerTimerID),
345-
hashSlotShardMap: healthyContext.hashSlotShardMap,
346-
lastHealthyState: healthyContext.clusterDescription,
347-
lastError: error
348-
))
341+
self.clusterState = .degraded(
342+
.init(
343+
start: self.clock.now,
344+
pendingSuccessNotifiers: [:],
345+
circuitBreakerTimer: .init(id: circuitBreakerTimerID),
346+
hashSlotShardMap: healthyContext.hashSlotShardMap,
347+
lastHealthyState: healthyContext.clusterDescription,
348+
lastError: error
349+
)
350+
)
349351
failedAction = ClusterDiscoveryFailedAction(
350352
circuitBreakerTimer: timerTillUnavailable
351353
)
@@ -466,7 +468,7 @@ package struct ValkeyClusterClientStateMachine<
466468
start: degradedContext.start,
467469
pendingSuccessNotifiers: [:],
468470
lastHealthyState: degradedContext.lastHealthyState,
469-
lastError: degradedContext.lastError,
471+
lastError: degradedContext.lastError
470472
)
471473
)
472474
return .init(
@@ -611,14 +613,16 @@ package struct ValkeyClusterClientStateMachine<
611613

612614
let circuitBreakerTimerID = self.nextTimerID()
613615

614-
self.clusterState = .degraded(.init(
615-
start: self.clock.now,
616-
pendingSuccessNotifiers: [:],
617-
circuitBreakerTimer: .init(id: circuitBreakerTimerID),
618-
hashSlotShardMap: healthyContext.hashSlotShardMap,
619-
lastHealthyState: healthyContext.clusterDescription,
620-
lastError: ValkeyClusterError.clusterIsMissingMovedErrorNode
621-
))
616+
self.clusterState = .degraded(
617+
.init(
618+
start: self.clock.now,
619+
pendingSuccessNotifiers: [:],
620+
circuitBreakerTimer: .init(id: circuitBreakerTimerID),
621+
hashSlotShardMap: healthyContext.hashSlotShardMap,
622+
lastHealthyState: healthyContext.clusterDescription,
623+
lastError: ValkeyClusterError.clusterIsMissingMovedErrorNode
624+
)
625+
)
622626

623627
// move into degraded state.
624628
let cancelTimer: TimerCancellationToken?
@@ -630,14 +634,16 @@ package struct ValkeyClusterClientStateMachine<
630634
cancelTimer = context.cancellationToken
631635
}
632636

633-
return .moveToDegraded(.init(
634-
runDiscoveryAndCancelTimer: cancelTimer,
635-
circuitBreakerTimer: .init(
636-
timerID: circuitBreakerTimerID,
637-
useCase: .circuitBreaker,
638-
duration: self.configuration.circuitBreakerDuration
637+
return .moveToDegraded(
638+
.init(
639+
runDiscoveryAndCancelTimer: cancelTimer,
640+
circuitBreakerTimer: .init(
641+
timerID: circuitBreakerTimerID,
642+
useCase: .circuitBreaker,
643+
duration: self.configuration.circuitBreakerDuration
644+
)
639645
)
640-
))
646+
)
641647

642648
case .shutdown:
643649
throw ValkeyClusterError.clusterClientIsShutDown
@@ -675,7 +681,6 @@ package struct ValkeyClusterClientStateMachine<
675681
}
676682
}
677683

678-
679684
package mutating func updateValkeyServiceNodes(
680685
_ description: ValkeyClusterDescription
681686
) -> UpdateValkeyNodesAction {

Sources/Valkey/ValkeyConnectionFactory.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ package final class ValkeyConnectionFactory: Sendable {
115115
commandTimeout: self.configuration.commandTimeout,
116116
blockingCommandTimeout: self.configuration.blockingCommandTimeout,
117117
tls: tls,
118-
clientName: nil,
118+
clientName: nil
119119
)
120120
}
121121
}

Tests/IntegrationTests/ValkeyTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ struct GeneratedCommands {
753753
.hostname(valkeyHostname, port: 6379),
754754
configuration: .init(
755755
commandTimeout: .milliseconds(200),
756-
blockingCommandTimeout: .milliseconds(500),
756+
blockingCommandTimeout: .milliseconds(500)
757757
),
758758
logger: logger
759759
) { connection in

0 commit comments

Comments
 (0)