diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 0b4a8e6c4..5b2505682 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -70,16 +70,10 @@ jobs: uses: actions/setup-java@v4 with: distribution: temurin - java-version: 11 - - name: Check Java installation - run: source travis_java_install.sh - - name: Pull Kafka releases - run: ./build_integration.sh + java-version: 21 + - name: Pull Kafka release + run: make servers/${{ matrix.kafka }}/kafka-bin + - name: Pytest + run: make test env: - PLATFORM: ${{ matrix.platform }} - KAFKA_VERSION: ${{ matrix.kafka }} - - name: Test with tox - run: tox - env: - PLATFORM: ${{ matrix.platform }} KAFKA_VERSION: ${{ matrix.kafka }} diff --git a/Makefile b/Makefile index fc8fa5b21..d384043a7 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,33 @@ -# Some simple testing tasks (sorry, UNIX only). +# Some simple testing tasks -FLAGS= -KAFKA_VERSION=0.11.0.2 -SCALA_VERSION=2.12 +SHELL = bash + +export KAFKA_VERSION ?= 2.4.0 +DIST_BASE_URL ?= https://archive.apache.org/dist/kafka/ + +# Required to support testing old kafka versions on newer java releases +# The performance opts defaults are set in each kafka brokers bin/kafka_run_class.sh file +# The values here are taken from the 2.4.0 release. +export KAFKA_JVM_PERFORMANCE_OPTS=-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -Djava.awt.headless=true setup: pip install -r requirements-dev.txt pip install -Ue . -servers/$(KAFKA_VERSION)/kafka-bin: - KAFKA_VERSION=$(KAFKA_VERSION) SCALA_VERSION=$(SCALA_VERSION) ./build_integration.sh - -build-integration: servers/$(KAFKA_VERSION)/kafka-bin - -# Test and produce coverage using tox. This is the same as is run on Travis -test37: build-integration - KAFKA_VERSION=$(KAFKA_VERSION) SCALA_VERSION=$(SCALA_VERSION) tox -e py37 -- $(FLAGS) +lint: + pylint --recursive=y --errors-only kafka test -test27: build-integration - KAFKA_VERSION=$(KAFKA_VERSION) SCALA_VERSION=$(SCALA_VERSION) tox -e py27 -- $(FLAGS) +test: build-integration + pytest --durations=10 kafka test # Test using pytest directly if you want to use local python. Useful for other # platforms that require manual installation for C libraries, ie. Windows. test-local: build-integration - KAFKA_VERSION=$(KAFKA_VERSION) SCALA_VERSION=$(SCALA_VERSION) pytest \ - --pylint --pylint-rcfile=pylint.rc --pylint-error-types=EF $(FLAGS) kafka test + pytest --pylint --pylint-rcfile=pylint.rc --pylint-error-types=EF $(TEST_FLAGS) kafka test cov-local: build-integration - KAFKA_VERSION=$(KAFKA_VERSION) SCALA_VERSION=$(SCALA_VERSION) pytest \ - --pylint --pylint-rcfile=pylint.rc --pylint-error-types=EF --cov=kafka \ - --cov-config=.covrc --cov-report html $(FLAGS) kafka test + pytest --pylint --pylint-rcfile=pylint.rc --pylint-error-types=EF --cov=kafka \ + --cov-config=.covrc --cov-report html $(TEST_FLAGS) kafka test @echo "open file://`pwd`/htmlcov/index.html" # Check the readme for syntax errors, which can lead to invalid formatting on @@ -56,4 +54,52 @@ doc: make -C docs html @echo "open file://`pwd`/docs/_build/html/index.html" -.PHONY: all test37 test27 test-local cov-local clean doc +.PHONY: all test test-local cov-local clean doc dist publish + +kafka_artifact_version=$(lastword $(subst -, ,$(1))) + +# Mappings for artifacts -> scala version; any unlisted will use default 2.12 +kafka_scala_0_8_0=2.8.0 +kafka_scala_0_8_1=2.10 +kafka_scala_0_8_1_1=2.10 +kafka_scala_0_8_2_0=2.11 +kafka_scala_0_8_2_1=2.11 +kafka_scala_0_8_2_2=2.11 +kafka_scala_0_9_0_0=2.11 +kafka_scala_0_9_0_1=2.11 +kafka_scala_0_10_0_0=2.11 +kafka_scala_0_10_0_1=2.11 +kafka_scala_0_10_1_0=2.11 +scala_version=$(if $(SCALA_VERSION),$(SCALA_VERSION),$(if $(kafka_scala_$(subst .,_,$(1))),$(kafka_scala_$(subst .,_,$(1))),2.12)) + +kafka_artifact_name=kafka_$(call scala_version,$(1))-$(1).$(if $(filter 0.8.0,$(1)),tar.gz,tgz) + +build-integration: servers/$(KAFKA_VERSION)/kafka-bin + +servers/dist: + mkdir -p servers/dist + +servers/dist/kafka_%.tgz servers/dist/kafka_%.tar.gz: + @echo "Downloading $(@F)" + wget -nv -P servers/dist/ -N $(DIST_BASE_URL)$(call kafka_artifact_version,$*)/$(@F) + +servers/dist/jakarta.xml.bind-api-2.3.3.jar: + wget -nv -P servers/dist/ -N https://repo1.maven.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar + +# to allow us to derive the prerequisite artifact name from the target name +.SECONDEXPANSION: + +servers/%/kafka-bin: servers/dist/$$(call kafka_artifact_name,$$*) | servers/dist + @echo "Extracting kafka $* binaries from $<" + if [ -d "$@" ]; then rm -rf $@.bak; mv $@ $@.bak; fi + mkdir $@ + tar xzvf $< -C $@ --strip-components 1 + if [[ "$*" < "1" ]]; then make servers/patch-libs/$*; fi + +servers/patch-libs/%: servers/dist/jakarta.xml.bind-api-2.3.3.jar | servers/$$*/kafka-bin + cp $< servers/$*/kafka-bin/libs/ + +servers/download/%: servers/dist/$$(call kafka_artifact_name,$$*) | servers/dist ; + +# Avoid removing any pattern match targets as intermediates (without this, .tgz artifacts are removed by make after extraction) +.SECONDARY: diff --git a/requirements-dev.txt b/requirements-dev.txt index 1fa933da2..e272d1ff7 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -15,3 +15,4 @@ Sphinx sphinx-rtd-theme tox xxhash +zstandard diff --git a/tox.ini b/tox.ini index 7417387ed..71e443dec 100644 --- a/tox.ini +++ b/tox.ini @@ -33,8 +33,7 @@ commands = setenv = CRC32C_SW_MODE = auto PROJECT_ROOT = {toxinidir} -passenv = KAFKA_VERSION - +passenv = KAFKA_* [testenv:pypy] # pylint is super slow on pypy...