Skip to content

Commit e0bef4b

Browse files
author
Thomas Jarrand
committed
Added linting + test menu builder
1 parent 520741c commit e0bef4b

14 files changed

Lines changed: 537 additions & 28 deletions

File tree

.github/workflow/ci.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: 'CI'
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
11+
lint:
12+
name: 'Lint'
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
16+
steps:
17+
- name: 'Checkout'
18+
uses: actions/checkout@v2
19+
20+
- name: 'Setup PHP'
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
coverage: "none"
24+
extensions: "json"
25+
ini-values: "memory_limit=-1"
26+
php-version: "8.0"
27+
28+
- name: 'Determine composer cache directory'
29+
id: composer-cache
30+
run: echo "::set-output name=directory::$(composer config cache-dir)"
31+
32+
- name: 'Cache composer dependencies'
33+
uses: actions/cache@v2
34+
with:
35+
path: ${{ steps.composer-cache.outputs.directory }}
36+
key: 7.4-composer-${{ hashFiles('**/composer.lock') }}
37+
restore-keys: 7.4-composer-
38+
39+
- name: 'Install dependencies'
40+
id: deps
41+
run: |
42+
echo "::group::composer update"
43+
composer update --no-progress --ansi
44+
echo "::endgroup::"
45+
46+
echo "::group::install phpunit"
47+
# Required for PhpStan
48+
vendor/bin/simple-phpunit install
49+
echo "::endgroup::"
50+
51+
- name: 'Composer validate'
52+
if: always() && steps.deps.outcome == 'success'
53+
run: composer validate --strict
54+
55+
- name: 'PHP CS Fixer'
56+
if: always() && steps.deps.outcome == 'success'
57+
run: vendor/bin/php-cs-fixer fix --dry-run --diff
58+
59+
- name: 'PhpStan'
60+
if: always() && steps.deps.outcome == 'success'
61+
run: vendor/bin/phpstan analyse
62+
63+
tests:
64+
name: 'Tests'
65+
runs-on: ubuntu-latest
66+
timeout-minutes: 5
67+
68+
strategy:
69+
fail-fast: false # don't cancel other matrix jobs on failure
70+
matrix:
71+
php: [ '7.4', '8.0' ]
72+
73+
steps:
74+
- name: 'Checkout'
75+
uses: actions/checkout@v2
76+
77+
- name: 'Setup PHP'
78+
uses: shivammathur/setup-php@v2
79+
with:
80+
coverage: "none"
81+
extensions: "json"
82+
ini-values: "memory_limit=-1"
83+
php-version: "${{ matrix.php }}"
84+
85+
- name: 'Determine composer cache directory'
86+
id: composer-cache
87+
run: echo "::set-output name=directory::$(composer config cache-dir)"
88+
89+
- name: 'Cache composer dependencies'
90+
uses: actions/cache@v2
91+
with:
92+
path: ${{ steps.composer-cache.outputs.directory }}
93+
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
94+
restore-keys: ${{ matrix.php }}-composer-
95+
96+
- name: 'Fixup Composer'
97+
if: matrix.php == 8.0
98+
run: |
99+
echo "::group::Fixup Composer platform config for third-parties deps not PHP 8 ready yet"
100+
composer config platform.php 7.4.99
101+
echo "::endgroup::"
102+
103+
- name: 'Install dependencies'
104+
run: |
105+
echo "::group::composer update"
106+
composer update --no-progress --ansi
107+
echo "::endgroup::"
108+
109+
echo "::group::install phpunit"
110+
vendor/bin/simple-phpunit install
111+
echo "::endgroup::"
112+
113+
- name: 'Run tests'
114+
run: vendor/bin/simple-phpunit --testdox
115+

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1+
###> symfony/phpunit-bridge ###
2+
.phpunit
3+
.phpunit.result.cache
4+
/phpunit.xml
5+
###< symfony/phpunit-bridge ######
6+
7+
###> friendsofphp/php-cs-fixer ###
8+
/.php-cs-fixer.php
9+
/.php-cs-fixer.cache
10+
###< friendsofphp/php-cs-fixer ###
11+
112
/vendor/
213
composer.lock

.php-cs-fixer.dist.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())->in([
4+
__DIR__
5+
]);
6+
7+
return (new PhpCsFixer\Config())
8+
->setFinder($finder)
9+
->setCacheFile('.php-cs-fixer.cache') // forward compatibility with 3.x line
10+
->setRiskyAllowed(true)
11+
->setRules([
12+
'@PSR12' => true,
13+
'@Symfony' => true,
14+
'strict_param' => true,
15+
'array_syntax' => ['syntax' => 'short'],
16+
'concat_space' => ['spacing' => 'one'],
17+
'declare_strict_types' => true,
18+
'native_function_invocation' => ['include' => ['@compiler_optimized']],
19+
'no_superfluous_phpdoc_tags' => true,
20+
'ordered_imports' => true,
21+
'phpdoc_annotation_without_dot' => false,
22+
'phpdoc_order' => true,
23+
'phpdoc_summary' => false,
24+
'simplified_null_return' => false,
25+
'single_line_throw' => false,
26+
'void_return' => true,
27+
'yoda_style' => false,
28+
])
29+
;

DependencyInjection/ElaoAdminThemeExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Elao\Bundle\AdminThemeBundle\DependencyInjection;
46

57
use Symfony\Component\Config\FileLocator;
68
use Symfony\Component\DependencyInjection\ContainerBuilder;
79
use Symfony\Component\DependencyInjection\Extension\Extension;
810
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
9-
use Symfony\Component\HttpFoundation\RequestStack;
10-
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1111

1212
class ElaoAdminThemeExtension extends Extension
1313
{
14-
public function load(array $configs, ContainerBuilder $container)
14+
public function load(array $configs, ContainerBuilder $container): void
1515
{
1616
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
1717
$loader->load('services.xml');

ElaoAdminThemeBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Elao\Bundle\AdminThemeBundle;
46

57
use Symfony\Component\HttpKernel\Bundle\Bundle;

Makefile

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,64 @@
1+
.SILENT:
2+
3+
## Colors
4+
COLOR_RESET = \033[0m
5+
COLOR_INFO = \033[32m
6+
COLOR_COMMENT = \033[33m
7+
8+
## Help
9+
help:
10+
printf "${COLOR_COMMENT}Usage:${COLOR_RESET}\n"
11+
printf " make [target]\n\n"
12+
printf "${COLOR_COMMENT}Available targets:${COLOR_RESET}\n"
13+
awk '/^[a-zA-Z\-\_0-9\.@]+:/ { \
14+
helpMessage = match(lastLine, /^## (.*)/); \
15+
if (helpMessage) { \
16+
helpCommand = substr($$1, 0, index($$1, ":")); \
17+
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
18+
printf " ${COLOR_INFO}%-16s${COLOR_RESET} %s\n", helpCommand, helpMessage; \
19+
} \
20+
} \
21+
{ lastLine = $$0 }' $(MAKEFILE_LIST)
22+
123
###########
224
# Install #
325
###########
426

27+
## Install dependencies
528
install:
6-
composer install
29+
composer update
730

831
########
932
# Lint #
1033
########
1134

12-
lint: lint-twig
35+
## Run code style checks
36+
lint: lint.php-cs-fixer lint.phpstan lint.composer lint.twig
37+
38+
lint.php-cs-fixer:
39+
vendor/bin/php-cs-fixer fix
40+
41+
lint.phpstan:
42+
vendor/bin/phpstan analyse .
43+
44+
lint.composer:
45+
composer validate --strict
1346

14-
lint-twig:
47+
lint.twig:
1548
php bin/lint.twig.php Resources/views
49+
50+
############
51+
# Security #
52+
############
53+
54+
# Run Symfony security check
55+
security.symfony:
56+
symfony check:security
57+
58+
########
59+
# Test #
60+
########
61+
62+
## Run tests
63+
test:
64+
vendor/bin/simple-phpunit

0 commit comments

Comments
 (0)