Skip to content

Commit

Permalink
Introduce OpenSearch 2.x fixtures (#48)
Browse files Browse the repository at this point in the history
New:

Create OpenSearch 2.x data fixtures, providing the same set of functionalities as int the Elasticsearch fixtures:
  - File fixtures
  - Directory Loader fixtures:
    - Array Directory fixtures
    - Json Directory fixtures
  - Adapter
  - Executor
  - Purger
- Add tests to the new type
- Add documentation

Other changes

- Add code quality tools in the library (Rector and PHPStan)
- Run those tools in the CI pipeline
- Replace deprecated SonarCloud action with latest SonarQube Scan action to perform Sonar checks
  • Loading branch information
hugo-goncalves-kununu authored Jan 23, 2025
1 parent c41d2df commit aae6010
Showing 46 changed files with 1,541 additions and 64 deletions.
39 changes: 36 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -11,9 +11,41 @@ env:
fail-fast: true

jobs:
checks:
name: Code Checks
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none

- name: Install Composer Dependencies
uses: ramsey/composer-install@v3
with:
dependency-versions: "highest"
composer-options: "--prefer-stable --optimize-autoloader --no-progress --no-interaction"

- name: Run PHP CS Fixer
run: vendor/bin/php-cs-fixer check --using-cache=no --config vendor/kununu/scripts/src/PHP/CodeStandards/Scripts/php_cs src/ tests/

- name: Run Rector
run: vendor/bin/rector process --ansi --dry-run --config rector-ci.php src/ tests/

- name: Run PHPStan
run: vendor/bin/phpstan analyse --ansi

build:
needs: checks
name: PHPUnit
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
@@ -39,7 +71,7 @@ jobs:
composer-options: "--prefer-stable"

- name: Run PHPUnit
run: vendor/bin/phpunit --log-junit tests/.results/tests-junit.xml --coverage-clover tests/.results/tests-clover.xml
run: vendor/bin/phpunit --colors=always --testdox --log-junit tests/.results/tests-junit.xml --coverage-clover tests/.results/tests-clover.xml

- name: Upload coverage files
uses: actions/upload-artifact@v4
@@ -50,6 +82,7 @@ jobs:

sonarcloud:
needs: build
name: SonarCloud Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -69,7 +102,7 @@ jobs:
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' tests-junit.xml
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@v3.0.0
uses: SonarSource/sonarqube-scan-action@v4.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ Currently, this package supports the following types of fixtures:
- *[Doctrine DBAL Connection Fixtures](docs/FixtureTypes/doctrine-dbal-connection-fixtures.md)* which relies on [Doctrine DBAL](https://github.com/doctrine/dbal) by using the [Connection](https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Connection.php) implementation
- *[Cache Pool Fixtures](docs/FixtureTypes/cache-pool-fixtures.md)* which relies on implementations of the [PSR-6](https://github.com/php-fig/cache) standard
- *[Elasticsearch Fixtures](docs/FixtureTypes/elasticsearch.md)* which relies on the [Elasticsearch-PHP client](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html)
- *[OpenSearch Fixtures](docs/FixtureTypes/opensearch.md)* which relies on the [OpenSearch PHP client](https://opensearch.org/docs/latest/clients/php/)
- *[Symfony Http Client Fixtures](docs/FixtureTypes/symfony-http-client.md)* which relies on the [Symfony Http Client](https://github.com/symfony/http-client) and [Symfony Http Foundation](https://github.com/symfony/http-foundation).

Also check [Directory Loader](docs/FixtureTypes/directory-loader.md) to check how to load fixtures from files in a directory.
@@ -42,6 +43,7 @@ In order to enable the fixture types that you are interested, check out their do
- [Doctrine DBAL Connection Fixtures](docs/FixtureTypes/doctrine-dbal-connection-fixtures.md)
- [Cache Pool Fixtures](docs/FixtureTypes/cache-pool-fixtures.md)
- [Elasticsearch Fixtures](docs/FixtureTypes/elasticsearch.md)
- [OpenSearch Fixtures](docs/FixtureTypes/opensearch.md)
- [Symfony Http Client Fixtures](docs/FixtureTypes/symfony-http-client.md)

--------------------
16 changes: 13 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
"data fixtures",
"Doctrine",
"Elasticsearch",
"Opensearch",
"PSR-6 Cache"
],
"authors": [
@@ -29,15 +30,20 @@
"doctrine/dbal": "^3.9",
"elasticsearch/elasticsearch": "^7.1",
"kununu/scripts": ">=5.1",
"phpunit/phpunit": "^11.3",
"opensearch-project/opensearch-php": "^2.0",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^11.5",
"psr/cache": "^2.0",
"rector/rector": "^2.0",
"symfony/http-client": "^6.4",
"symfony/http-foundation": "^6.4"
},
"suggest": {
"psr/cache": "Load fixtures for implementation of the PSR6 standard",
"doctrine/dbal": "Load fixtures using Doctrine DBAL",
"elasticsearch/elasticsearch": "Load fixtures with Elasticsearch",
"opensearch-project/opensearch-php": "Load fixtures with Openseach",
"kununu/testing-bundle": "Use this package in a Symfony application",
"symfony/http-client": "Load fixtures with mocked data for Symfony Http client",
"symfony/http-foundation": "Load fixtures with mocked data for Symfony Http client"
@@ -54,11 +60,15 @@
},
"scripts": {
"test": "phpunit --no-coverage --no-logging --no-progress",
"test-coverage": "XDEBUG_MODE=coverage phpunit --log-junit tests/.results/tests-junit.xml --coverage-clover tests/.results/tests-clover.xml --coverage-html tests/.results/html"
"test-coverage": "XDEBUG_MODE=coverage phpunit --log-junit tests/.results/tests-junit.xml --coverage-clover tests/.results/tests-clover.xml --coverage-html tests/.results/html",
"phpstan": "phpstan",
"rector": "rector process --dry-run --config rector-ci.php src/ tests/"
},
"scripts-descriptions": {
"test": "Run all tests",
"test-coverage": "Run all tests with coverage report"
"test-coverage": "Run all tests with coverage report",
"rector": "Run Rector in dry-run mode with CI rules",
"phpstan": "Run PHPStan"
},
"config": {
"sort-packages": true,
Loading

0 comments on commit aae6010

Please sign in to comment.