Skip to content

Commit

Permalink
ci: set LIBRDKAFKA_LIBRARY_PATH for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
dirx committed Oct 28, 2024
1 parent b390a32 commit d2576c2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
LIBRDKAFKA_LIBRARY_PATH: /opt/homebrew/lib/librdkafka.dylib
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion resources/phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
$version = getenv('LIBRDKAFKA_VERSION') ?: '';
$version = ltrim($version, 'v');
$version = $version === 'master' ? Library::VERSION_LATEST : $version;
Library::init($version);
Library::init($version, 'RdKafka', LIBRDKAFKA_LIBRARY_PATH);
1 change: 1 addition & 0 deletions resources/phpunit/config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

define('LIBRDKAFKA_LIBRARY_PATH', getenv('LIBRDKAFKA_LIBRARY_PATH') ?: null);
define('KAFKA_BROKERS', getenv('KAFKA_BROKERS') ?: 'kafka:9092');
const KAFKA_TEST_TOPIC = "test";
const KAFKA_TEST_TOPIC_ADMIN = "test_admin";
Expand Down
10 changes: 7 additions & 3 deletions tests/RdKafka/FFI/LibraryPreloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ class LibraryPreloadTest extends TestCase

protected function tearDown(): void
{
Library::init();
Library::init(
Library::VERSION_AUTODETECT,
'RdKafka',
LIBRDKAFKA_LIBRARY_PATH
);
}

public function testPreloadWithInvalidCdef(): void
{
$this->expectException(\FFI\Exception::class);
Library::preload(Library::getLibraryVersion(), 'Any', null, 'invalid');
Library::preload(Library::getLibraryVersion(), __METHOD__, LIBRDKAFKA_LIBRARY_PATH, 'invalid');
}

/**
* @depends testPreloadWithInvalidCdef
*/
public function testPreload(): void
{
$ffi = Library::preload();
$ffi = Library::preload(Library::getLibraryVersion(), __METHOD__, LIBRDKAFKA_LIBRARY_PATH);

$this->assertInstanceOf(FFI::class, $ffi);
$this->assertMatchesRegularExpression('/^\d+\.\d+\./', $ffi->rd_kafka_version_str());
Expand Down
6 changes: 5 additions & 1 deletion tests/RdKafka/FFI/LibraryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ class LibraryTest extends TestCase

protected function tearDown(): void
{
Library::init();
Library::init(
Library::VERSION_AUTODETECT,
'RdKafka',
LIBRDKAFKA_LIBRARY_PATH
);
}

public function testGetFFI(): void
Expand Down

0 comments on commit d2576c2

Please sign in to comment.