Skip to content

Commit

Permalink
[CI] Adopt GitHub actions
Browse files Browse the repository at this point in the history
# Motivation

We want to switch our CI to GitHub actions.

# Modification

This PR sets up the reusable workflows from NIO.

# Result

More modern CI.
  • Loading branch information
FranzBusch committed Sep 17, 2024
1 parent 24c800f commit 1a0f3f5
Show file tree
Hide file tree
Showing 28 changed files with 392 additions and 504 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true


[*.yml]
indent_style = space
indent_size = 2
14 changes: 14 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
changelog:
categories:
- title: SemVer Major
labels:
- ⚠️ semver/major
- title: SemVer Minor
labels:
- semver/minor
- title: SemVer Patch
labels:
- semver/patch
- title: Other Changes
labels:
- semver/none
20 changes: 20 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Main

on:
push:
branches: [main]

jobs:
unit-tests:
name: Unit tests
uses: ./.github/workflows/unit_tests.yml
with:
linux_5_8_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"

cxx-interop:
name: Cxx interop
uses: ./.github/workflows/cxx_interop.yml
26 changes: 26 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PR

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
soundness:
name: Soundness
uses: apple/swift-nio/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "SwiftServiceLifecycle"

unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_8_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"

swift-6-language-mode:
name: Swift 6 Language Mode
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main
18 changes: 18 additions & 0 deletions .github/workflows/pull_request_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR label

on:
pull_request:
types: [labeled, unlabeled, opened, reopened, synchronize]

jobs:
semver-label-check:
name: Semantic Version label check
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check for Semantic Version label
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main
16 changes: 16 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Scheduled

on:
schedule:
- cron: "0 8,20 * * *"

jobs:
unit-tests:
name: Unit tests
uses: ./.github/workflows/unit_tests.yml
with:
linux_5_8_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
39 changes: 39 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.gitignore
**/.gitignore
.licenseignore
.gitattributes
.mailfilter
.mailmap
.spi.yml
.swift-format
.editorconfig
.github/*
*.md
*.txt
*.yml
*.yaml
*.json
Package.swift
**/Package.swift
Package@-*.swift
**/Package@-*.swift
Package.resolved
**/Package.resolved
Makefile
*.modulemap
**/*.modulemap
**/*.docc/*
*.xcprivacy
**/*.xcprivacy
*.symlink
**/*.symlink
Dockerfile
**/Dockerfile
Snippets/*
dev/git.commit.template
*.crt
**/*.crt
*.pem
**/*.pem
*.der
**/*.der
58 changes: 58 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"indentation" : {
"spaces" : 4
},
"indentConditionalCompilationBlocks" : false,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : true,
"lineBreakBeforeEachGenericRequirement" : true,
"lineLength" : 120,
"maximumBlankLines" : 1,
"prioritizeKeepingFunctionOutputTogether" : true,
"respectsExistingLineBreaks" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLowerCamelCase" : false,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : false,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : false,
"ReturnVoidInsteadOfEmptyTuple" : true,
"UseEarlyExits" : true,
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : false,
"UseSynthesizedInitializer" : false,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
},
"spacesAroundRangeFormationOperators" : false,
"tabWidth" : 4,
"version" : 1
}
27 changes: 0 additions & 27 deletions .swiftformat

This file was deleted.

10 changes: 3 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ let package = Package(
url: "https://github.com/apple/swift-log.git",
from: "1.5.2"
),
.package(
url: "https://github.com/apple/swift-docc-plugin",
from: "1.0.0"
),
.package(
url: "https://github.com/apple/swift-async-algorithms.git",
from: "1.0.0"
Expand All @@ -56,13 +52,13 @@ let package = Package(
.target(
name: "ServiceLifecycleTestKit",
dependencies: [
.target(name: "ServiceLifecycle"),
.target(name: "ServiceLifecycle")
]
),
.target(
name: "UnixSignals",
dependencies: [
.target(name: "ConcurrencyHelpers"),
.target(name: "ConcurrencyHelpers")
]
),
.target(
Expand All @@ -78,7 +74,7 @@ let package = Package(
.testTarget(
name: "UnixSignalsTests",
dependencies: [
.target(name: "UnixSignals"),
.target(name: "UnixSignals")
]
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ extension AsyncSequence where Self: Sendable, Element: Sendable {
}

/// An asynchronous sequence that is cancelled once graceful shutdown has triggered.
public struct AsyncCancelOnGracefulShutdownSequence<Base: AsyncSequence & Sendable>: AsyncSequence, Sendable where Base.Element: Sendable {
public struct AsyncCancelOnGracefulShutdownSequence<Base: AsyncSequence & Sendable>: AsyncSequence, Sendable
where Base.Element: Sendable {
@usableFromInline
enum _ElementOrGracefulShutdown: Sendable {
case base(AsyncMapNilSequence<Base>.Element)
Expand Down
17 changes: 10 additions & 7 deletions Sources/ServiceLifecycle/GracefulShutdown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ enum ValueOrGracefulShutdown<T: Sendable>: Sendable {
/// Cancels the closure when a graceful shutdown was triggered.
///
/// - Parameter operation: The actual operation.
public func cancelWhenGracefulShutdown<T: Sendable>(_ operation: @Sendable @escaping () async throws -> T) async rethrows -> T {
public func cancelWhenGracefulShutdown<T: Sendable>(
_ operation: @Sendable @escaping () async throws -> T
) async rethrows -> T {
return try await withThrowingTaskGroup(of: ValueOrGracefulShutdown<T>.self) { group in
group.addTask {
let value = try await operation()
Expand Down Expand Up @@ -163,7 +165,9 @@ public func cancelWhenGracefulShutdown<T: Sendable>(_ operation: @Sendable @esca
// renamed pattern has been shown to cause compiler crashes in 5.x compilers.
@available(*, deprecated, message: "renamed to cancelWhenGracefulShutdown")
#endif
public func cancelOnGracefulShutdown<T: Sendable>(_ operation: @Sendable @escaping () async throws -> T) async rethrows -> T? {
public func cancelOnGracefulShutdown<T: Sendable>(
_ operation: @Sendable @escaping () async throws -> T
) async rethrows -> T? {
return try await cancelWhenGracefulShutdown(operation)
}

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

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

return handlerID
}
// We are already shutting down so we just run the handler now.
handler()
return nil
}
}

Expand Down
Loading

0 comments on commit 1a0f3f5

Please sign in to comment.