Skip to content

Commit 10e873a

Browse files
committed
[Kocal/SymfonyAppPack] Add recipe
1 parent 3428e6b commit 10e873a

File tree

18 files changed

+653
-0
lines changed

18 files changed

+653
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "composer" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
defaults:
4+
run:
5+
shell: bash
6+
7+
on:
8+
pull_request:
9+
types: [ opened, synchronize, reopened, ready_for_review ]
10+
push:
11+
branches:
12+
- main
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
qa:
20+
if: ${{ ! github.event.pull_request.draft }}
21+
name: Quality Assurance
22+
timeout-minutes: 10
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
extensions: ctype, iconv, mbstring
32+
tools: symfony
33+
34+
- name: Start Docker containers
35+
run: docker compose up -d --wait
36+
37+
- name: Install project
38+
run: make app.install
39+
40+
- name: QA
41+
run: make qa
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
$ruleset = new TwigCsFixer\Ruleset\Ruleset();
4+
$ruleset->addStandard(new TwigCsFixer\Standard\Symfony());
5+
6+
$config = new TwigCsFixer\Config\Config();
7+
$config->setCacheFile(__DIR__.'/tools/.cache/twig-cs-fixer');
8+
$config->setRuleset($ruleset);
9+
10+
return $config;
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
2+
include $(ROOT_DIR)/tools/make/text.mk
3+
include $(ROOT_DIR)/tools/make/help.mk
4+
include $(ROOT_DIR)/tools/make/os.mk
5+
include $(ROOT_DIR)/tools/make/git.mk
6+
7+
.DEFAULT_GOAL := help
8+
9+
# Executables
10+
SF := symfony
11+
SF_PROXY = $(shell $(SF) local:proxy:url)
12+
SF_CONSOLE := $(SF) console
13+
PHP := $(SF) php
14+
COMPOSER := $(SF) composer
15+
16+
UID := $(shell id -u)
17+
GID := $(shell id -g)
18+
DC := USER_ID=$(UID) GROUP_ID=$(GID) docker compose --env-file /dev/null
19+
20+
## Install everything needed to start the project
21+
install:
22+
$(SF) local:server:ca:install
23+
$(MAKE) start
24+
$(MAKE) app.install
25+
26+
## Start the environment
27+
start:
28+
$(DC) up -d
29+
$(SF) proxy:start
30+
$(SF) serve
31+
32+
## Stop the environment
33+
stop:
34+
$(DC) kill
35+
36+
## Stop and delete the environment and project data (database, logs, etc.)
37+
delete:
38+
$(DC) down -v --remove-orphans
39+
40+
## App - Install the application
41+
app.install:
42+
@$(call action, Installing PHP dependencies...)
43+
$(COMPOSER) install --prefer-dist
44+
45+
@$(call action, Running DB migrations...)
46+
$(SF_CONSOLE) doctrine:migrations:migrate --no-interaction --all-or-nothing
47+
48+
## App - Install the application (alias to "make app.install")
49+
app.update: app.install
50+
51+
######
52+
# QA #
53+
######
54+
55+
## QA - Run all QA checks
56+
qa: archi refactor cs lint phpstan test
57+
58+
## QA - Run all QA checks and fix issues
59+
qa.fix: archi refactor.fix cs.fix lint.fix phpstan test
60+
61+
#########
62+
# Archi #
63+
#########
64+
65+
## Architecture - Run architecture checks
66+
archi: archi.back
67+
68+
## Architecture - Run architecture checks for backend
69+
archi.back:
70+
$(PHP) vendor/bin/deptrac --report-uncovered --fail-on-uncovered
71+
72+
############
73+
# Refactor #
74+
############
75+
76+
## Refactor - Run all refactor checks
77+
refactor: refactor.back
78+
79+
## Refactor - Run all refactor checks and fix issues
80+
refactor.fix: refactor.back.fix
81+
82+
## Refactor - Run refactor checks for backend
83+
refactor.back:
84+
$(PHP) vendor/bin/rector process --dry-run
85+
86+
## Refactor - Run refactor checks for backend and fix issues
87+
refactor.back.fix:
88+
$(PHP) vendor/bin/rector process
89+
90+
################
91+
# Coding style #
92+
################
93+
94+
## Coding style - Run all coding style checks
95+
cs: cs.back cs.front
96+
97+
## Coding style - Run all coding style checks and fix issues
98+
cs.fix: cs.back.fix cs.front.fix
99+
100+
## Coding style - Check backend coding style
101+
cs.back:
102+
$(PHP) vendor/bin/ecs check
103+
$(PHP) vendor/bin/twig-cs-fixer
104+
105+
## Coding style - Check backend coding style and fix issues
106+
cs.back.fix:
107+
$(PHP) vendor/bin/ecs check --fix
108+
$(PHP) vendor/bin/twig-cs-fixer --fix
109+
110+
## Coding style - Check frontend coding style
111+
cs.front: bin/oxfmt
112+
bin/oxfmt --check
113+
114+
## Coding style - Check frontend coding style and fix issues
115+
cs.front.fix: bin/oxfmt
116+
bin/oxfmt
117+
118+
bin/oxfmt:
119+
@$(call action, Downloading oxfmt...)
120+
$(SF_CONSOLE) oxc:download:oxfmt
121+
@$(call success, oxfmt downloaded successfully)
122+
123+
##########
124+
# Linter #
125+
##########
126+
127+
## Linter - Run all linters
128+
lint: lint.back lint.front
129+
130+
## Linter - Run all linters and fix issues
131+
lint.fix: lint.back lint.front.fix
132+
133+
## Linter - Run linters for backend
134+
lint.back:
135+
$(SF_CONSOLE) lint:container
136+
$(SF_CONSOLE) lint:xliff translations
137+
$(SF_CONSOLE) lint:yaml --parse-tags config
138+
$(SF_CONSOLE) lint:twig templates
139+
#$(SF_CONSOLE) doctrine:schema:validate
140+
141+
## Linter - Lint front files
142+
lint.front: bin/oxlint
143+
bin/oxlint
144+
145+
## Linter - Lint front files and fix issues
146+
lint.front.fix: bin/oxlint
147+
bin/oxlint --fix
148+
149+
bin/oxlint:
150+
@$(call action, Downloading oxlint...)
151+
$(SF_CONSOLE) oxc:download:oxlint
152+
153+
###########
154+
# PHPStan #
155+
###########
156+
157+
## PHPStan - Run PHPStan
158+
phpstan:
159+
$(PHP) vendor/bin/phpstan analyse
160+
161+
## PHPStan - Run PHPStan and update the baseline
162+
phpstan.generate-baseline:
163+
$(PHP) vendor/bin/phpstan analyse --generate-baseline
164+
165+
#########
166+
# Tests #
167+
#########
168+
169+
## Tests - Run all tests
170+
test: test.back
171+
172+
## Tests - Run backend tests
173+
test.back:
174+
$(PHP) vendor/bin/phpunit
175+
## Tests - Run backend tests with coverage
176+
177+
test.back.coverage:
178+
$(PHP) vendor/bin/phpunit --coverage-html .cache/phpunit/coverage-html
179+
180+
-include $(ROOT_DIR)/Makefile.local
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Local targets that should not be committed to git

kocal/symfony-app-pack/1.0/ecs.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Symplify\EasyCodingStandard\Config\ECSConfig;
6+
7+
return ECSConfig::configure()
8+
->withParallel()
9+
->withCache(__DIR__ . '/tools/.cache/ecs')
10+
->withPaths([
11+
__DIR__ . '/assets',
12+
__DIR__ . '/config',
13+
__DIR__ . '/public',
14+
__DIR__ . '/src',
15+
__DIR__ . '/tests',
16+
__DIR__ . '/tools',
17+
])
18+
->withSkip([
19+
__DIR__ . '/tools/.cache',
20+
__DIR__ . '/config/bundles.php',
21+
__DIR__ . '/config/reference.php',
22+
])
23+
->withPreparedSets(
24+
psr12: true,
25+
common: true,
26+
strict: true,
27+
cleanCode: true,
28+
)
29+
;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"copy-from-recipe": {
3+
".github/": ".github/",
4+
"tools/": "tools/",
5+
".twig-cs-fixer.php": ".twig-cs-fixer.php",
6+
"ecs.php": "ecs.php",
7+
"Makefile": "Makefile",
8+
"Makefile.local": "Makefile.local",
9+
"php.ini": "php.ini",
10+
"phpstan.dist.neon": "phpstan.dist.neon",
11+
"rector.php": "rector.php"
12+
},
13+
"gitignore": [
14+
"/Makefile.local"
15+
]
16+
}

kocal/symfony-app-pack/1.0/php.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
memory_limit = -1
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
includes:
2+
- vendor/kocal/phpstan-symfony-ux/extension.neon
3+
- vendor/phpstan/phpstan-symfony/extension.neon
4+
- vendor/phpstan/phpstan-doctrine/extension.neon
5+
- tools/phpstan/symfony-configuration.php
6+
7+
parameters:
8+
level: 9
9+
paths:
10+
- bin/
11+
- config/
12+
- public/
13+
- src/
14+
- tools/
15+
- tests/
16+
excludePaths:
17+
- config/reference.php
18+
- tools/.cache
19+
20+
tmpDir: tools/.cache/phpstan
21+
22+
symfony:
23+
consoleApplicationLoader: tools/phpstan/console-application.php
24+
25+
doctrine:
26+
objectManagerLoader: tools/phpstan/object-manager.php
27+
28+
rules:
29+
- Kocal\PHPStanSymfonyUX\Rules\TwigComponent\ClassMustBeFinalRule
30+
- Kocal\PHPStanSymfonyUX\Rules\TwigComponent\ClassNameMustNotEndWithComponentRule
31+
- Kocal\PHPStanSymfonyUX\Rules\TwigComponent\ForbiddenAttributesPropertyRule
32+
- Kocal\PHPStanSymfonyUX\Rules\TwigComponent\ForbiddenClassPropertyRule
33+
- Kocal\PHPStanSymfonyUX\Rules\TwigComponent\MethodsVisibilityRule
34+
- Kocal\PHPStanSymfonyUX\Rules\TwigComponent\PostMountMethodSignatureRule
35+
- Kocal\PHPStanSymfonyUX\Rules\TwigComponent\PreMountMethodSignatureRule
36+
- Kocal\PHPStanSymfonyUX\Rules\TwigComponent\PublicPropertiesMustBeCamelCaseRule
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Symfony\CodeQuality\Rector\Class_\ControllerMethodInjectionToConstructorRector;
7+
8+
return RectorConfig::configure()
9+
->withParallel()
10+
->withCache(__DIR__ . '/tools/.cache/rector')
11+
->withPaths([
12+
__DIR__ . '/config',
13+
__DIR__ . '/public',
14+
__DIR__ . '/src',
15+
__DIR__ . '/tests',
16+
__DIR__ . '/tools',
17+
])
18+
->withPhpSets()
19+
->withPreparedSets(
20+
deadCode: true,
21+
codeQuality: true,
22+
codingStyle: true,
23+
typeDeclarations: true,
24+
privatization: true,
25+
instanceOf: true,
26+
earlyReturn: true,
27+
phpunitCodeQuality: true,
28+
doctrineCodeQuality: true,
29+
symfonyCodeQuality: true,
30+
)
31+
->withSkip([
32+
__DIR__ . '/config/bundles.php',
33+
__DIR__ . '/config/reference.php',
34+
__DIR__ . '/tools/.cache',
35+
ControllerMethodInjectionToConstructorRector::class,
36+
])
37+
;

0 commit comments

Comments
 (0)