Skip to content

Commit 2b4e29e

Browse files
rnroktoso
andauthored
Migrate to GitHub Actions (#47)
Co-authored-by: Konrad `ktoso` Malawski <[email protected]>
1 parent 43c98e0 commit 2b4e29e

File tree

47 files changed

+500
-620
lines changed

Some content is hidden

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

47 files changed

+500
-620
lines changed

.editorconfig

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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

.github/workflows/main.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
schedule:
7+
- cron: "0 8,20 * * *"
8+
9+
jobs:
10+
unit-tests:
11+
name: Unit tests
12+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
13+
with:
14+
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
15+
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
16+
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
17+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
18+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
19+
20+
benchmarks:
21+
name: Benchmarks
22+
# Workaround https://github.com/nektos/act/issues/1875
23+
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
24+
with:
25+
benchmark_package_path: "Benchmarks"

.github/workflows/pull_request.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
soundness:
9+
name: Soundness
10+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
11+
with:
12+
license_header_check_project_name: "Swift Service Context"
13+
14+
unit-tests:
15+
name: Unit tests
16+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
17+
with:
18+
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
19+
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
20+
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
21+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
22+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
23+
24+
benchmarks:
25+
name: Benchmarks
26+
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
27+
with:
28+
benchmark_package_path: "Benchmarks"
29+
30+
cxx-interop:
31+
name: Cxx interop
32+
uses: apple/swift-nio/.github/workflows/cxx_interop.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

.licenseignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
.unacceptablelanguageignore

.swift-format

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

.swiftformat

-20
This file was deleted.

Benchmarks/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.build/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift Service Context open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift Service Context project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift Service Context project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
import Benchmark
16+
17+
let benchmarks = {
18+
let defaultMetrics: [BenchmarkMetric] = [
19+
.mallocCountTotal
20+
]
21+
22+
Benchmark(
23+
"PassAroundStaticStringsSmall",
24+
configuration: .init(
25+
metrics: defaultMetrics,
26+
scalingFactor: .mega,
27+
maxDuration: .seconds(10_000_000),
28+
maxIterations: 10
29+
)
30+
) { benchmark in
31+
runPassAroundStaticStringsSmall(
32+
iterations: benchmark.scaledIterations.upperBound
33+
)
34+
}
35+
36+
Benchmark(
37+
"PassAroundStaticStringsLarge",
38+
configuration: .init(
39+
metrics: defaultMetrics,
40+
scalingFactor: .mega,
41+
maxDuration: .seconds(10_000_000),
42+
maxIterations: 10
43+
)
44+
) { benchmark in
45+
runPassAroundStaticStringsLarge(
46+
iterations: benchmark.scaledIterations.upperBound
47+
)
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift Service Context open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift Service Context project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift Service Context project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
//===----------------------------------------------------------------------===//
16+
//
17+
// This source file is part of the Swift Distributed Tracing open source project
18+
//
19+
// Copyright (c) 2024 Apple Inc. and the Swift Distributed Tracing project
20+
// authors
21+
// Licensed under Apache License v2.0
22+
//
23+
// See LICENSE.txt for license information
24+
//
25+
// SPDX-License-Identifier: Apache-2.0
26+
//
27+
//===----------------------------------------------------------------------===//
28+
29+
import Benchmark
30+
import ServiceContextModule
31+
32+
func runPassAroundStaticStringsSmall(iterations: Int) {
33+
var context = ServiceContext.topLevel
34+
// static allocated strings
35+
context[StringKey1.self] = "one"
36+
context[StringKey2.self] = "two"
37+
context[StringKey3.self] = "three"
38+
39+
for _ in 0..<iterations {
40+
let res = take1(context: context)
41+
precondition(res == 42)
42+
}
43+
}
44+
45+
func runPassAroundStaticStringsLarge(iterations: Int) {
46+
var context = ServiceContext.topLevel
47+
// static allocated strings
48+
context[StringKey1.self] = String(repeating: "a", count: 30)
49+
context[StringKey2.self] = String(repeating: "b", count: 12)
50+
context[StringKey3.self] = String(repeating: "c", count: 20)
51+
52+
for _ in 0..<iterations {
53+
let res = take1(context: context)
54+
precondition(res == 42)
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift Service Context open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift Service Context project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift Service Context project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
//===----------------------------------------------------------------------===//
16+
//
17+
// This source file is part of the Swift Distributed Tracing open source project
18+
//
19+
// Copyright (c) 2020-2021 Apple Inc. and the Swift Distributed Tracing project
20+
// authors
21+
// Licensed under Apache License v2.0
22+
//
23+
// See LICENSE.txt for license information
24+
//
25+
// SPDX-License-Identifier: Apache-2.0
26+
//
27+
//===----------------------------------------------------------------------===//
28+
29+
import Foundation
30+
import ServiceContextModule
31+
32+
@inline(never)
33+
func take1(context: ServiceContext) -> Int {
34+
take2(context: context)
35+
}
36+
37+
@inline(never)
38+
func take2(context: ServiceContext) -> Int {
39+
take3(context: context)
40+
}
41+
42+
@inline(never)
43+
func take3(context: ServiceContext) -> Int {
44+
take4(context: context)
45+
}
46+
47+
@inline(never)
48+
func take4(context: ServiceContext) -> Int {
49+
42
50+
}
51+
52+
enum StringKey1: ServiceContextKey {
53+
typealias Value = String
54+
}
55+
56+
enum StringKey2: ServiceContextKey {
57+
typealias Value = String
58+
}
59+
60+
enum StringKey3: ServiceContextKey {
61+
typealias Value = String
62+
}

0 commit comments

Comments
 (0)