Skip to content

Commit 96a6754

Browse files
committed
Add package action
1 parent 2e7a2fe commit 96a6754

File tree

5 files changed

+71
-7
lines changed

5 files changed

+71
-7
lines changed

.github/workflows/package.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Package'
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
package:
8+
name: 'Package'
9+
runs-on: 'ubuntu-20.04'
10+
steps:
11+
- name: 'Check out repository'
12+
uses: 'actions/checkout@v2'
13+
with:
14+
path: 'php-rdkafka'
15+
16+
- name: 'Install dependencies'
17+
run: 'sudo apt-get -y install php7.4-dev librdkafka-dev'
18+
19+
- name: 'Package and verify package'
20+
run: './php-rdkafka/.github/workflows/package/package.sh'
21+
22+
- name: 'Archive package'
23+
uses: 'actions/upload-artifact@v2'
24+
with:
25+
path: 'php-rdkafka/rdkafka.tgz'

.github/workflows/package/package.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
cd php-rdkafka
6+
7+
echo "Checking version consistency"
8+
9+
CODE_VERSION="$(grep PHP_RDKAFKA_VERSION php_rdkafka.h|cut -d'"' -f2)"
10+
PACKAGE_VERSION="$(grep -m 1 '<release>' package.xml|cut -d'>' -f2|cut -d'<' -f1)"
11+
12+
if ! [ "$CODE_VERSION" = "$PACKAGE_VERSION" ]; then
13+
printf "Version in php_rdkafka.h does not match version in package.xml: '%s' vs '%s'" "$CODE_VERSION" "$PACKAGE_VERSION" >&2
14+
exit 1
15+
fi
16+
17+
echo "Packaging"
18+
19+
pecl package
20+
21+
echo "Installing package.xml"
22+
23+
mv "./rdkafka-$PACKAGE_VERSION.tgz" rdkafka.tgz
24+
sudo pecl install ./rdkafka.tgz
25+
26+
echo "Checking that all test files was included"
27+
28+
sudo pecl list-files rdkafka|grep ^test|sed 's@.*/tests/@@'|sort > installed-test-files
29+
find tests/ -type f|sed 's@^tests/@@'|sort > repository-test-files
30+
31+
if ! diff -u repository-test-files installed-test-files; then
32+
echo "Some test files are missing from package.xml (see diff above)" >&2
33+
exit 1
34+
fi

.github/workflows/test/build-php-rdkafka.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ set -e
55
echo "Building php-rdkafka with PHP version:"
66
php --version
77

8+
cd php-rdkafka
9+
10+
PACKAGE_VERSION="$(grep -m 1 '<release>' package.xml|cut -d'>' -f2|cut -d'<' -f1)"
11+
12+
pecl package
13+
814
if [ $MEMORY_CHECK -eq 1 ]; then
915
PHP_RDKAFKA_CFLAGS="-Wall -Werror -Wno-deprecated-declarations"
1016
fi
1117

12-
cd php-rdkafka
13-
phpize
14-
CFLAGS="$PHP_RDKAFKA_CFLAGS" ./configure
15-
make
18+
sudo CFLAGS="$PHP_RDKAFKA_CFLAGS" pecl install "./rdkafka-$PACKAGE_VERSION.tgz"
1619

17-
echo "extension=$(pwd)/modules/rdkafka.so"|sudo tee /usr/local/etc/php/rdkafka.ini >/dev/null
20+
echo "extension=rdkafka.so"|sudo tee /usr/local/etc/php/rdkafka.ini >/dev/null

.github/workflows/test/tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -xve
44

55
cd php-rdkafka
66

7-
if [ $MEMORY_CHECK -eq 1 ]; then
7+
if [ ${MEMORY_CHECK:-0} -eq 1 ]; then
88
echo "Enabling memory checking"
99
showmem=--show-mem
1010
checkmem=-m
@@ -13,4 +13,4 @@ fi
1313
cp tests/test_env.php.sample tests/test_env.php
1414

1515
PHP=$(which php)
16-
REPORT_EXIT_STATUS=1 TEST_PHP_EXECUTABLE="$PHP" "$PHP" run-tests.php -q $checkmem --show-diff $showmem
16+
sudo REPORT_EXIT_STATUS=1 TEST_PHP_EXECUTABLE="$PHP" "$PHP" /usr/local/lib/php/build/run-tests.php -q $checkmem --show-diff $showmem

package.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
<file role="test" name="allow_null_payload.phpt"/>
111111
<file role="test" name="bug115.phpt"/>
112112
<file role="test" name="bug330.phpt"/>
113+
<file role="test" name="bug465.phpt"/>
113114
<file role="test" name="bug74.phpt"/>
114115
<file role="test" name="bug88.phpt"/>
115116
<file role="test" name="bugConfSetArgument.phpt"/>
@@ -137,6 +138,7 @@
137138
<file role="test" name="producev_opaque.phpt"/>
138139
<file role="test" name="rd_kafka_get_err_descs.phpt"/>
139140
<file role="test" name="test0.phpt"/>
141+
<file role="test" name="test_env.php.sample"/>
140142
<file role="test" name="topic_conf.phpt"/>
141143
<file role="test" name="topic_partition.phpt"/>
142144
</dir>

0 commit comments

Comments
 (0)