Skip to content

Commit

Permalink
migrate from travis to github actions (solariumphp#792)
Browse files Browse the repository at this point in the history
... and run all integration tests in cloud mode, too.
  • Loading branch information
Markus Kalkbrenner authored May 29, 2020
1 parent 7b78901 commit 11bcd88
Show file tree
Hide file tree
Showing 22 changed files with 914 additions and 922 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Run Tests

on:
push:

schedule:
- cron: '0 8 * * *' # run at 08:00 UTC

jobs:
run-tests:
runs-on: ubuntu-latest

strategy:
matrix:
php: [7.2, 7.3, 7.4]
solr: [7, 8]
mode: [cloud, server]
symfony: [4.3.*, 4.4.*, 5.0.*]

name: PHP ${{ matrix.php }}, symfony ${{ matrix.symfony }}, Solr ${{ matrix.solr }} ${{ matrix.mode }}

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, intl, iconv, json, simplexml
ini-values: memory_limit=256M,post_max_size=256M
coverage: pcov

- name: Checkout solarium
uses: actions/checkout@v2

- name: Start Solr ${{ matrix.solr }} in ${{ matrix.mode }} mode
run: |
cd tests/Integration/Fixtures/docker/solr${{ matrix.solr }}_${{ matrix.mode }}
docker-compose up -d
- name: Install dependencies
run: |
composer global require hirak/prestissimo
composer require --dev symfony/event-dispatcher:${{ matrix.symfony }}
- name: Run tests
env:
COVERALLS_RUN_LOCALLY: 1
COVERALLS_REPO_TOKEN:
run: |
vendor/bin/phpstan analyze src/ tests/ --level=1
vendor/bin/phpunit -c phpunit.xml --exclude-group skip_for_solr_${{ matrix.mode }} -v
vendor/bin/php-coveralls -v --dry-run
59 changes: 0 additions & 59 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions phpunit.xml.dist → phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
backupStaticAttributes="false"
colors="true"
>

<testsuites>
<testsuite name="Solarium">
<directory suffix="Test.php">tests</directory>
Expand All @@ -23,4 +24,5 @@
<directory suffix=".php">src</directory>
</whitelist>
</filter>

</phpunit>
26 changes: 0 additions & 26 deletions phpunit.xml.travis

This file was deleted.

95 changes: 95 additions & 0 deletions tests/Integration/AbstractCloudTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

namespace Solarium\Tests\Integration;

use Solarium\Core\Client\State\ClusterState;

/**
* Abstract base class.
*/
abstract class AbstractCloudTest extends AbstractTechproductsTest
{

protected static function createTechproducts(): void
{
self::$config = [
'endpoint' => [
'localhost' => [
'host' => '127.0.0.1',
'port' => 8983,
'path' => '/',
'collection' => self::$name,
],
],
];

self::$client = TestClientFactory::createWithPsr18Adapter(self::$config);

$collectionsQuery = self::$client->createCollections();

// create core with unique name using the techproducts configset
$createAction = $collectionsQuery->createCreate();
$createAction->setName(self::$name)
->setCollectionConfigName('techproducts')
->setNumShards(2);
$collectionsQuery->setAction($createAction);
$response = self::$client->collections($collectionsQuery);
static::assertTrue($response->getWasSuccessful());
}

public static function tearDownAfterClass(): void
{
$collectionsQuery = self::$client->createCollections();

// now we delete the collection we created in setUpBeforeClass()
$deleteAction = $collectionsQuery->createDelete();
$deleteAction->setName(self::$name);
$collectionsQuery->setAction($deleteAction);
$response = self::$client->collections($collectionsQuery);
static::assertTrue($response->getWasSuccessful());
}

public function testCreateDelete()
{
$collectionsQuery = self::$client->createCollections();

$action = $collectionsQuery->createCreate();
$action->setName('test');
$action->setNumShards(1);
$collectionsQuery->setAction($action);
$result = self::$client->collections($collectionsQuery);
$this->assertTrue($result->getWasSuccessful());

$action = $collectionsQuery->createDelete();
$action->setName('test');
$collectionsQuery->setAction($action);
$result = self::$client->collections($collectionsQuery);
$this->assertTrue($result->getWasSuccessful());
}

public function testReload()
{
$collectionsQuery = self::$client->createCollections();

$action = $collectionsQuery->createReload();
$action->setName(self::$name);
$collectionsQuery->setAction($action);
$result = self::$client->collections($collectionsQuery);
$this->assertTrue($result->getWasSuccessful());
}

public function testClusterStatus()
{
$collectionsQuery = self::$client->createCollections();

$action = $collectionsQuery->createClusterStatus();
$collectionsQuery->setAction($action);
$result = self::$client->collections($collectionsQuery);
$this->assertTrue($result->getWasSuccessful());
$clusterState = $result->getClusterState();
$this->assertSame(ClusterState::class, get_class($clusterState));
$this->assertCount(2, $clusterState->getLiveNodes());
$this->assertCount(1, $clusterState->getCollections());
$this->assertTrue($clusterState->collectionExists(self::$name));
}
}
88 changes: 0 additions & 88 deletions tests/Integration/AbstractCollectionsTest.php

This file was deleted.

Loading

0 comments on commit 11bcd88

Please sign in to comment.