Skip to content

Commit

Permalink
chore: add deptrac
Browse files Browse the repository at this point in the history
  • Loading branch information
mtarld committed Sep 5, 2022
1 parent 2b47746 commit ec5ea45
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@
/.php-cs-fixer.php
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###

###> qossmic/deptrac-shim ###
/.deptrac_bc.cache
/.deptrac_hexa.cache
###< qossmic/deptrac-shim ###
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ psalm:
phpunit:
@$(EXEC) bin/phpunit

# TODO
# Run layers depedencies analysis
# deptrac:
# @echo "\n\e[7mChecking DDD layers...\e[0m"
# @$(EXEC) tools/vendor/bin/deptrac analyze --fail-on-uncovered --report-uncovered --no-progress --cache-file tools/.deptrac_ddd.cache tools/depfile_ddd.yaml
#
# @echo "\n\e[7mChecking Bounded context layers...\e[0m"
# @$(EXEC) tools/vendor/bin/deptrac analyze --fail-on-uncovered --report-uncovered --no-progress --cache-file tools/.deptrac_bc.cache tools/depfile_bc.yaml
## Run layers depedencies analysis
deptrac:
@echo "\n\e[7mChecking Bounded contexts...\e[0m"
@$(EXEC) vendor/bin/deptrac analyze --fail-on-uncovered --report-uncovered --no-progress --cache-file .deptrac_bc.cache --config-file deptrac_bc.yaml

@echo "\n\e[7mChecking Hexagonal layers...\e[0m"
@$(EXEC) vendor/bin/deptrac analyze --fail-on-uncovered --report-uncovered --no-progress --cache-file .deptrac_hexa.cache --config-file deptrac_hexa.yaml

## Run either static analysis and tests
ci: php-cs-fixer psalm phpunit
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"friendsofphp/php-cs-fixer": "^3.11",
"justinrainbow/json-schema": "^5.2",
"phpunit/phpunit": "^9.5",
"qossmic/deptrac-shim": "^0.24.0",
"symfony/browser-kit": "6.1.*",
"symfony/css-selector": "6.1.*",
"symfony/debug-bundle": "6.1.*",
Expand Down
55 changes: 54 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions deptrac_bc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
parameters:
paths: [ ./src ]

layers:
- name: BookStore
collectors:
- type: directory
regex: src/BookStore/.*

- name: Shared
collectors:
- type: directory
regex: src/Shared/.*

- name: Vendors
collectors:
- { type: className, regex: ^ApiPlatform\\ }
- { type: className, regex: ^Symfony\\ }
- { type: className, regex: ^Doctrine\\ }
- { type: className, regex: ^Webmozart\\ }

ruleset:
BookStore: [ Shared, Vendors ]
Shared: [ Vendors ]
51 changes: 51 additions & 0 deletions deptrac_hexa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
parameters:
paths: [ ./src ]

layers:
- name: Domain
collectors:
- type: directory
regex: .+/Domain/.*

- name: Application
collectors:
- type: directory
regex: .+/Application/.*

- name: Infrastructure
collectors:
- type: directory
regex: .+/Infrastructure/.*

- name: Vendors
collectors:
- { type: className, regex: ^ApiPlatform\\ }
- { type: className, regex: ^Symfony\\(?!(Component\\Uid\\)) }
- { type: className, regex: ^Doctrine\\(?!(ORM\\Mapping)) }
- { type: className, regex: ^Webmozart\\(?!Assert\\Assert) }

- name: Attributes
collectors:
- { type: className, regex: ^Doctrine\\ORM\\Mapping }

- name: Helpers
collectors:
- { type: className, regex: ^Symfony\\Component\\Uid\\ }
- { type: className, regex: ^Webmozart\\Assert\\Assert }

ruleset:
Domain:
- Helpers
- Attributes

Application:
- Domain
- Helpers
- Attributes

Infrastructure:
- Domain
- Application
- Vendors
- Helpers
- Attributes
12 changes: 12 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@
"psr/log": {
"version": "3.0.0"
},
"qossmic/deptrac-shim": {
"version": "0.24",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "0.19",
"ref": "3c3daab46226c37fc14e10faf81df737a3039d96"
},
"files": [
"deptrac.yaml"
]
},
"symfony/asset": {
"version": "v6.0.3"
},
Expand Down

0 comments on commit ec5ea45

Please sign in to comment.