Skip to content

Commit 50e12f3

Browse files
committed
[CI] Adopt GitHub actions
# Motivation We want to switch our CI to GitHub actions. # Modification This PR sets up the reusable workflows from NIO. # Result More modern CI.
1 parent 24c800f commit 50e12f3

26 files changed

+392
-485
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
11+
[*.yml]
12+
indent_style = space
13+
indent_size = 2

.github/release.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
changelog:
2+
categories:
3+
- title: SemVer Major
4+
labels:
5+
- ⚠️ semver/major
6+
- title: SemVer Minor
7+
labels:
8+
- semver/minor
9+
- title: SemVer Patch
10+
labels:
11+
- semver/patch
12+
- title: Other Changes
13+
labels:
14+
- semver/none

.github/workflows/main.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
unit-tests:
9+
name: Unit tests
10+
uses: ./.github/workflows/unit_tests.yml
11+
with:
12+
linux_5_8_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
13+
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
14+
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
15+
linux_nightly_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
16+
linux_nightly_main_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
17+
18+
benchmarks:
19+
name: Benchmarks
20+
uses: ./.github/workflows/benchmarks.yml
21+
with:
22+
benchmark_package_path: "Benchmarks"
23+
24+
cxx-interop:
25+
name: Cxx interop
26+
uses: ./.github/workflows/cxx_interop.yml

.github/workflows/pull_request.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
soundness:
9+
name: Soundness
10+
uses: apple/swift-nio/.github/workflows/soundness.yml@main
11+
with:
12+
license_header_check_project_name: "SwiftCertificates"
13+
14+
unit-tests:
15+
name: Unit tests
16+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
17+
with:
18+
linux_5_8_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
19+
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
20+
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
21+
linux_nightly_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
22+
linux_nightly_main_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
23+
24+
swift-6-language-mode:
25+
name: Swift 6 Language Mode
26+
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: PR label
2+
3+
on:
4+
pull_request:
5+
types: [labeled, unlabeled, opened, reopened, synchronize]
6+
7+
jobs:
8+
semver-label-check:
9+
name: Semantic Version label check
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 1
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
persist-credentials: false
17+
- name: Check for Semantic Version label
18+
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main

.github/workflows/scheduled.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Scheduled
2+
3+
on:
4+
schedule:
5+
- cron: "0 8,20 * * *"
6+
7+
jobs:
8+
unit-tests:
9+
name: Unit tests
10+
uses: ./.github/workflows/unit_tests.yml
11+
with:
12+
linux_5_8_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
13+
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
14+
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
15+
linux_nightly_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
16+
linux_nightly_main_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
17+
18+
benchmarks:
19+
name: Benchmarks
20+
uses: ./.github/workflows/benchmarks.yml
21+
with:
22+
benchmark_package_path: "Benchmarks"

.licenseignore

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.gitignore
2+
**/.gitignore
3+
.licenseignore
4+
.gitattributes
5+
.git-blame-ignore-revs
6+
.mailfilter
7+
.mailmap
8+
.spi.yml
9+
.swift-format
10+
.editorconfig
11+
.github/*
12+
*.md
13+
*.txt
14+
*.yml
15+
*.yaml
16+
*.json
17+
Package.swift
18+
**/Package.swift
19+
Package@-*.swift
20+
**/Package@-*.swift
21+
Package.resolved
22+
**/Package.resolved
23+
Makefile
24+
*.modulemap
25+
**/*.modulemap
26+
**/*.docc/*
27+
*.xcprivacy
28+
**/*.xcprivacy
29+
*.symlink
30+
**/*.symlink
31+
Dockerfile
32+
**/Dockerfile
33+
Snippets/*
34+
dev/git.commit.template
35+
dev/update-benchmark-thresholds
36+
*.crt
37+
**/*.crt
38+
*.pem
39+
**/*.pem
40+
*.der
41+
**/*.der
42+
Tests/X509Tests/CSR Vectors/cryptography/LICENSE.APACHE

.swift-format

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"fileScopedDeclarationPrivacy" : {
3+
"accessLevel" : "private"
4+
},
5+
"indentation" : {
6+
"spaces" : 4
7+
},
8+
"indentConditionalCompilationBlocks" : false,
9+
"indentSwitchCaseLabels" : false,
10+
"lineBreakAroundMultilineExpressionChainComponents" : false,
11+
"lineBreakBeforeControlFlowKeywords" : false,
12+
"lineBreakBeforeEachArgument" : true,
13+
"lineBreakBeforeEachGenericRequirement" : true,
14+
"lineLength" : 120,
15+
"maximumBlankLines" : 1,
16+
"prioritizeKeepingFunctionOutputTogether" : true,
17+
"respectsExistingLineBreaks" : true,
18+
"rules" : {
19+
"AllPublicDeclarationsHaveDocumentation" : false,
20+
"AlwaysUseLowerCamelCase" : false,
21+
"AmbiguousTrailingClosureOverload" : true,
22+
"BeginDocumentationCommentWithOneLineSummary" : false,
23+
"DoNotUseSemicolons" : true,
24+
"DontRepeatTypeInStaticProperties" : true,
25+
"FileScopedDeclarationPrivacy" : true,
26+
"FullyIndirectEnum" : true,
27+
"GroupNumericLiterals" : true,
28+
"IdentifiersMustBeASCII" : true,
29+
"NeverForceUnwrap" : false,
30+
"NeverUseForceTry" : false,
31+
"NeverUseImplicitlyUnwrappedOptionals" : false,
32+
"NoAccessLevelOnExtensionDeclaration" : true,
33+
"NoAssignmentInExpressions" : true,
34+
"NoBlockComments" : true,
35+
"NoCasesWithOnlyFallthrough" : true,
36+
"NoEmptyTrailingClosureParentheses" : true,
37+
"NoLabelsInCasePatterns" : false,
38+
"NoLeadingUnderscores" : false,
39+
"NoParensAroundConditions" : true,
40+
"NoVoidReturnOnFunctionSignature" : true,
41+
"OneCasePerLine" : true,
42+
"OneVariableDeclarationPerLine" : true,
43+
"OnlyOneTrailingClosureArgument" : true,
44+
"OrderedImports" : false,
45+
"ReturnVoidInsteadOfEmptyTuple" : true,
46+
"UseEarlyExits" : true,
47+
"UseLetInEveryBoundCaseVariable" : false,
48+
"UseShorthandTypeNames" : true,
49+
"UseSingleLinePropertyGetter" : false,
50+
"UseSynthesizedInitializer" : false,
51+
"UseTripleSlashForDocumentationComments" : true,
52+
"UseWhereClausesInForLoops" : false,
53+
"ValidateDocumentationComments" : false
54+
},
55+
"spacesAroundRangeFormationOperators" : false,
56+
"tabWidth" : 4,
57+
"version" : 1
58+
}

.swiftformat

-27
This file was deleted.

Package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ let package = Package(
5656
.target(
5757
name: "ServiceLifecycleTestKit",
5858
dependencies: [
59-
.target(name: "ServiceLifecycle"),
59+
.target(name: "ServiceLifecycle")
6060
]
6161
),
6262
.target(
6363
name: "UnixSignals",
6464
dependencies: [
65-
.target(name: "ConcurrencyHelpers"),
65+
.target(name: "ConcurrencyHelpers")
6666
]
6767
),
6868
.target(
@@ -78,7 +78,7 @@ let package = Package(
7878
.testTarget(
7979
name: "UnixSignalsTests",
8080
dependencies: [
81-
.target(name: "UnixSignals"),
81+
.target(name: "UnixSignals")
8282
]
8383
),
8484
]

Sources/ServiceLifecycle/AsyncCancelOnGracefulShutdownSequence.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ extension AsyncSequence where Self: Sendable, Element: Sendable {
2424
}
2525

2626
/// An asynchronous sequence that is cancelled once graceful shutdown has triggered.
27-
public struct AsyncCancelOnGracefulShutdownSequence<Base: AsyncSequence & Sendable>: AsyncSequence, Sendable where Base.Element: Sendable {
27+
public struct AsyncCancelOnGracefulShutdownSequence<Base: AsyncSequence & Sendable>: AsyncSequence, Sendable
28+
where Base.Element: Sendable {
2829
@usableFromInline
2930
enum _ElementOrGracefulShutdown: Sendable {
3031
case base(AsyncMapNilSequence<Base>.Element)

Sources/ServiceLifecycle/GracefulShutdown.swift

+10-7
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ enum ValueOrGracefulShutdown<T: Sendable>: Sendable {
115115
/// Cancels the closure when a graceful shutdown was triggered.
116116
///
117117
/// - Parameter operation: The actual operation.
118-
public func cancelWhenGracefulShutdown<T: Sendable>(_ operation: @Sendable @escaping () async throws -> T) async rethrows -> T {
118+
public func cancelWhenGracefulShutdown<T: Sendable>(
119+
_ operation: @Sendable @escaping () async throws -> T
120+
) async rethrows -> T {
119121
return try await withThrowingTaskGroup(of: ValueOrGracefulShutdown<T>.self) { group in
120122
group.addTask {
121123
let value = try await operation()
@@ -163,7 +165,9 @@ public func cancelWhenGracefulShutdown<T: Sendable>(_ operation: @Sendable @esca
163165
// renamed pattern has been shown to cause compiler crashes in 5.x compilers.
164166
@available(*, deprecated, message: "renamed to cancelWhenGracefulShutdown")
165167
#endif
166-
public func cancelOnGracefulShutdown<T: Sendable>(_ operation: @Sendable @escaping () async throws -> T) async rethrows -> T? {
168+
public func cancelOnGracefulShutdown<T: Sendable>(
169+
_ operation: @Sendable @escaping () async throws -> T
170+
) async rethrows -> T? {
167171
return try await cancelWhenGracefulShutdown(operation)
168172
}
169173

@@ -218,11 +222,7 @@ public final class GracefulShutdownManager: @unchecked Sendable {
218222

219223
func registerHandler(_ handler: @Sendable @escaping () -> Void) -> UInt64? {
220224
return self.state.withLockedValue { state in
221-
if state.isShuttingDown {
222-
// We are already shutting down so we just run the handler now.
223-
handler()
224-
return nil
225-
} else {
225+
guard state.isShuttingDown else {
226226
defer {
227227
state.handlerCounter += 1
228228
}
@@ -231,6 +231,9 @@ public final class GracefulShutdownManager: @unchecked Sendable {
231231

232232
return handlerID
233233
}
234+
// We are already shutting down so we just run the handler now.
235+
handler()
236+
return nil
234237
}
235238
}
236239

0 commit comments

Comments
 (0)