Skip to content

Commit

Permalink
Migrate to GitHub Actions
Browse files Browse the repository at this point in the history
Migrate CI to use GitHub Actions.

Motivation:

To migrate to GitHub actions and centralised infrastructure.

Modifications:

Changes of note:
* Bump the minimum version to Swift 5.9 in line with CI coverage
* Adopt swift-format using rules from SwiftNIO
* Remove scripts which are no longer needed

Result:

Feature parity with old CI.

Future improvements:
* Enable API breakage checks
* Enable YAML linting
* Enable Python linting
* Set thresholds and enable Benchmarks
  • Loading branch information
rnro committed Nov 12, 2024
1 parent 1638b32 commit 452c2a9
Show file tree
Hide file tree
Showing 48 changed files with 659 additions and 486 deletions.
1 change: 0 additions & 1 deletion .dockerignore

This file was deleted.

8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
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
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Main

on:
push:
branches: [main]
schedule:
- cron: "0 8,20 * * *"

jobs:
unit-tests:
name: Unit tests
uses: ./.github/workflows/unit-tests.yml
23 changes: 23 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: PR

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

jobs:
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "swift-kafka-client"
api_breakage_check_enabled: false # requires libsasl2-dev
yamllint_check_enabled: false # failures in librdkafka, need .yamlignore support
python_lint_check_enabled: false # requires librdkafka, need --exclude support

unit-tests:
name: Unit tests
uses: ./.github/workflows/unit-tests.yml

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.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
64 changes: 64 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Unit tests

on:
workflow_call:

jobs:
unit-tests:
name: Kafka unit tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# We are specifying only the major and minor of the docker images to automatically pick up the latest patch release
swift:
- image: "swift:5.9-jammy"
swift_version: "5.9"
enabled: true
- image: "swift:5.10-jammy"
swift_version: "5.10"
enabled: true
- image: "swift:6.0-jammy"
swift_version: "6.0"
enabled: true
- image: "swiftlang/swift:nightly-6.0-jammy"
swift_version: "nightly-6.0"
enabled: true
- image: "swiftlang/swift:nightly-main-jammy"
swift_version: "nightly-main"
enabled: true
steps:
- name: Checkout repository
if: ${{ matrix.swift.enabled }}
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true
- name: Mark the workspace as safe
if: ${{ matrix.swift.enabled }}
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Run matrix job
if: ${{ matrix.swift.enabled }}
env:
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
COMMAND: "swift"
COMMAND_OVERRIDE_5_9: "swift test -Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -strict-concurrency=complete"
COMMAND_OVERRIDE_5_10: "swift test -Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -strict-concurrency=complete"
COMMAND_OVERRIDE_6_0: "swift test --explicit-target-dependency-import-check error"
COMMAND_OVERRIDE_NIGHTLY_6_0: "swift test -Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
COMMAND_OVERRIDE_NIGHTLY_MAIN: "swift test -Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
run: |
apt-get -qq update && apt-get -qq -y install curl && apt-get -y install libsasl2-dev
curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.sh | bash
container:
image: ${{ matrix.swift.image }}
services:
zookeeper:
image: ubuntu/zookeeper
kafka:
image: ubuntu/kafka
env:
ZOOKEEPER_HOST: zookeeper
env:
KAFKA_HOST: kafka
40 changes: 40 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.gitignore
**/.gitignore
.licenseignore
.gitattributes
.gitmodules
.git-blame-ignore-revs
.mailfilter
.mailmap
.spi.yml
.swift-format
.swiftformatignore
.editorconfig
.yamlignore
.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
.unacceptablelanguageignore
Sources/Crdkafka/*
Sources/COpenSSL/*
68 changes: 68 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version" : 1,
"indentation" : {
"spaces" : 4
},
"tabWidth" : 4,
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"spacesAroundRangeFormationOperators" : false,
"indentConditionalCompilationBlocks" : false,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : true,
"lineBreakBeforeEachGenericRequirement" : true,
"lineLength" : 120,
"maximumBlankLines" : 1,
"respectsExistingLineBreaks" : true,
"prioritizeKeepingFunctionOutputTogether" : true,
"noAssignmentInExpressions" : {
"allowedFunctions" : [
"XCTAssertNoThrow",
"XCTAssertThrowsError"
]
},
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : 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" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : true,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : false,
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : false,
"UseSynthesizedInitializer" : false,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
}
}
25 changes: 0 additions & 25 deletions .swiftformat

This file was deleted.

2 changes: 2 additions & 0 deletions .unacceptablelanguageignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sources/Crdkafka/*
Sources/COpenSSL/*
2 changes: 2 additions & 0 deletions .yamlignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sources/Crdkafka/*
Sources/COpenSSL/*
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
import Benchmark
import Crdkafka
import Dispatch
import struct Foundation.Date
import struct Foundation.UUID
import Kafka
import Logging
import ServiceLifecycle

import struct Foundation.Date
import struct Foundation.UUID

let benchmarks = {
var uniqueTestTopic: String!
let messageCount: UInt = 1000
Expand Down Expand Up @@ -80,7 +81,11 @@ let benchmarks = {
logger: .perfLogger
)

let serviceGroupConfiguration = ServiceGroupConfiguration(services: [consumer], gracefulShutdownSignals: [.sigterm, .sigint], logger: .perfLogger)
let serviceGroupConfiguration = ServiceGroupConfiguration(
services: [consumer],
gracefulShutdownSignals: [.sigterm, .sigint],
logger: .perfLogger
)
let serviceGroup = ServiceGroup(configuration: serviceGroupConfiguration)

try await withThrowingTaskGroup(of: Void.self) { group in
Expand Down Expand Up @@ -119,7 +124,9 @@ let benchmarks = {

let timeIntervalTotal = Date.timeIntervalSinceReferenceDate - totalStartDate
let avgRateMb = Double(totalBytes) / timeIntervalTotal / 1024
benchLog("All read up to ctr: \(ctr), avgRate: (\(Int(avgRateMb))KB/s), timePassed: \(Int(timeIntervalTotal))sec")
benchLog(
"All read up to ctr: \(ctr), avgRate: (\(Int(avgRateMb))KB/s), timePassed: \(Int(timeIntervalTotal))sec"
)
}

// Wait for second Consumer Task to complete
Expand Down Expand Up @@ -149,7 +156,11 @@ let benchmarks = {
logger: .perfLogger
)

let serviceGroupConfiguration = ServiceGroupConfiguration(services: [consumer], gracefulShutdownSignals: [.sigterm, .sigint], logger: .perfLogger)
let serviceGroupConfiguration = ServiceGroupConfiguration(
services: [consumer],
gracefulShutdownSignals: [.sigterm, .sigint],
logger: .perfLogger
)
let serviceGroup = ServiceGroup(configuration: serviceGroupConfiguration)

try await withThrowingTaskGroup(of: Void.self) { group in
Expand Down Expand Up @@ -190,7 +201,9 @@ let benchmarks = {

let timeIntervalTotal = Date.timeIntervalSinceReferenceDate - totalStartDate
let avgRateMb = Double(totalBytes) / timeIntervalTotal / 1024
benchLog("All read up to ctr: \(ctr), avgRate: (\(Int(avgRateMb))KB/s), timePassed: \(Int(timeIntervalTotal))sec")
benchLog(
"All read up to ctr: \(ctr), avgRate: (\(Int(avgRateMb))KB/s), timePassed: \(Int(timeIntervalTotal))sec"
)
}

// Wait for second Consumer Task to complete
Expand Down Expand Up @@ -265,7 +278,9 @@ let benchmarks = {

let timeIntervalTotal = Date.timeIntervalSinceReferenceDate - totalStartDate
let avgRateMb = Double(totalBytes) / timeIntervalTotal / 1024
benchLog("All read up to ctr: \(ctr), avgRate: (\(Int(avgRateMb))KB/s), timePassed: \(Int(timeIntervalTotal))sec")
benchLog(
"All read up to ctr: \(ctr), avgRate: (\(Int(avgRateMb))KB/s), timePassed: \(Int(timeIntervalTotal))sec"
)
}

Benchmark("librdkafka_with_offset_commit_messages_\(messageCount)") { benchmark in
Expand Down Expand Up @@ -340,6 +355,8 @@ let benchmarks = {

let timeIntervalTotal = Date.timeIntervalSinceReferenceDate - totalStartDate
let avgRateMb = Double(totalBytes) / timeIntervalTotal / 1024
benchLog("All read up to ctr: \(ctr), avgRate: (\(Int(avgRateMb))KB/s), timePassed: \(Int(timeIntervalTotal))sec")
benchLog(
"All read up to ctr: \(ctr), avgRate: (\(Int(avgRateMb))KB/s), timePassed: \(Int(timeIntervalTotal))sec"
)
}
}
Loading

0 comments on commit 452c2a9

Please sign in to comment.