Contributing

Running the tests

sbt test

That runs the ordinary JVM, Scala.js, and Scala Native suites. A change usually has to work on all three. Tests that need a broker or a schema registry are skipped unless the environment names one, which the scripts below do.

Scala.js uses Node.js 24, the version .nvmrc records:

nvm use

The Avro, JSON Schema and Protobuf suites on the JVM also check what xkafka writes and reads against Apache Avro and Confluent's own serializers, which come from Confluent's Maven repository.

Broker-backed tests

scripts/integration-test.sh

The script starts, in Docker:

It runs the same suites against all three backends, then removes the brokers, the registry and their volumes. When a run fails, each container's log is kept in target/broker-logs. Name a backend, jvm, js or native, to run only that one, as CI does with each on a runner of its own:

scripts/integration-test.sh native

The suites it runs include:

A case listed as divergent in the conformance suite is marked as expected to fail on the named backends. Fixing the backend makes the marked case fail, so a marker cannot outlive the divergence it records.

To run other commands against the same brokers and registry, such as a single suite, use scripts/with-kafka.sh, which starts them, exports their addresses, runs the command and cleans up:

scripts/with-kafka.sh sbt "schemaRegistryHttp4sJVM/Test/testOnly xkafka.schemaregistry.http4s.RegistryBrokerSuite"

The streams engine's tests run separately, against a broker of each Kafka release it supports and beside a Java Kafka Streams application, as CI does in a job of their own:

scripts/integration-test.sh --streams

librdkafka for the Native build

The build downloads librdkafka, verifies its SHA-256 checksum, builds it, and links it statically for the Native tests. librdkafka is built with TLS and compression, which need OpenSSL, zlib and zstd: libssl-dev, zlib1g-dev and libzstd-dev on Debian and Ubuntu, or brew install openssl@3 zstd zlib on macOS.

To prepare librdkafka explicitly:

sbt clientNative/prepareLibrdkafka

A prebuilt static installation can be supplied instead:

XKAFKA_LIBRDKAFKA_PREFIX=/path/to/librdkafka-prefix sbt test

The prefix must contain include/librdkafka/rdkafka.h and lib/librdkafka.a.

RocksDB for the Scala.js and Scala Native builds

The build downloads the pinned rocksdbjni jar once, verifies its checksum, and extracts the RocksDB library for this platform, which the Scala.js and Scala Native tests of stores kept on disk use.

The C shims

scripts/native-leak-check.sh

Runs the Native smoke binary against a broker under leaks on macOS or LeakSanitizer on Linux, so the shim's allocations are exercised through a real round trip.

scripts/js-leak-check.sh

Runs every asynchronous call of the Scala.js library against a broker under the same leak checkers, through a small C program linked against the library the npm package ships.

sbt clientJS/rocksdbShimTest

Builds the RocksDB shim and tests it in C under the same leak checkers, with the RocksDB library found each way a Native application finds it.

Published artifacts

XKAFKA_VERSION=<version> scripts/downstream-test.sh

Builds a separate application against the published xkafka-client artifacts of the version XKAFKA_VERSION names, and runs it against a broker the script starts, including both ways a Native application reaches librdkafka.

Formatting and checks

Before opening a pull request, run:

sbt prePR test mimaReportBinaryIssues doc docs/tlSite

prePR regenerates the CI workflow, adds missing license headers and formats the code, so commit what it changes; continuous integration checks all three. The rest runs the tests, the binary compatibility check, the API docs and the site, whose examples are compiled, as continuous integration does. Continuous integration also tests the sbt plugin on sbt 1 and sbt 2; to do the same, run sbt sbtCodegen/scripted '++3.9.0 sbtCodegen/scripted'.

Changes to the build

The continuous integration workflow is generated from build.sbt. After changing anything that affects it, such as adding a module:

sbt githubWorkflowGenerate

githubWorkflowCheck fails the build if the committed workflow is stale.