Contributions are very welcome on Karapace. When contributing please keep this in mind:
- Open an issue to discuss new bigger features.
- Write code consistent with the project style and make sure the tests are passing.
- Stay in touch with us if we have follow up questions or requests for further changes.
There is very little you need to get started coding for Karapace:
- Use one of the supported python versions
documented in the
project:requires-python. - Install Go (needed for the
protopacehelpers built duringpip install .). The Go module declaresgo 1.21(toolchain 1.24 is supported). - Create a virtual environment and install the dev dependencies in it:
python -m venv <path_to_venv>
source <path_to_venv>/bin/activate
pip install .
pip install -e .[dev,typing]For isolated testing and development using Docker, we provide convenient make commands that handle all setup automatically. This ensures consistency across development environments.
Set .env:
cp .env.example .envEdit .env to customize:
PYTHON_VERSION- Python version for Docker builds (default: 3.13)KARAPACE_VERSION- Karapace version (default: 5.0.3)DOCKER_COMPOSE- Docker compose command (default: docker-compose)RUNNER_UID/RUNNER_GID- Container user IDs (check .env.example on how to get)PYTEST_ARGS- Pytest arguments for test runs
Run any make command - make populates the environment with .env:
Some commands run start-karapace-docker-resources, so resources are available.
make cli- Open interactive shell inside Karapace containermake start-karapace-docker-resources- Start all Docker containers (Kafka, Schema Registry, etc.)make stop-karapace-docker-resources- Stop all Docker containersmake type-check-mypy-in-docker- Run type checking in Dockermake unit-tests-in-docker- Run unit tests in Dockermake integration-tests-in-docker- Run integration tests in Dockermake e2e-tests-in-docker- Run end-to-end tests in Dockermake smoke-test-schema-registry- Run schema registry smoke testsmake smoke-test-rest-proxy- Run REST proxy smoke tests
Karapace documentation is part of this GitHub repository. You can find it in website folder. Its README file contains instructions explaining how you can run documentation website locally.
Tests are written with the pytest framework, and All PRs are tested for each supported Python version using GitHub Flow.
There are two flavors of tests, unit tests and integration tests:
- Unit: These are faster and very useful for quick iterations. They are usually testing pure functions.
- Integration: Are slower but more complete. These tests run Karapace, ZooKeeper, and Kafka servers, pytest's fixtures are used to start/stop these for you.
Both flavors run in parallel using pytest-xdist. New tests should be engineered with this in mind:
- Don't reuse schema/subject/topic names
- Expect other clients to be interacting with the servers at the same time.
Before running the tests make sure you have protoc installed. protoc is part of the protobuf-compiler package.
In Fedora® distributions you can install it using:
dnf install protobuf-compiler
Use the make commands for consistent, isolated test environments:
make unit-tests-in-docker
make integration-tests-in-docker
make e2e-tests-in-dockerTo run the tests locally in your virtual environment use the binary pytest available in the virtualenv.
It will download Kafka to be used in the tests for you:
pytest tests/unit
pytest tests/integrationThe integration tests can be configured with the use of a few parameters:
--kafka-version: allows to change the version of the Kafka server used by the tests. Example versions:2.7.2,2.8.1,3.0.0.--kafka-bootstrap-servers: A comma separated list of servers. This option allows to use an external server (the tests won't start a server for you)
Other options can be seen with pytest test/integration --help
The code is statically checked and formatted using a few tools. To run these automatically on each commit please enable the pre-commit hooks.
To use your development code, you need to set up a Kafka server and run Karapace from you virtual environment:
docker compose -f ./container/compose.yml up -d kafka
karapace karapace.config.json
To see descriptions of configuration keys see our README.
Each configuration key can be overridden with an environment variable prefixed with KARAPACE_,
exception being configuration keys that actually start with the karapace string. For example, to
override the bootstrap_uri config value, one would use the environment variable
KARAPACE_BOOTSTRAP_URI.
- Commit messages should describe the changes, not the filenames. Win our admiration by following the excellent advice from Chris Beams when composing commit messages.
- Choose a meaningful title for your pull request.
- The pull request description should focus on what changed and why.
- Check that the tests pass (and add test coverage for your changes if appropriate).
- Tick the change type in the PR template. Reviewers add the matching label before merging (see below).
Karapace follows semantic versioning. Each release takes the highest level among the PRs merged since the previous tag.
| Level | When | Label |
|---|---|---|
| Level | Example | When |
| --- | --- | --- |
Major (<major>.0.0) |
7.0.0 |
Breaking changes: a config key removed or renamed, a changed default, an incompatible API change, a storage or backup format change, a dropped Python version |
Minor (<major>.<minor>.0) |
6.3.0 |
New features, endpoints or config options; major-version dependency upgrades |
Patch (<major>.<minor>.<patch>) |
6.2.5 |
Bug fixes, docs, tests, CI, minor dependency bumps |
"Generate release notes" groups PRs by these labels (.github/release.yml). An unlabelled PR lands under "Other changes", so an unlabelled feature makes a release look like a patch. Check the labels before every release (step 4 below).
- Open Releases → Draft a new release.
- Choose a tag: type the new version, e.g.
6.3.0. GitHub creates the tag on publish. - Target: the commit to release. Pick
main, or a recent commit from the list. For an older commit, usegh release create <version> --target <sha> --generate-notesinstead. - Previous tag: the last release of the same line. Click "Generate release notes".
If the notes have an "Other changes" section, those PRs have no label. Label them (labels can be added after merge)
and generate the notes again. To list unlabelled PRs in advance:
gh pr list --repo Aiven-Open/karapace --state merged --search "no:label merged:>=<date of the previous tag>" - Pick the version: anything under Breaking changes means a major, otherwise anything under Features means a minor, otherwise a patch.
- Publish. The tag push builds the container image.
A release contains the full history up to its target commit. To leave a merged PR out, revert it on main first.
- Merge the fix on
mainfirst. - Create the maintenance branch
<major>.<minor>.x(a literalx, e.g.6.2.x) from the line's latest tag if it doesn't exist:git switch -c 6.2.x 6.2.4. Never name a branch like a tag (6.2.5). - If the branch was cut from a tag older than
.github/release.yml, cherry-pick that file onto it once. - Cherry-pick the fix with
git cherry-pick -x <sha>into a PR against the maintenance branch (e.g.6.2.x), label it and merge it. - Release the next patch of that line (e.g.
6.2.5) with the maintenance branch as target, and untick "Set as the latest release".
Fedora and the Infinity design logo are trademarks of Red Hat, Inc.