Skip to content
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

Run unit tests on github action #1882

Merged
merged 4 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
52 changes: 51 additions & 1 deletion .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Continuous integration'
on: ['push', 'pull_request']
jobs:
cs:
runs-on: 'ubuntu-latest'
runs-on: 'ubuntu-20.04'
name: 'Coding style'
steps:
- name: 'Checkout'
Expand All @@ -21,3 +21,53 @@ jobs:

- name: 'Check composer.json'
run: 'composer-normalize --diff --dry-run --indent-size=4 --indent-style=space --no-update-lock'

phpunit:
runs-on: 'ubuntu-20.04'
name: 'PHPUnit (PHP ${{ matrix.php }}, ES ${{ matrix.elasticsearch }})'
timeout-minutes: 5
strategy:
matrix:
include:
- php: '7.2'
elasticsearch: '7.1.1'
- php: '7.2'
elasticsearch: '7.2.1'
- php: '7.3'
elasticsearch: '7.3.2'
- php: '7.4'
elasticsearch: '7.3.2'
- php: '8.0'
elasticsearch: '7.3.2'
composer_flags: '--ignore-platform-reqs'
fail-fast: false
steps:
- name: 'Checkout'
uses: 'actions/checkout@v2'

- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '${{ matrix.php }}'
coverage: 'none'
tools: 'pecl, composer:v2'
extensions: 'curl, json, mbstring, openssl'

- name: 'Get composer cache directory'
id: 'composer_cache'
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'

- name: 'Cache dependencies'
uses: 'actions/cache@v2'
with:
path: '${{ steps.composer_cache.outputs.dir }}'
key: '${{ runner.os }}-composer-php${{ matrix.php }}-${{ hashFiles(''**/composer.json'') }}'
restore-keys: |
${{ runner.os }}-composer-php${{ matrix.php }}-
${{ runner.os }}-composer-

- name: 'Update dependencies'
run: 'composer update --prefer-dist --no-interaction --no-progress --ansi ${{ matrix.composer_flags }}'

- name: 'Run tests'
run: 'vendor/bin/phpunit --group unit'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just running unit test for the moment as booting a functional stack is more complicated. Will be done in a following PR if you don't mind.

11 changes: 9 additions & 2 deletions tests/Aggregation/TermsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Elastica\Query;

/**
* @group functional
*
* @internal
*/
class TermsTest extends BaseAggregationTest
Expand Down Expand Up @@ -73,6 +71,9 @@ public function testExcludeExactMatch(): void
$this->assertSame(['first', 'second'], $agg->getParam('exclude'));
}

/**
* @group functional
*/
public function testTermsAggregation(): void
{
$agg = new Terms('terms');
Expand All @@ -86,6 +87,9 @@ public function testTermsAggregation(): void
$this->assertEquals('blue', $results['buckets'][0]['key']);
}

/**
* @group functional
*/
public function testTermsSetOrder(): void
{
$agg = new Terms('terms');
Expand All @@ -99,6 +103,9 @@ public function testTermsSetOrder(): void
$this->assertEquals('blue', $results['buckets'][2]['key']);
}

/**
* @group functional
*/
public function testTermsSetOrders(): void
{
$agg = new Terms('terms');
Expand Down
6 changes: 3 additions & 3 deletions tests/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,20 @@ protected function _isUnitGroup()
{
$groups = TestUtil::getGroups(\get_class($this), $this->getName(false));

return \in_array('unit', $groups);
return \in_array('unit', $groups, true);
}

protected function _isFunctionalGroup()
{
$groups = TestUtil::getGroups(\get_class($this), $this->getName(false));

return \in_array('functional', $groups);
return \in_array('functional', $groups, true);
}

protected function _isBenchmarkGroup()
{
$groups = TestUtil::getGroups(\get_class($this), $this->getName(false));

return \in_array('benchmark', $groups);
return \in_array('benchmark', $groups, true);
}
}
5 changes: 4 additions & 1 deletion tests/BasePipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class BasePipeline extends BaseTest
{
protected function tearDown(): void
{
$this->_createPipeline()->deletePipeline('*');
if ($this->_isFunctionalGroup()) {
$this->_createPipeline()->deletePipeline('*');
}

parent::tearDown();
}

Expand Down
Loading