Skip to content

[Cache] Fix CI because of Couchbase version #39131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2020
Merged
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
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,12 @@ jobs:

- name: Install system dependencies
run: |
echo "::group::add apt sources"
sudo wget -O - http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add -
echo "deb http://packages.couchbase.com/ubuntu bionic bionic/main" | sudo tee /etc/apt/sources.list.d/couchbase.list
echo "::endgroup::"

echo "::group::apt-get update"
sudo apt-get update
echo "::endgroup::"

echo "::group::install tools & libraries"
sudo apt-get install libcouchbase-dev librdkafka-dev
sudo apt-get install librdkafka-dev
echo "::endgroup::"

- name: Configure Couchbase
Expand All @@ -122,6 +117,11 @@ jobs:
php-version: "${{ matrix.php }}"
tools: pecl

- name: Display versions
run: |
php -r 'foreach (get_loaded_extensions() as $extension) echo $extension . " " . phpversion($extension) . PHP_EOL;'
php -i

- name: Load fixtures
uses: docker://bitnami/openldap
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CouchbaseBucketAdapter extends AbstractAdapter
public function __construct(\CouchbaseBucket $bucket, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null)
{
if (!static::isSupported()) {
throw new CacheException('Couchbase >= 2.6.0 is required.');
throw new CacheException('Couchbase >= 2.6.0 < 3.0.0 is required.');
}

$this->maxIdLength = static::MAX_KEY_LENGTH;
Expand All @@ -66,7 +66,7 @@ public static function createConnection($servers, array $options = []): \Couchba
}

if (!static::isSupported()) {
throw new CacheException('Couchbase >= 2.6.0 is required.');
throw new CacheException('Couchbase >= 2.6.0 < 3.0.0 is required.');
}

set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
Expand Down Expand Up @@ -125,7 +125,7 @@ public static function createConnection($servers, array $options = []): \Couchba

public static function isSupported(): bool
{
return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '2.6.0', '>=');
return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '2.6.0', '>=') && version_compare(phpversion('couchbase'), '3.0', '<');
}

private static function getOptions(string $options): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
use Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter;

/**
* @requires extension couchbase 2.6.0
* @requires extension couchbase <3.0.0
Copy link
Member Author

Choose a reason for hiding this comment

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

duplicate with check in setupBeforeClass because not all version of phpunit supports multiple requires on the same extension

* @requires extension couchbase >=2.6.0
* @group integration
*
* @author Antonio Jose Cerezo Aranda <aj.cerezo@gmail.com>
Expand All @@ -32,6 +33,10 @@ class CouchbaseBucketAdapterTest extends AdapterTestCase

public static function setupBeforeClass(): void
{
if (!CouchbaseBucketAdapter::isSupported()) {
self::markTestSkipped('Couchbase >= 2.6.0 < 3.0.0 is required.');
}

self::$client = AbstractAdapter::createConnection('couchbase://'.getenv('COUCHBASE_HOST').'/cache',
['username' => getenv('COUCHBASE_USER'), 'password' => getenv('COUCHBASE_PASS')]
);
Expand Down