Skip to content

Commit

Permalink
Merge remote-tracking branch 'ibexa/main' into merge-bump-php-req
Browse files Browse the repository at this point in the history
  • Loading branch information
konradoboza committed Dec 14, 2021
2 parents 6687402 + cec1300 commit 88cbefd
Show file tree
Hide file tree
Showing 37 changed files with 337 additions and 222 deletions.
16 changes: 16 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
| Question | Answer
| ---------------------------------------- | ------------------
| **JIRA issue** | [IBX-XXXX](https://issues.ibexa.co/browse/IBX-XXXX)
| **Type** | feature/bug/improvement
| **Target Ibexa version** | `v4.x` - please update `x` accordingly
| **BC breaks** | yes/no

<!-- Replace this comment with Pull Request description -->

#### Checklist:
- [ ] Provided PR description.
- [ ] Tested the solution manually.
- [ ] Provided automated test coverage.
- [ ] Checked that target branch is set correctly (master for features, the oldest supported for bugs).
- [ ] Ran PHP CS Fixer for new PHP code (use `$ composer fix-cs`).
- [ ] Asked for a review (ping `@ibexa/engineering`).
105 changes: 105 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: CI

on:
push:
branches:
- main
- '[0-9]+.[0-9]+'
pull_request: ~

jobs:
tests:
name: Tests on SQLite
runs-on: "ubuntu-20.04"
timeout-minutes: 10
continue-on-error: ${{ matrix.experimental }}

strategy:
fail-fast: false
matrix:
php:
- '7.4'
composer_options: [ "" ]
experimental: [false]
include:
- php: '8.0'
composer_options: "--ignore-platform-req php"
experimental: true

steps:
- uses: actions/checkout@v2

- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: pdo_sqlite, gd
tools: cs2pr

- uses: "ramsey/composer-install@v1"
with:
dependency-versions: "highest"
composer-options: "${{ matrix.composer_options }}"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run code style check
run: composer run-script check-cs -- --format=checkstyle | cs2pr

- name: Run test suite on SQLite
run: composer run-script --timeout=600 test

mysql-tests:
name: Tests on MySQL
services:
mysql:
image: mysql:8.0
ports:
- 3306/tcp
env:
MYSQL_RANDOM_ROOT_PASSWORD: true
MYSQL_USER: mysql
MYSQL_PASSWORD: mysql
MYSQL_DATABASE: testdb
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
runs-on: "ubuntu-20.04"
timeout-minutes: 60
continue-on-error: ${{ matrix.experimental }}

strategy:
fail-fast: false
matrix:
experimental: [ false ]
php:
- '7.4'
composer_options: [ "" ]

steps:
- uses: actions/checkout@v2

- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: pdo_mysql, gd
tools: cs2pr

- uses: "ramsey/composer-install@v1"
with:
dependency-versions: "highest"
composer-options: "${{ matrix.composer_options }}"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run integration test suite vs MySQL
run: composer run-script test
env:
MYSQL_DATABASE_URL: "mysql://mysql:[email protected]:${{ job.services.mysql.ports[3306] }}/testdb"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor
/.php_cs.cache
/.php-cs-fixer.cache
/composer.lock
/.phpunit.result.cache
17 changes: 17 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

use Ibexa\CodeStyle\PhpCsFixer\InternalConfigFactory;

$finder = PhpCsFixer\Finder::create()
->in([__DIR__ . '/src', __DIR__ . '/tests'])
->files()->name('*.php');

return InternalConfigFactory::build()
->setFinder($finder)
;
11 changes: 0 additions & 11 deletions .php_cs

This file was deleted.

53 changes: 0 additions & 53 deletions .travis.yml

This file was deleted.

28 changes: 10 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,46 @@ It introduces custom Yaml format for schema definition and provides autowired AP

## Schema Builder

Provided by APIs defined on the `\EzSystems\DoctrineSchema\API\SchemaImporter` interface,
Provided by APIs defined on the `\Ibexa\Contracts\DoctrineSchema\SchemaImporterInterface` interface,
imports given Yaml source string or Yaml file into `\Doctrine\DBAL\Schema` object.

## Schema Exporter

Provided by APIs defined on the `\EzSystems\DoctrineSchema\API\SchemaExporter` interface,
Provided by APIs defined on the `\Ibexa\Contracts\DoctrineSchema\SchemaExporterInterface` interface,
exports given `\Doctrine\DBAL\Schema` object to the custom Yaml format.

## SchemaBuilder

Provided by APIs defined on the `\EzSystems\DoctrineSchema\API\Builder\SchemaBuilder` interface,
is an extensibility point to be used by Symfony-based projects.
Provided by APIs defined on the `\Ibexa\Contracts\DoctrineSchema\Builder\SchemaBuilderInterface`
interface, is an extensibility point to be used by Symfony-based projects.

The `SchemaBuilder` is event-driven. To hook into the process of building schema, a custom `EventSubscriber` is required, e.g.

```php
use EzSystems\DoctrineSchema\API\Event\SchemaBuilderEvent;
use EzSystems\DoctrineSchema\API\Event\SchemaBuilderEvents;
use Ibexa\Contracts\DoctrineSchema\Event\SchemaBuilderEvent;
use Ibexa\Contracts\DoctrineSchema\SchemaBuilderEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class BuildSchemaSubscriber implements EventSubscriberInterface
{
/**
* @var string
*/
private $schemaFilePath;
private string $schemaFilePath;

public function __construct(string $schemaFilePath)
{
$this->schemaFilePath = $schemaFilePath;
}

/**
* Returns an array of events this subscriber wants to listen to.
*
* @return string[]
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
SchemaBuilderEvents::BUILD_SCHEMA => ['onBuildSchema', 200],
];
}

/**
* @param \EzSystems\DoctrineSchema\API\Builder\SchemaBuilderEvent $event
*/
public function onBuildSchema(SchemaBuilderEvent $event)
public function onBuildSchema(SchemaBuilderEvent $event): void
{
$event
->getSchemaBuilder()
Expand All @@ -70,7 +62,7 @@ Schema provided in this way can be imported into Schema object by e.g.:
$this->schemaBuilder = $schemaBuilder;
}

public function importSchema()
public function importSchema(): void
{
$schema = $this->schemaBuilder->buildSchema();
// ...
Expand Down
38 changes: 19 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
{
"name": "ezsystems/doctrine-dbal-schema",
"name": "ibexa/doctrine-schema",
"description": "Abstraction layer, on top of Doctrine, for cross-DBMS schema import",
"type": "ezplatform-bundle",
"type": "ibexa-bundle",
"license": "GPL-2.0-only",
"replace": {
"ezsystems/doctrine-dbal-schema": "*"
},
"require": {
"php": "^7.3 || ^8.0",
"doctrine/dbal": "^2.10",
"symfony/config": "^5.0",
"symfony/dependency-injection": "^5.0",
"symfony/http-kernel": "^5.0",
"symfony/yaml": "^5.0"
"php": "^7.4 || ^8.0",
"doctrine/dbal": "^2.13",
"symfony/config": "^5.3",
"symfony/dependency-injection": "^5.3",
"symfony/http-kernel": "^5.3",
"symfony/yaml": "^5.3"
},
"require-dev": {
"ezsystems/ezplatform-code-style": "^0.4.0",
"friendsofphp/php-cs-fixer": "^2.16",
"ibexa/code-style": "^1.0",
"phpunit/phpunit": "^8.5"
},
"autoload": {
"psr-4": {
"Ibexa\\DoctrineSchema\\": "src/lib/",
"Ibexa\\Bundle\\DoctrineSchema\\": "src/bundle/",
"Ibexa\\Contracts\\DoctrineSchema\\": "src/contracts/",
"EzSystems\\DoctrineSchemaBundle\\": "src/bundle",
"EzSystems\\DoctrineSchema\\": "src/lib"
}
},
"autoload-dev": {
"psr-4": {
"EzSystems\\Tests\\DoctrineSchema\\": "tests/lib"
"Ibexa\\Tests\\DoctrineSchema\\": "tests/lib/"
}
},
"scripts": {
"fix-cs": "@php ./vendor/bin/php-cs-fixer fix -v --show-progress=estimating",
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
"check-cs": "@fix-cs --diff --dry-run",
"test": "@php ./vendor/bin/phpunit -vc phpunit.xml"
},
"extra": {
"_ezplatform_branch_for_behat_tests": "3.0",
"branch-alias": {
"dev-master": "1.0.x-dev",
"dev-tmp_ci_branch": "1.0.x-dev"
},
"thanks": {
"name": "ezsystems/ezplatform",
"url": "https://github.com/ezsystems/ezplatform"
"dev-main": "4.0.x-dev"
}
}
}
8 changes: 5 additions & 3 deletions src/bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
*/
declare(strict_types=1);

namespace EzSystems\DoctrineSchemaBundle\DependencyInjection;
namespace Ibexa\Bundle\DoctrineSchema\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* Symfony extension configuration definition for ez_doctrine_schema extension.
* Symfony's extension configuration definition for ibexa_doctrine_schema extension.
*/
class Configuration implements ConfigurationInterface
{
Expand All @@ -21,7 +21,7 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('ez_doctrine_schema');
$treeBuilder = new TreeBuilder(DoctrineSchemaExtension::EXTENSION_NAME);

$rootNode = $treeBuilder->getRootNode();
$rootNode
Expand All @@ -40,3 +40,5 @@ public function getConfigTreeBuilder(): TreeBuilder
return $treeBuilder;
}
}

class_alias(Configuration::class, 'EzSystems\DoctrineSchemaBundle\DependencyInjection\Configuration');
Loading

0 comments on commit 88cbefd

Please sign in to comment.