feat(drupal): allow for disabling quality checks

For Commerce Kickstart, there are no custom modules so these checks will
fail in the CI pipeline.
This commit is contained in:
Oliver Davies 2023-10-18 20:38:53 +02:00
parent f58846ef20
commit 696aa5d617
3 changed files with 32 additions and 3 deletions

View file

@ -73,7 +73,6 @@ final class CreateListOfFilesToGenerate
new TemplateFile(data: 'drupal/.hadolint.yaml', name: '.hadolint.yaml'),
new TemplateFile(data: 'drupal/Dockerfile', name: 'Dockerfile'),
new TemplateFile(data: 'drupal/docker-compose.yaml', name: 'docker-compose.yaml'),
new TemplateFile(data: 'drupal/phpstan.neon.dist', name: 'phpstan.neon.dist'),
new TemplateFile(data: 'drupal/run', name: 'run'),
]);
@ -86,8 +85,18 @@ final class CreateListOfFilesToGenerate
));
}
$filesToGenerate->push(new TemplateFile(data: 'drupal/phpcs.xml.dist', name: 'phpcs.xml.dist'));
$filesToGenerate->push(new TemplateFile(data: 'drupal/phpunit.xml.dist', name: 'phpunit.xml.dist'));
if ($configurationDataDto->php['phpcs'] !== false) {
$filesToGenerate->push(new TemplateFile(data: 'drupal/phpcs.xml.dist', name: 'phpcs.xml.dist'));
}
if ($configurationDataDto->php['phpstan'] !== false) {
$filesToGenerate->push(new TemplateFile(data: 'drupal/phpstan.neon.dist', name: 'phpstan.neon.dist'));
}
if ($configurationDataDto->php['phpunit'] !== false) {
$filesToGenerate->push(new TemplateFile(data: 'drupal/phpunit.xml.dist', name: 'phpunit.xml.dist'));
}
$filesToGenerate->push(new TemplateFile(
data: 'drupal/docker-entrypoint-php',
name: 'docker-entrypoint-php',

View file

@ -59,4 +59,6 @@ final class Config
#[Assert\NotBlank]
public ?string $projectRoot;
public array $php;
}

View file

@ -21,9 +21,13 @@ function ci:test {
composer install --quiet --no-progress
{% if not php.phpcs is same as false %}
test --testdox
{% endif %}
{% if not php.phpcs is same as false and not php.phpstan is same as false %}
quality
{% endif %}
}
# Run a command within the php container.
@ -31,9 +35,11 @@ function cmd {
docker compose exec php "${@}"
}
{% if not php.phpcs is same as false %}
function coding-standards {
cmd phpcs "${@}"
}
{% endif %}
function composer {
_exec php composer "${@}"
@ -65,10 +71,16 @@ function lint:dockerfile {
hadolint/hadolint hadolint --ignore DL3008 --ignore DL3059 -t style "${@}" - < Dockerfile
}
{% if not php.phpcs is same as false and not php.phpstan is same as false %}
function quality {
{% if not php.phpcs is same as false %}
coding-standards
{% endif %}
{% if not php.phpstan is same as false %}
static-analysis
{% endif %}
}
{% endif %}
function start {
cp -v --no-clobber .env.example .env
@ -76,22 +88,28 @@ function start {
docker compose up -d
}
{% if not php.phpstan is same as false %}
function static-analysis {
cmd phpstan --memory-limit=-1 --no-progress "${@}"
}
{% endif %}
function stop {
docker compose down
}
{% if not php.phpunit is same as false %}
function test {
_exec php phpunit --colors=always "${@}"
}
{% endif %}
function test:commit {
{% if not php.phpunit is same as false %}
test --testdox --testsuite functional
test --testdox --testsuite kernel
test --testdox --testsuite unit
{% endif %}
quality
}