Skip to content

Commit

Permalink
Add X32 CI build
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb committed Oct 25, 2024
1 parent 6c1a72c commit fc35dc0
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 14 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ jobs:
librdkafka: 'v1.9.2'
memcheck: '1'

# X32
- php: '8.3.0'
librdkafka: 'v2.6.0'
arch: 'X32'

# Latest librdkafka 2.x
- php: '8.3.0'
librdkafka: 'v2.3.0'
Expand Down Expand Up @@ -172,6 +177,7 @@ jobs:
SKIP_OAUTH: ${{ matrix.skipoauth }}
TEST_KAFKA_BROKERS: kafka:9092
TEST_KAFKA_BROKER_VERSION: 2.6
ARCH: ${{ matrix.arch }}
steps:
- name: 'Check out repository'
uses: 'actions/checkout@v2'
Expand All @@ -181,12 +187,15 @@ jobs:
- uses: actions/cache@v2
with:
path: ~/build-cache/php
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.memcheck }}
key: ${{ runner.os }}-${{ matrix.arch }}-${{ matrix.php }}-${{ matrix.memcheck }}

- uses: actions/cache@v2
with:
path: ~/build-cache/librdkafka
key: ${{ runner.os }}-${{ matrix.librdkafka }}
key: ${{ runner.os }}-${{ matrix.arch }}-${{ matrix.librdkafka }}

- name: 'Install dependencies'
run: './php-rdkafka/.github/workflows/test/install-dependencies.sh'

- name: 'Build librdkafka'
run: './php-rdkafka/.github/workflows/test/build-librdkafka.sh'
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/test/build-librdkafka.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ if ! [ -f ~/build-cache/librdkafka/usr/local/include/librdkafka/rdkafka.h ] || !

git clone --depth 1 --branch "${LIBRDKAFKA_VERSION:-v2.3.0}" "${LIBRDKAFKA_REPOSITORY_URL:-https://github.com/edenhill/librdkafka.git}"

LIBRDKAFKA_BUILD_FLAGS=

if [ "$ARCH" = "X32" ]; then
export CC="${CC:-gcc} -m32"
export CFLAGS="$CFLAGS -m32"
export CXXFLAGS="$CXXFLAGS -m32"
export LDFLAGS="$LDFLAGS -m32"
LIBRDKAFKA_BUILD_FLAGS="$LIBRDKAFKA_BUILD_FLAGS --build=i686-pc-linux-gnu"
fi

cd librdkafka
./configure
make
./configure $LIBRDKAFKA_BUILD_FLAGS
make -j $(nproc)
mkdir -p ~/build-cache/librdkafka
sudo make install DESTDIR=$HOME/build-cache/librdkafka
test -f ~/build-cache/librdkafka/usr/local/include/librdkafka/rdkafka.h || echo "librdkafka build failed"
Expand All @@ -22,7 +32,7 @@ if ! [ -f ~/build-cache/librdkafka/usr/local/include/librdkafka/rdkafka.h ] || !

cd kafkacat
./configure
make
make -j $(nproc)
sudo make install DESTDIR=$HOME/build-cache/librdkafka

else
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/test/build-php-rdkafka.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ PACKAGE_VERSION="$(grep -m 1 '<release>' package.xml|cut -d'>' -f2|cut -d'<' -f1

pecl package

if [ $MEMORY_CHECK -eq 1 ]; then
PHP_RDKAFKA_CFLAGS="-Wall -Werror -Wno-deprecated-declarations"
if [ $MEMORY_CHECK -eq 1 ] || [ "$ARCH" = "X32" ]; then
export CFLAGS="$CFLAGS -Wall -Werror -Wno-deprecated-declarations"
fi

sudo CFLAGS="$PHP_RDKAFKA_CFLAGS" pecl install "./rdkafka-$PACKAGE_VERSION.tgz"
if [ "$ARCH" = "X32" ]; then
export CC="${CC:-gcc} -m32"
export CFLAGS="$CFLAGS -m32"
export CXXFLAGS="$CXXFLAGS -m32"
export LDFLAGS="$LDFLAGS -m32"
fi

sudo -E pecl install "./rdkafka-$PACKAGE_VERSION.tgz"

echo "extension=rdkafka.so"|sudo tee /usr/local/etc/php/rdkafka.ini >/dev/null
12 changes: 8 additions & 4 deletions .github/workflows/test/build-php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

set -ex

if [ $MEMORY_CHECK -eq 1 ]; then
sudo apt-get -y install valgrind
fi

if ! [ -f ~/build-cache/php/usr/local/bin/php ]; then
echo "PHP build is not cached"

Expand All @@ -29,6 +25,14 @@ if ! [ -f ~/build-cache/php/usr/local/bin/php ]; then
esac
fi

if [ "$ARCH" = "X32" ]; then
export CC="${CC:-gcc} -m32"
export CFLAGS="$CFLAGS -m32"
export CXXFLAGS="$CXXFLAGS -m32"
export LDFLAGS="$LDFLAGS -m32"
PHP_BUILD_FLAGS="$PHP_BUILD_FLAGS --build=i686-pc-linux-gnu"
fi

./configure $PHP_BUILD_FLAGS $PHP_BUILD_EXTRA_FLAGS
make -j $(nproc)
mkdir -p ~/build-cache/php
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/test/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -ex

export DEBIAN_FRONTEND=noninteractive

DEPS="zlib1g-dev libssl-dev"

if [ "$ARCH" = "X32" ]; then
sudo dpkg --add-architecture i386
sudo apt-get update
DEPS="$DEPS gcc-multilib g++-multilib zlib1g-dev:i386 libssl-dev:i386"
fi

if [ "$MEMORY_CHECK" = "1" ]; then
DEPS="$DEPS valgrind"
fi

if [ -n "$DEPS" ]; then
sudo apt-get -y install $DEPS
fi
4 changes: 2 additions & 2 deletions conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ static void kafka_conf_log_cb(const rd_kafka_t *rk, int level, const char *facil
zval_ptr_dtor(&args[3]);
}

#ifdef HAS_RD_KAFKA_OAUTHBEARER
/*
void rd_kafka_conf_set_oauthbearer_token_refresh_cb(
rd_kafka_conf_t *conf,
Expand Down Expand Up @@ -371,8 +372,7 @@ static void kafka_conf_set_oauthbearer_token_refresh_cb(rd_kafka_t *rk, const ch
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
}


#endif

/* {{{ proto RdKafka\Conf::__construct() */
PHP_METHOD(RdKafka_Conf, __construct)
Expand Down

0 comments on commit fc35dc0

Please sign in to comment.