Skip to content

Commit

Permalink
Migrate to GitHub Actions (#175)
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:

GitHub Actions CI

Future improvements:
* Re-enable `--warnings-as-errors`
* Investigate extending re-used workflows to enable specifying setup
commands and services to allow us to drop the bespoke workflows here.
* Enable API breakage checks
* Set thresholds and enable Benchmarks
* Enable documentation checking
  • Loading branch information
rnro authored Nov 13, 2024
1 parent 1638b32 commit e768c1e
Show file tree
Hide file tree
Showing 49 changed files with 754 additions and 485 deletions.
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
15 changes: 15 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[flake8]

ignore =
# These are needed to make our license headers pass the linting
E265,
E266,

# 10% larger than the standard 80 character limit. Conforms to the black
# standard and Bugbear's B950.
max-line-length = 88

# Custom rules:
exclude =
Sources/Crdkafka/
Sources/COpenSSL/
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
18 changes: 18 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Main

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

jobs:
unit-tests:
name: Unit tests
uses: ./.github/workflows/unit_tests.yml
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -strict-concurrency=complete"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -strict-concurrency=complete"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
39 changes: 39 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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
docs_check_enabled: false # requires libsasl2-dev

unit-tests:
name: Unit tests
uses: ./.github/workflows/unit_tests.yml
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -strict-concurrency=complete"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -strict-concurrency=complete"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Cxx interop"
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q jq && apt-get -y install libsasl2-dev && curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-cxx-interop-compatibility.sh | bash"
matrix_linux_5_9_enabled: true
matrix_linux_5_10_enabled: true
matrix_linux_6_0_enabled: true
matrix_linux_nightly_6_0_enabled: true
matrix_linux_nightly_main_enabled: true
matrix_windows_6_0_enabled: false
matrix_windows_nightly_6_0_enabled: false
matrix_windows_nightly_main_enabled: false
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
105 changes: 105 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Unit tests

on:
workflow_call:
inputs:
linux_5_9_enabled:
type: boolean
description: "Boolean to enable the Linux 5.9 Swift version matrix job. Defaults to true."
default: true
linux_5_9_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux 5.9 Swift version matrix job."
default: ""
linux_5_10_enabled:
type: boolean
description: "Boolean to enable the Linux 5.10 Swift version matrix job. Defaults to true."
default: true
linux_5_10_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux 5.10 Swift version matrix job."
default: ""
linux_6_0_enabled:
type: boolean
description: "Boolean to enable the Linux 6.0 Swift version matrix job. Defaults to true."
default: true
linux_6_0_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux 6.0 Swift version matrix job."
default: ""
linux_nightly_6_0_enabled:
type: boolean
description: "Boolean to enable the Linux nightly 6.0 Swift version matrix job. Defaults to true."
default: true
linux_nightly_6_0_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux nightly 6.0 Swift version matrix job."
default: ""
linux_nightly_main_enabled:
type: boolean
description: "Boolean to enable the Linux nightly main Swift version matrix job. Defaults to true."
default: true
linux_nightly_main_arguments_override:
type: string
description: "The arguments passed to swift test in the Linux nightly main Swift version matrix job."
default: ""

jobs:
unit-tests:
name: 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: ${{ inputs.linux_5_9_enabled }}
- image: "swift:5.10-jammy"
swift_version: "5.10"
enabled: ${{ inputs.linux_5_10_enabled }}
- image: "swift:6.0-jammy"
swift_version: "6.0"
enabled: ${{ inputs.linux_6_0_enabled }}
- image: "swiftlang/swift:nightly-6.0-jammy"
swift_version: "nightly-6.0"
enabled: ${{ inputs.linux_nightly_6_0_enabled }}
- image: "swiftlang/swift:nightly-main-jammy"
swift_version: "nightly-main"
enabled: ${{ inputs.linux_nightly_main_enabled }}
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 test"
COMMAND_OVERRIDE_5_9: "swift test ${{ inputs.linux_5_9_arguments_override }}"
COMMAND_OVERRIDE_5_10: "swift test ${{ inputs.linux_5_10_arguments_override }}"
COMMAND_OVERRIDE_6_0: "swift test ${{ inputs.linux_6_0_arguments_override }}"
COMMAND_OVERRIDE_NIGHTLY_6_0: "swift test ${{ inputs.linux_nightly_6_0_arguments_override }}"
COMMAND_OVERRIDE_NIGHTLY_MAIN: "swift test ${{ inputs.linux_nightly_main_arguments_override }}"
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
43 changes: 43 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.dockerignore
.gitignore
**/.gitignore
.licenseignore
.gitattributes
.gitmodules
.git-blame-ignore-revs
.mailfilter
.mailmap
.spi.yml
.swift-format
.swiftformatignore
.editorconfig
.yamlignore
.github/*
.yamllint.yml
.flake8
*.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/*
4 changes: 4 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [Kafka, KafkaFoundationCompat]
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/*
12 changes: 12 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extends: default

rules:
line-length: false
document-start: false
truthy:
check-keys: false # Otherwise we get a false positive on GitHub action's `on` key

# Custom ignores
ignore: |
Sources/Crdkafka/
Sources/COpenSSL/
Loading

0 comments on commit e768c1e

Please sign in to comment.