Skip to content

Commit ddc9742

Browse files
authored
chore: setup monorepo isolation rules (api-platform#6081)
adds phparkitect
1 parent 456e74f commit ddc9742

File tree

7 files changed

+123
-3
lines changed

7 files changed

+123
-3
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,46 @@ jobs:
3131
echo '{}' > package.json
3232
npm install --no-fund --no-audit @commitlint/config-conventional @commitlint/cli
3333
echo $commit | ./node_modules/.bin/commitlint -g .commitlintrc
34+
35+
architecture:
36+
name: Check components interdependencies
37+
runs-on: ubuntu-latest
38+
timeout-minutes: 20
39+
strategy:
40+
matrix:
41+
php:
42+
- '8.3'
43+
fail-fast: false
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v3
47+
- name: Setup PHP
48+
uses: shivammathur/setup-php@v2
49+
with:
50+
php-version: ${{ matrix.php }}
51+
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
52+
ini-values: memory_limit=-1
53+
tools: pecl, composer
54+
coverage: none
55+
- name: Download PHPArkitect PHAR
56+
run: |
57+
wget -q https://github.com/phparkitect/arkitect/releases/latest/download/phparkitect.phar
58+
chmod +x phparkitect.phar
59+
- name: Get composer cache directory
60+
id: composercache
61+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
62+
- name: Cache dependencies
63+
uses: actions/cache@v3
64+
with:
65+
path: ${{ steps.composercache.outputs.dir }}
66+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
67+
restore-keys: ${{ runner.os }}-composer-
68+
- name: Update project dependencies
69+
run: |
70+
composer update --no-interaction --no-progress --ansi
71+
- name: Run PHPArkitect
72+
run: ./phparkitect.phar check
73+
3474
php-cs-fixer:
3575
name: PHP CS Fixer (PHP ${{ matrix.php }})
3676
runs-on: ubuntu-latest

phparkitect-baseline.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"violations": [
3+
],
4+
"stopOnFailure": false
5+
}

phparkitect.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
use Arkitect\ClassSet;
15+
use Arkitect\CLI\Config;
16+
use Arkitect\RuleBuilders\Architecture\Architecture;
17+
18+
return static function (Config $config): void {
19+
$classSet = ClassSet::fromDir(__DIR__.'/src')
20+
->excludePath('*/vendor/*')
21+
->excludePath('*/Tests/*');
22+
23+
$config->add($classSet, ...Architecture::withComponents()
24+
->component('DoctrineCommon')->definedBy('ApiPlatform\Doctrine\Common\*')
25+
->component('Documentation')->definedBy('ApiPlatform\Documentation\*')
26+
->component('Elasticsearch')->definedBy('ApiPlatform\Elasticsearch\*')
27+
->component('GraphQl')->definedBy('ApiPlatform\GraphQl\*')
28+
->component('HttpCache')->definedBy('ApiPlatform\HttpCache\*')
29+
->component('Hydra')->definedBy('ApiPlatform\Hydra\*')
30+
->component('JsonLd')->definedBy('ApiPlatform\JsonLd\*')
31+
->component('JsonSchema')->definedBy('ApiPlatform\JsonSchema\*')
32+
->component('Metadata')->definedBy('ApiPlatform\Metadata\*')
33+
->component('OpenApi')->definedBy('ApiPlatform\OpenApi\*')
34+
->component('ParameterValidator')->definedBy('ApiPlatform\ParameterValidator\*')
35+
->component('RamseyUuid')->definedBy('ApiPlatform\RamseyUuid\*')
36+
->component('Serializer')->definedBy('ApiPlatform\Serializer\*')
37+
->component('State')->definedBy('ApiPlatform\State\*')
38+
->component('Symfony')->definedBy('ApiPlatform\Symfony\*')
39+
->component('Validator')->definedBy('ApiPlatform\Validator\*')
40+
41+
->where('DoctrineCommon')->mayDependOnComponents('Metadata', 'State')
42+
->where('Documentation')->mayDependOnComponents('Metadata', 'OpenApi', 'State')
43+
->where('Elasticsearch')->mayDependOnComponents('Metadata', 'Serializer', 'State')
44+
->where('GraphQl')->mayDependOnComponents('Metadata', 'Serializer', 'State', 'Validator')
45+
->where('HttpCache')->mayDependOnComponents('Metadata', 'State')
46+
->where('Hydra')->mayDependOnComponents('Metadata', 'State', 'JsonLd', 'Serializer', 'JsonSchema')
47+
->where('JsonLd')->mayDependOnComponents('Metadata', 'State', 'Serializer')
48+
->where('JsonSchema')->mayDependOnComponents('Metadata')
49+
->where('OpenApi')->mayDependOnComponents('JsonSchema', 'Metadata', 'State')
50+
->where('RamseyUuid')->mayDependOnComponents('Metadata')
51+
->where('Serializer')->mayDependOnComponents('Metadata', 'State')
52+
->where('Symfony')->mayDependOnComponents(
53+
'Documentation',
54+
'GraphQl',
55+
'Metadata',
56+
'State',
57+
'Validator',
58+
'Serializer',
59+
'JsonSchema',
60+
'JsonLd',
61+
'OpenApi',
62+
'ParameterValidator',
63+
'HttpCache',
64+
'Elasticsearch'
65+
)
66+
->where('Validator')->mayDependOnComponents('Metadata')
67+
68+
->rules()
69+
);
70+
};

src/Documentation/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
],
2222
"require": {
2323
"api-platform/openapi": "*@dev || ^3.1",
24-
"api-platform/metadata": "*@dev || ^3.1"
24+
"api-platform/metadata": "*@dev || ^3.1",
25+
"api-platform/state": "*@dev || ^3.1"
2526
},
2627
"require-dev": {
2728
"sebastian/comparator": "<5.0"

src/GraphQl/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"api-platform/metadata": "*@dev || ^3.1",
2525
"api-platform/serializer": "*@dev || ^3.1",
2626
"api-platform/state": "*@dev || ^3.1",
27+
"api-platform/validator": "*@dev || ^3.1",
2728
"symfony/property-info": "^6.1",
2829
"symfony/serializer": "^6.1",
2930
"webonyx/graphql-php": "^14.0 || ^15.0",

src/Hydra/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
"php": ">=8.1",
3131
"api-platform/state": "*@dev || ^3.1",
3232
"api-platform/metadata": "*@dev || ^3.1",
33-
"api-platform/jsonld": "*@dev || ^3.1"
33+
"api-platform/jsonld": "*@dev || ^3.1",
34+
"api-platform/json-schema": "*@dev || ^3.1",
35+
"api-platform/serializer": "*@dev || ^3.1"
3436
},
3537
"require-dev": {
3638
"sebastian/comparator": "<5.0"

src/JsonLd/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"require": {
3030
"php": ">=8.1",
3131
"api-platform/state": "*@dev || ^3.1",
32-
"api-platform/metadata": "*@dev || ^3.1"
32+
"api-platform/metadata": "*@dev || ^3.1",
33+
"api-platform/serializer": "*@dev || ^3.1"
3334
},
3435
"require-dev": {
3536
"sebastian/comparator": "<5.0"

0 commit comments

Comments
 (0)