Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 5 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
version: 2.1

orbs:
ci-caching: jobcloud/ci-caching@3.1
ci-php: jobcloud/ci-php@2.7
ci-caching: jobcloud/ci-caching@3.2.5
ci-php: jobcloud/ci-php@2.12.1

workflows:
version: 2
test-php-kafka-lib:
jobs:
- ci-caching/build-docker-images:
context: dockerhub-credentials
dockerComposeFile: "./docker/docker-compose.yml"
- ci-php/install-dependencies:
context: dockerhub-credentials
dockerComposeFile: "./docker/docker-compose.yml"
dependencyCheckSumFile: "./composer.json"
requires:
- ci-caching/build-docker-images
- coverage:
- ci-php/coverage:
context: dockerhub-credentials
dependencyCheckSumFile: "./composer.json"
requires:
- ci-php/install-dependencies
- ci-php/code-style:
context: dockerhub-credentials
dockerComposeFile: "./docker/docker-compose.yml"
dependencyCheckSumFile: "./composer.json"
requires:
- ci-php/install-dependencies
- ci-php/static-analysis:
context: dockerhub-credentials
dockerComposeFile: "./docker/docker-compose.yml"
dependencyCheckSumFile: "./composer.json"
requires:
- ci-php/install-dependencies
- ci-php/infection-testing:
context: dockerhub-credentials
dockerComposeFile: "./docker/docker-compose.yml"
dependencyCheckSumFile: "./composer.json"
requires:
- ci-php/install-dependencies
Expand Down Expand Up @@ -66,21 +63,3 @@ workflows:
requires:
- build-docker-images
- install-dependencies

jobs:
coverage:
machine: true
steps:
- ci-php/coverage-command:
dockerComposeFile: "./docker/docker-compose.yml"
dependencyCheckSumFile: "./composer.json"
- run:
name: Download cc-test-reporter
command: |
mkdir -p tmp/
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an archived project, the download of this file does not even exist anymore.

chmod +x ./tmp/cc-test-reporter
- run:
name: Upload coverage results to Code Climate
command: |
./tmp/cc-test-reporter after-build -p /var/www/html --coverage-input-type clover --exit-code $?
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
/composer.symlink
composer.lock
.phpunit.result.cache
clover.xml
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 JobCloud AG
Copyright (c) 2025 JobCloud AG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PHPSTAN = ./vendor/bin/phpstan
PHPCS = ./vendor/bin/phpcs --extensions=php
CONSOLE = ./bin/console
INFECTION = ./vendor/bin/infection
COVCHK = ./vendor/bin/coverage-check

clean:
rm -rf ./build ./vendor
Expand All @@ -15,7 +16,7 @@ code-style: pcov-disable
${PHPCS} --report-full --report-gitblame --standard=PSR12 ./src --exclude=Generic.Commenting.Todo --report-junit=build/logs/phpcs/junit.xml

coverage: pcov-enable
${PHPUNIT} && ./vendor/bin/coverage-check clover.xml 100
${PHPUNIT} && ${COVCHK} build/logs/phpunit/clover.xml 100

test: pcov-disable
${PHPUNIT}
Expand All @@ -35,9 +36,8 @@ install-dependencies-lowest:

infection-testing:
make coverage
cp -f build/logs/phpunit/junit.xml build/logs/phpunit/coverage/junit.xml
sudo php-ext-disable pcov
${INFECTION} --coverage=build/logs/phpunit/coverage --min-msi=91 --threads=`nproc`
${INFECTION} --coverage=build/logs/phpunit/ --min-msi=91 --threads=`nproc`
sudo php-ext-enable pcov

pcov-enable:
Expand Down
33 changes: 17 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,36 @@
"rdkafka"
],
"require": {
"php": "^8.0",
"ext-rdkafka": "^4.0|^5.0|^6.0",
"ext-json": "*"
"php": "^8.1",
"ext-rdkafka": "^4.0|^5.0|^6.0"
},
"require-dev": {
"phpunit/phpunit": "^9.4",
"squizlabs/php_codesniffer": "^3.5.4",
"phpstan/phpstan": "^1.8",
"php-mock/php-mock-phpunit": "^2.6",
"kwn/php-rdkafka-stubs": "^2.0.0",
"ext-pcntl": "*",
"flix-tech/avro-serde-php": "^1.7.2 || ^2.2.0 || ^3.0.0",
Comment on lines +20 to +25
Copy link
Copy Markdown
Contributor

@nemanjajojic nemanjajojic Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"flix-tech/avro-serde-php": "^1.7.2"

can work only with php ^7.3||^8.0, meaning can't be shipped alongside php dependency php 8.1.

If problem you trying to solve is to use "flix-tech/avro-serde-php": "^3.0", than only thing that's necessary for this pr is

"flix-tech/avro-serde-php": "^1.7.2 || ^2.2.0 || ^3.0.0",

rest can be reverted and we'll release patch version.

The same applies for this PR

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^7.3||^8.0 means it can even run with a PHP version like 8.9.

Copy link
Copy Markdown
Contributor

@nemanjajojic nemanjajojic Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup including 8.0. But one of change in this pr is to remove support for php versions below 8.1, which is not necessary, because it's a BC.

In general, for releasing a new version we have to make a plan. So we should do everything we can to avoid introducing a BC

Copy link
Copy Markdown
Member Author

@haeber haeber Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do everything we can to avoid introducing a BC

Why? It's a jobcloud library, not used that much outside of our own projects, PHP 8.0 is not supported anymore, furthermore I actually plan to do a new major version, therefore I don't see any problems having small BC breaks then.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lib is not jobcloud exclusive. That's why we have jobcloud-kafka-lib.

There is nothing wrong with introducing a new major version. What we don't want is to introduce new version often(every week, month etc...) Instead we wanna plan all things that should be part of next major release eg. changing an api or internals.

For example, end support date for php 8.1 is December 31, 2025, meaning lowest supported version potentially should be 8.2.

I'd suggest trying to solve without needing releasing major version. If this is not possible, than we should proceed with release candidate(RC) version

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what's your actual Change Request?
I guess this:

  • "php": "^8.2"
  • lix-tech/avro-serde-php": "^2.2.0 || ^3.0.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferably if it's possible only this

"flix-tech/avro-serde-php": "^1.7.2 || ^2.2.0 || ^3.0.0",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't get it, what shall I change from what to what? And I would be fine with a new major (but not sure why we need RCs).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but not sure why we need RCs

The reason for releasing RC is so we can go further with development, even-thought there's still things we might include in next major release. RC allowing us to incrementally change code without frequent releasing major versions.

Let's have call tomorrow, since I'm bit confused

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, nevermind I think all this RC stuff is slowing us down.

"infection/infection": "^0.29.8",
"johnkary/phpunit-speedtrap": "^v3.3.0",
"kwn/php-rdkafka-stubs": "^v2.2.1",
"php-mock/php-mock-phpunit": "^2.13.0",
"phpstan/phpstan": "^2.1.24",
"phpunit/phpunit": "^9.6.26",
"rregeer/phpunit-coverage-check": "^0.3.1",
"johnkary/phpunit-speedtrap": "^3.1",
"flix-tech/avro-serde-php": "^1.4",
"infection/infection": "^0.26"
"squizlabs/php_codesniffer": "^3.13.4"
},
"autoload": {
"psr-4": {
"Jobcloud\\Kafka\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Jobcloud\\Kafka\\Tests\\": "tests/"
}
},
"suggest": {
"flix-tech/avro-serde-php": "Is needed for Avro support"
},
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": false
}
Expand Down
6 changes: 3 additions & 3 deletions docker/dev/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.0-cli-alpine3.16
FROM php:8.1-cli-alpine3.22

ARG HOST_USER_ID
ARG HOST_USER
Expand All @@ -24,11 +24,11 @@ RUN echo "$HOST_USER:x:$HOST_USER_ID:82:Linux User,,,:/home/$HOST_USER:" >> /etc
addgroup $HOST_USER www-data

# COMPOSER: install binary and prestissimo
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer --version=2.5.1
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

# PHP: Install php extensions
RUN pecl channel-update pecl.php.net && \
pecl install rdkafka-6.0.3 pcov && \
pecl install rdkafka pcov && \
docker-php-ext-install pcntl && \
php-ext-enable rdkafka pcntl pcov

Expand Down
1 change: 0 additions & 1 deletion docker/docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.2'
services:
php:
build:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.2'
services:
php:
build:
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
<file>src</file>
<file>tests</file>
<rule ref="PSR12"/>
<arg name="report-gitblame"/>
<arg name="report-full"/>
Expand Down
64 changes: 28 additions & 36 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
forceCoversAnnotation="true"
bootstrap="tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
<coverage>
<include>
<directory>src</directory>
</include>
<report>
<clover outputFile="clover.xml"/>
<html outputDirectory="build/logs/phpunit/coverage"/>
<text outputFile="php://stdout" showOnlySummary="true"/>
<xml outputDirectory="build/logs/phpunit/coverage/coverage-xml"/>
</report>
</coverage>
<php>
<ini name="max_execution_time" value="-1"/>
<ini name="html_errors" value="false"/>
<ini name="memory_limit" value="2G"/>
</php>
<testsuites>
<testsuite name="Unit">
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/logs/phpunit/junit.xml"/>
</logging>
<listeners>
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener"/>
</listeners>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd">
<coverage>
<include>
<directory>src</directory>
</include>
<report>
<clover outputFile="build/logs/phpunit/clover.xml"/>
<html outputDirectory="build/logs/phpunit/coverage-html"/>
<text outputFile="php://stdout" showOnlySummary="true"/>
<xml outputDirectory="build/logs/phpunit/coverage-xml"/>
</report>
</coverage>
<php>
<ini name="max_execution_time" value="-1"/>
<ini name="html_errors" value="false"/>
<ini name="memory_limit" value="-1"/>
</php>
<testsuites>
<testsuite name="Unit">
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/logs/phpunit/junit.xml"/>
</logging>
<listeners>
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener"/>
</listeners>
</phpunit>
19 changes: 6 additions & 13 deletions src/Callback/KafkaConsumerRebalanceCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,16 @@
final class KafkaConsumerRebalanceCallback
{
/**
* @param RdKafkaConsumer $consumer
* @param integer $errorCode
* @param array|RdKafkaTopicPartition[]|null $partitions
* @param RdKafkaTopicPartition[]|null $partitions
* @throws KafkaRebalanceException
* @return void
*/
public function __invoke(RdKafkaConsumer $consumer, int $errorCode, array $partitions = null)
public function __invoke(RdKafkaConsumer $consumer, int $errorCode, ?array $partitions = null): void
{
try {
switch ($errorCode) {
case RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS:
$consumer->assign($partitions);
break;

default:
$consumer->assign(null);
break;
if ($errorCode === RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS) {
$consumer->assign($partitions);
} else {
$consumer->assign();
}
} catch (RdKafkaException $e) {
throw new KafkaRebalanceException($e->getMessage(), $e->getCode(), $e);
Expand Down
6 changes: 1 addition & 5 deletions src/Callback/KafkaErrorCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
final class KafkaErrorCallback
{
/**
* @param mixed $kafka
* @param integer $errorCode
* @param string $reason
* @return void
* @throws KafkaBrokerException
*/
public function __invoke($kafka, int $errorCode, string $reason)
public function __invoke(mixed $kafka, int $errorCode, string $reason): void
{
// non fatal errors are retried by librdkafka
if (RD_KAFKA_RESP_ERR__FATAL !== $errorCode) {
Expand Down
5 changes: 1 addition & 4 deletions src/Callback/KafkaProducerDeliveryReportCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
final class KafkaProducerDeliveryReportCallback
{
/**
* @param RdKafkaProducer $producer
* @param RdKafkaMessage $message
* @return void
* @throws KafkaProducerException
*/
public function __invoke(RdKafkaProducer $producer, RdKafkaMessage $message)
public function __invoke(RdKafkaProducer $producer, RdKafkaMessage $message): void
{

if (RD_KAFKA_RESP_ERR_NO_ERROR === $message->err) {
Expand Down
Loading