Skip to content

Commit 6e24f0e

Browse files
Fix failing CI Builds (swift-server#52)
* Exclude some files from soundness.sh Motivation: CI was failing as our soundness.sh script detected unacceptable language in our repo that cannot be avoided. Modifications: * excluded `CODE_OF_CONDUCT.md` from soundness check as it deliberately gives examples of what unacceptable language looks like * excluded all `*Config.swift` files from soundness check as Kafka configuration properties rely terminology which is considered unacceptable Result: The soundness CI check succeeds. * Include SwiftFormat in Dockerfile Motivation: CI failed because SwiftFormat was not installed on in our Docker container and needed by the `soundness.sh` script. Modifications: * add instructions for installing `nicklockwood/SwiftFormat` to `Dockerfile` Result: SwiftFormat is available to the `soundness.sh` script. * Adjust copyright header soundness check Modifications: * add copyright header to `Sources/Crdkafka/shim.h` * exclude `librdkafka` from copyright header check * Fix conflicting container names/ports Motivation: * CI was occasionally failing because of conflicting container names/ports Modifications: * remove explicit `container_name`s and `port`s in `docker-compose.yaml` * SwiftFormat: --disable hoist(Try|Await) * Run SwiftFormat
1 parent 2f36885 commit 6e24f0e

File tree

6 files changed

+46
-15
lines changed

6 files changed

+46
-15
lines changed

.swiftformat

+2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@
1919
--disable redundantReturn
2020
--disable preferKeyPath
2121
--disable sortedSwitchCases
22+
--disable hoistTry
23+
--disable hoistAwait
2224

2325
# rules

Sources/Crdkafka/shim.h

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the swift-kafka-gsoc open source project
4+
//
5+
// Copyright (c) 2022 Apple Inc. and the swift-kafka-gsoc 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-kafka-gsoc project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
115
#ifndef __RD_KAFKA_SHIM_H__
216
#define __RD_KAFKA_SHIM_H__
317
#include <librdkafka/rdkafka.h>

Sources/SwiftKafka/KafkaProducer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public actor KafkaProducer {
221221
valueBuffer.count,
222222
keyBytes,
223223
keyBytes?.count ?? 0,
224-
UnsafeMutableRawPointer(bitPattern: messageIDCounter)
224+
UnsafeMutableRawPointer(bitPattern: self.messageIDCounter)
225225
)
226226
}
227227

docker/Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ RUN wget -qO - http://packages.confluent.io/deb/7.2/archive.key | apt-key add -
1111
RUN add-apt-repository "deb http://packages.confluent.io/deb/ $(lsb_release -cs) main" -y
1212
RUN apt-get install librdkafka-dev -y
1313

14+
# tools
15+
RUN mkdir -p $HOME/.tools
16+
RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile
17+
18+
# swiftformat (until part of the toolchain)
19+
ARG swiftformat_version=0.51.8
20+
RUN git clone --branch $swiftformat_version --depth 1 https://github.com/nicklockwood/SwiftFormat $HOME/.tools/swift-format
21+
RUN cd $HOME/.tools/swift-format && swift build -c release
22+
RUN ln -s $HOME/.tools/swift-format/.build/release/swiftformat $HOME/.tools/swiftformat
23+
1424
WORKDIR /swift-kafka-gsoc
1525

1626
COPY . /swift-kafka-gsoc

docker/docker-compose.yaml

+2-11
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,13 @@ services:
44

55
zookeeper:
66
image: ubuntu/zookeeper
7-
container_name: zookeeper
8-
ports:
9-
- "2181:2181"
107

118
kafka:
129
image: ubuntu/kafka
13-
container_name: kafka_broker
1410
depends_on:
1511
- zookeeper
16-
ports:
17-
- "9092:9092"
1812
environment:
1913
ZOOKEEPER_HOST: zookeeper
20-
ZOOKEEPER_PORT: 2181
2114

2215
swift-kafka-gsoc:
2316
depends_on:
@@ -27,10 +20,9 @@ services:
2720
dockerfile: docker/Dockerfile
2821
environment:
2922
KAFKA_HOST: kafka
30-
KAFKA_PORT: 9092
3123

3224
# Swift on Server CI
33-
# e.g. docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.2204.57.yaml run test
25+
# e.g. docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.2204.57.yaml run test
3426

3527
runtime-setup:
3628
image: swift-kafka-gsoc:default
@@ -55,11 +47,10 @@ services:
5547
depends_on: [kafka, runtime-setup]
5648
environment:
5749
KAFKA_HOST: kafka
58-
KAFKA_PORT: 9092
5950
command: /bin/bash -xcl "swift $${SWIFT_TEST_VERB-test} $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-}"
6051

6152
# util
6253

6354
shell:
6455
<<: *common
65-
entrypoint: /bin/bash
56+
entrypoint: /bin/bash

scripts/soundness.sh

+17-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,22 @@ unacceptable_terms=(
3030
-e slav[e]
3131
-e sanit[y]
3232
)
33-
if git grep --color=never -i "${unacceptable_terms[@]}" > /dev/null; then
33+
34+
# We have to exclude the code of conduct because it gives examples of unacceptable language.
35+
# We have to exclude *Config.swift files as they need to map to Kafka terminology
36+
# which is considered unacceptable by us.
37+
exclude_files=(
38+
CODE_OF_CONDUCT.md
39+
*Config.swift
40+
)
41+
for word in "${exclude_files[@]}"; do
42+
exclude_files+=(":(exclude)$word")
43+
done
44+
exclude_files_str=$(printf " %s" "${exclude_files[@]}")
45+
46+
if git grep --color=never -i "${unacceptable_terms[@]}" -- . $exclude_files_str > /dev/null; then
3447
printf "\033[0;31mUnacceptable language found.\033[0m\n"
35-
git grep -i "${unacceptable_terms[@]}"
48+
git grep -i "${unacceptable_terms[@]}" -- . $exclude_files_str
3649
exit 1
3750
fi
3851
printf "\033[0;32mokay.\033[0m\n"
@@ -59,7 +72,8 @@ for language in swift-or-c bash dtrace python; do
5972
matching_files=( -name '*' )
6073
case "$language" in
6174
swift-or-c)
62-
exceptions=( -name Package.swift )
75+
# we don't add our own headers to the librdkafka submodule
76+
exceptions=( -path '*Sources/Crdkafka/librdkafka/*' -o -name Package.swift )
6377
matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' )
6478
cat > "$tmp" <<"EOF"
6579
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)