-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) fixed the tests + (feat) added castor tooling and a Symfony bridge
* added castor and some tooling * updated tests * added a Symfony bundle for easy configuration
- Loading branch information
1 parent
8306969
commit 04ab340
Showing
139 changed files
with
4,082 additions
and
433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of JoliCode's "markdown fixer" project. | ||
* | ||
* (c) JoliCode <coucou@jolicode.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace qa; | ||
|
||
use Castor\Attribute\AsOption; | ||
use Castor\Attribute\AsTask; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
use function Castor\get_context; | ||
use function Castor\run; | ||
|
||
#[AsTask(description: 'Runs all QA tasks')] | ||
function all(): void | ||
{ | ||
install(); | ||
cs(false); | ||
phpstan(); | ||
rector(); | ||
phpunit(); | ||
} | ||
|
||
#[AsTask(description: 'Installs tooling')] | ||
function install(): void | ||
{ | ||
run('composer install --working-dir tools/php-cs-fixer'); | ||
run('composer install --working-dir tools/phpstan'); | ||
run('composer install --working-dir tools/phpunit'); | ||
run('composer install --working-dir tools/rector'); | ||
} | ||
|
||
#[AsTask(description: 'Fix coding standards')] | ||
function cs( | ||
#[AsOption(name: 'dry-run', description: 'Do not make changes and outputs diff', mode: InputOption::VALUE_NONE)] | ||
bool $dryRun, | ||
): int { | ||
$command = 'tools/php-cs-fixer/vendor/bin/php-cs-fixer fix'; | ||
|
||
if ($dryRun) { | ||
$command .= ' --dry-run --diff'; | ||
} | ||
|
||
$c = get_context() | ||
->withAllowFailure(true) | ||
; | ||
|
||
return run($command, context: $c)->getExitCode(); | ||
} | ||
|
||
#[AsTask(description: 'Run the phpstan analysis')] | ||
function phpstan(): int | ||
{ | ||
return run('tools/phpstan/vendor/bin/phpstan analyse')->getExitCode(); | ||
} | ||
|
||
#[AsTask(description: 'Run the phpunit tests')] | ||
function phpunit(): int | ||
{ | ||
$c = get_context() | ||
->withAllowFailure(true) | ||
; | ||
|
||
return run('tools/phpunit/vendor/bin/simple-phpunit', context: $c)->getExitCode(); | ||
} | ||
|
||
#[AsTask(description: 'Run the rector upgrade')] | ||
function rector(): int | ||
{ | ||
return run('tools/rector/vendor/bin/rector process')->getExitCode(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Continuous Integration | ||
|
||
'on': | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
ci: | ||
name: Run the tests suite | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: | ||
- '8.1' | ||
- '8.2' | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '${{ matrix.php-versions }}' | ||
extensions: mbstring, dom | ||
tools: jolicode/castor | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate --strict | ||
|
||
- name: Install dependencies | ||
run: castor install | ||
|
||
- | ||
name: Install quality tools | ||
run: castor qa:install | ||
|
||
- | ||
name: Check coding standards | ||
run: castor qa:cs --dry-run | ||
|
||
- | ||
name: Run PHPStan | ||
run: castor qa:phpstan | ||
|
||
- | ||
name: Run tests | ||
run: castor qa:phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
/.phpunit.result.cache | ||
/composer.lock | ||
/vendor/ | ||
|
||
/.castor.stub.php | ||
|
||
# tools dependencies | ||
tools/*/vendor/ | ||
|
||
###> symfony/phpunit-bridge ### | ||
.phpunit.result.cache | ||
/phpunit.xml | ||
###< symfony/phpunit-bridge ### | ||
|
||
###> friendsofphp/php-cs-fixer ### | ||
/.php-cs-fixer.php | ||
/.php-cs-fixer.cache | ||
###< friendsofphp/php-cs-fixer ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of JoliCode's "markdown fixer" project. | ||
* | ||
* (c) JoliCode <coucou@jolicode.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
$finder = (new PhpCsFixer\Finder()) | ||
->ignoreVCSIgnored(true) | ||
->ignoreDotFiles(false) | ||
->in(__DIR__) | ||
->append([ | ||
__FILE__, | ||
]) | ||
; | ||
|
||
$header = <<<'EOF' | ||
This file is part of JoliCode's "markdown fixer" project. | ||
(c) JoliCode <coucou@jolicode.com> | ||
For the full copyright and license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
EOF; | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@PHP81Migration' => true, | ||
'@Symfony' => true, | ||
'@Symfony:risky' => true, | ||
'concat_space' => ['spacing' => 'one'], | ||
'header_comment' => ['header' => $header], | ||
'ordered_class_elements' => true, // Symfony(PSR12) override the default value, but we don't want | ||
'blank_line_before_statement' => true, // Symfony(PSR12) override the default value, but we don't want | ||
'phpdoc_to_comment' => ['ignored_tags' => ['var']], | ||
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']], | ||
]) | ||
->setFinder($finder) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2023 JoliCode | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is furnished | ||
to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of JoliCode's "markdown fixer" project. | ||
* | ||
* (c) JoliCode <coucou@jolicode.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Castor\Attribute\AsTask; | ||
|
||
use function Castor\import; | ||
use function Castor\run; | ||
|
||
import(__DIR__ . '/.castor'); | ||
|
||
#[AsTask(description: 'Installs the application (composer, yarn, ...)')] | ||
function install(): void | ||
{ | ||
run('composer install -n --prefer-dist --optimize-autoloader'); | ||
} |
Oops, something went wrong.