Skip to content

Commit

Permalink
Update docker infrastructure and dependencies (#294)
Browse files Browse the repository at this point in the history
* Update infrastructure

* Update dependencies

* Update tools
  • Loading branch information
pyrech authored Oct 10, 2024
1 parent 6fbcc13 commit 764599d
Show file tree
Hide file tree
Showing 35 changed files with 3,108 additions and 2,216 deletions.
511 changes: 511 additions & 0 deletions .castor/docker.php

Large diffs are not rendered by default.

161 changes: 0 additions & 161 deletions .castor/infra.php

This file was deleted.

56 changes: 38 additions & 18 deletions .castor/qa.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,61 @@

use Castor\Attribute\AsTask;

use function Castor\io;
use function Castor\variable;
use function docker\docker_compose_run;
use function docker\docker_exit_code;

#[AsTask(description: 'Runs all QA tasks')]
function all(): void
function all(): int
{
install();
cs();
phpstan();
phpunit();
$cs = cs();
$phpstan = phpstan();
$phpunit = phpunit();

return max($cs, $phpstan, $phpunit);
}

#[AsTask(description: 'Installs tooling')]
function install(): void
{
docker_compose_run('composer install --working-dir tools/php-cs-fixer');
docker_compose_run('composer install --working-dir tools/phpstan');
io()->title('Installing QA tooling');

docker_compose_run('composer install -o', workDir: '/var/www/tools/php-cs-fixer');
docker_compose_run('composer install -o', workDir: '/var/www/tools/phpstan');
}

#[AsTask(description: 'Runs PHPStan')]
function phpstan(): void
#[AsTask(description: 'Runs PHPUnit', aliases: ['phpunit'])]
function phpunit(): int
{
docker_compose_run('bin/console about --env=test'); // to create the cache
docker_compose_run('phpstan');
return docker_exit_code('vendor/bin/simple-phpunit');
}

#[AsTask(description: 'Runs PHPUnit')]
function phpunit(): void
#[AsTask(description: 'Runs PHPStan', aliases: ['phpstan'])]
function phpstan(): int
{
docker_compose_run('bin/phpunit');
if (!is_dir(variable('root_dir') . '/tools/phpstan/vendor')) {
io()->error('PHPStan is not installed. Run `castor qa:install` first.');

return 1;
}

return docker_exit_code('phpstan', workDir: '/var/www');
}

#[AsTask(description: 'Fixes Coding Style')]
function cs(bool $dryRun = false): void
#[AsTask(description: 'Fixes Coding Style', aliases: ['cs'])]
function cs(bool $dryRun = false): int
{
if (!is_dir(variable('root_dir') . '/tools/php-cs-fixer/vendor')) {
io()->error('PHP-CS-Fixer is not installed. Run `castor qa:install` first.');

return 1;
}

if ($dryRun) {
docker_compose_run('php-cs-fixer fix --dry-run --diff');
} else {
docker_compose_run('php-cs-fixer fix');
return docker_exit_code('php-cs-fixer fix --dry-run --diff', workDir: '/var/www');
}

return docker_exit_code('php-cs-fixer fix', workDir: '/var/www');
}
Loading

0 comments on commit 764599d

Please sign in to comment.