Skip to content
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
214 changes: 214 additions & 0 deletions .github/workflows/backend-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
name: Backend build

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

jobs:
cs-fix:
name: Run code style check
runs-on: "ubuntu-22.04"
strategy:
matrix:
php:
- '8.1'
steps:
- uses: actions/checkout@v4

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

- name: Add composer keys for private packagist
run: |
composer config http-basic.updates.ibexa.co $IBEXA_KEY $IBEXA_TOKEN
composer config github-oauth.github.com $GITHUB_TOKEN
env:
IBEXA_KEY: ${{ secrets.IBEXA_KEY }}
IBEXA_TOKEN: ${{ secrets.IBEXA_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: ramsey/composer-install@v2
with:
dependency-versions: "highest"

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

deptrac:
name: Deptrac
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deptrac
uses: smoench/deptrac-action@master

tests:
name: Tests
runs-on: "ubuntu-22.04"
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
php:
- '8.2'
- '8.3'

steps:
- uses: actions/checkout@v4

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

- name: Add composer keys for private packagist
run: |
composer config http-basic.updates.ibexa.co $IBEXA_KEY $IBEXA_TOKEN
composer config github-oauth.github.com $GITHUB_TOKEN
env:
IBEXA_KEY: ${{ secrets.IBEXA_KEY }}
IBEXA_TOKEN: ${{ secrets.IBEXA_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: ramsey/composer-install@v2

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

- name: Run PHPStan analysis
run: composer run-script phpstan

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

integration-tests-postgres:
name: PostgreSQL integration tests
needs: tests
services:
postgres:
image: postgres:14
ports:
- 5432
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: testdb
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--tmpfs /var/lib/postgres
runs-on: "ubuntu-22.04"
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
php:
- '8.2'
- '8.3'

steps:
- uses: actions/checkout@v4

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

- name: Add composer keys for private packagist
run: |
composer config http-basic.updates.ibexa.co $IBEXA_KEY $IBEXA_TOKEN
composer config github-oauth.github.com $GITHUB_TOKEN
env:
IBEXA_KEY: ${{ secrets.IBEXA_KEY }}
IBEXA_TOKEN: ${{ secrets.IBEXA_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: ramsey/composer-install@v2
with:
dependency-versions: "highest"

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

- name: Run integration test suite vs Postgresql
run: composer run-script --timeout=600 test-integration
env:
DATABASE_URL: "pgsql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/testdb?server_version=10"

integration-tests-mysql:
name: MySQL integration tests
needs: tests
services:
mysql:
image: mysql:8
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
--tmpfs=/var/lib/mysql
runs-on: "ubuntu-22.04"
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
php:
- '8.2'
- '8.3'

steps:
- uses: actions/checkout@v4

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

- name: Add composer keys for private packagist
run: |
composer config http-basic.updates.ibexa.co $IBEXA_KEY $IBEXA_TOKEN
composer config github-oauth.github.com $GITHUB_TOKEN
env:
IBEXA_KEY: ${{ secrets.IBEXA_KEY }}
IBEXA_TOKEN: ${{ secrets.IBEXA_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: ramsey/composer-install@v2
with:
dependency-versions: "highest"

- 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 --timeout=600 test-integration
env:
DATABASE_URL: "mysql://mysql:mysql@127.0.0.1:${{ job.services.mysql.ports[3306] }}/testdb"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
/package-lock.json
/yarn.lock
vendor
.idea
.idea
/.deptrac.cache
/.php-version
34 changes: 34 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);


use AdamWojs\PhpCsFixerPhpdocForceFQCN\Fixer\Phpdoc\ForceFQCNFixer;

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

return (new PhpCsFixer\Config())
->registerCustomFixers([
new ForceFQCNFixer(),
])
->setRules([
'AdamWojs/phpdoc_force_fqcn_fixer' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
'property' => 'one',
],
],
'class_definition' => [
'single_item_single_line' => true,
'inline_constructor_arguments' => false,
],
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
])
->setFinder(
$finder
);

27 changes: 26 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"symfony/yaml": "^5.4"
},
"require-dev": {
"dama/doctrine-test-bundle": "^v6.7",
"ibexa/admin-ui": "~4.6",
"ibexa/code-style": "~2.0.0",
"ibexa/content-forms": "~4.6",
Expand All @@ -54,9 +55,26 @@
"ibexa/personalization": "~4.6",
"ibexa/product-catalog": "~4.6",
"ibexa/rest": "~4.6",
"ibexa/scheduler": "^4.6",
"ibexa/search": "~4.6",
"ibexa/taxonomy": "~4.6",
"ibexa/twig-components": "~4.6"
"ibexa/test-core": "4.6.x-dev",
"ibexa/twig-components": "~4.6",
"ibexa/version-comparison": "^4.6",
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^9",
"qossmic/deptrac-shim": "^0.24.0 || ^1.0.2"
},
"scripts": {
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php --show-progress=dots --allow-risky=yes",
"check-cs": "@fix-cs --dry-run",
"test": "phpunit -c phpunit.xml.dist",
"test-integration": "phpunit -c phpunit.integration.xml",
"phpstan": "phpstan analyse -c phpstan.neon",
"deptrac": "php vendor/bin/deptrac analyse"
},
"extra": {
"branch-alias": {
Expand All @@ -70,6 +88,13 @@
"CodeRhapsodie\\ConnectorGemini\\": "src/lib/"
}
},
"autoload-dev": {
"psr-4": {
"CodeRhapsodie\\Tests\\Bundle\\ConnectorGemini\\": "tests/bundle/",
"CodeRhapsodie\\Tests\\Integration\\ConnectorGemini\\": "tests/integration/",
"CodeRhapsodie\\Tests\\ConnectorGemini\\": "tests/lib/"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
Expand Down
26 changes: 26 additions & 0 deletions deptrac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
deptrac:
paths:
- ./src
layers:
- name: Bundle
collectors:
- type: directory
value: bundle/.*
- name: Contracts
collectors:
- type: directory
value: contracts/.*
- name: Library
collectors:
- type: directory
value: lib/.*
ruleset:
Bundle:
- Bundle
- Contracts
- Library
Contracts:
- Contracts
Library:
- Contracts
- Library
7 changes: 7 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
ignoreErrors:
-
message: '#^Class CodeRhapsodie\\Bundle\\ConnectorGemini\\Form\\Type\\AbstractActionConfigurationOptions extends generic class Symfony\\Component\\Form\\AbstractType but does not specify its types\: TData$#'
identifier: missingType.generics
count: 1
path: src/bundle/Form/Type/AbstractActionConfigurationOptions.php
10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- phpstan-baseline.neon

parameters:
level: 8
paths:
- src
- tests
21 changes: 21 additions & 0 deletions phpunit.integration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="tests/bootstrap.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnWarning="true"
verbose="true">
<php>
<env name="DATABASE_URL" value="sqlite://i@i/var/test.db" />
<env name="KERNEL_CLASS" value="CodeRhapsodie\Tests\Integration\ConnectorGemini\Kernel" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=4&amp;max[direct]=0&amp;verbose=0"/>
</php>
<testsuites>
<testsuite name="integration">
<directory>tests/integration/</directory>
</testsuite>
</testsuites>
<extensions>
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>
</phpunit>
20 changes: 20 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnWarning="true"
colors="true">
<testsuites>
<testsuite name="bundle">
<directory>tests/bundle</directory>
</testsuite>
<testsuite name="lib">
<directory>tests/lib</directory>
</testsuite>
</testsuites>
</phpunit>
Loading