Skip to content

Commit

Permalink
Add configuration for Test Kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Jan 4, 2022
1 parent 992e513 commit 3104010
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 1 deletion.
12 changes: 12 additions & 0 deletions config/projects.yaml
Expand Up @@ -76,6 +76,7 @@ admin-bundle:
sonata-project/block-bundle: ['3.*']

block-bundle:
has_test_kernel: false
branches:
5.x:
php: ['7.3', '7.4', '8.0', '8.1']
Expand All @@ -91,6 +92,7 @@ block-bundle:
symfony/symfony: ['4.4.*']

cache:
has_test_kernel: false
phpstan: false
psalm: false
excluded_files:
Expand All @@ -103,6 +105,7 @@ cache:
php: ['7.3', '7.4', '8.0', '8.1']

cache-bundle:
has_test_kernel: false
branches:
4.x:
php: ['7.3', '7.4', '8.0', '8.1']
Expand Down Expand Up @@ -134,6 +137,7 @@ classification-bundle:
symfony/symfony: ['4.4.*']

datagrid-bundle:
has_test_kernel: false
branches:
4.x:
php: ['7.3', '7.4', '8.0', '8.1']
Expand Down Expand Up @@ -192,6 +196,7 @@ entity-audit-bundle:
excluded_files:
- README.md
has_documentation: false
has_test_kernel: false
branches:
2.x:
php: ['7.3', '7.4', '8.0', '8.1']
Expand All @@ -206,6 +211,7 @@ entity-audit-bundle:

exporter:
documentation_badge_slug: sonata-project-exporter
has_test_kernel: false
branches:
3.x:
php: ['7.3', '7.4', '8.0', '8.1']
Expand All @@ -220,6 +226,7 @@ exporter:

formatter-bundle:
psalm: false
has_test_kernel: false
branches:
5.x:
php: ['7.4', '8.0', '8.1']
Expand All @@ -235,6 +242,7 @@ formatter-bundle:
sonata-project/block-bundle: ['3.*']

form-extensions:
has_test_kernel: false
branches:
2.x:
php: ['7.3', '7.4', '8.0', '8.1']
Expand All @@ -251,13 +259,15 @@ google-authenticator:
excluded_files:
- README.md
has_documentation: false
has_test_kernel: false
branches:
3.x:
php: ['7.3', '7.4', '8.0', '8.1']
2.x:
php: ['7.3', '7.4', '8.0', '8.1']

intl-bundle:
has_test_kernel: false
branches:
3.x:
php: ['7.3', '7.4', '8.0', '8.1']
Expand Down Expand Up @@ -293,6 +303,7 @@ media-bundle:
notification-bundle:
custom_doctor_rst_whitelist_part:
" - 'resource: \"@NelmioApiDocBundle/Resources/config/routing.yml\"'"
has_test_kernel: false
branches:
4.x:
php: ['7.3', '7.4', '8.0']
Expand All @@ -319,6 +330,7 @@ page-bundle:
sonata-project/block-bundle: ['3.*']

seo-bundle:
has_test_kernel: false
branches:
4.x:
php: ['7.4', '8.0', '8.1']
Expand Down
7 changes: 7 additions & 0 deletions src/Command/Dispatcher/DispatchBranchesProtectionCommand.php
Expand Up @@ -167,6 +167,13 @@ private function buildRequiredStatusChecks(Project $project, Branch $branch): ar
$requiredStatusChecks[] = 'Webpack Encore';
}

if ($project->hasTestKernel()) {
$requiredStatusChecks[] = 'Symfony container';
$requiredStatusChecks[] = 'Twig files';
$requiredStatusChecks[] = 'XLIFF files';
$requiredStatusChecks[] = 'YML files';
}

/** @var PhpVersion $phpVersion */
foreach ($branch->phpVersions() as $phpVersion) {
$requiredStatusChecks[] = sprintf(
Expand Down
5 changes: 5 additions & 0 deletions src/Command/Dispatcher/DispatchFilesCommand.php
Expand Up @@ -287,6 +287,11 @@ private function deleteNotNeededFilesAndDirs(Project $project, Branch $branch, s
$filesToRemove[] = '.symfony.bundle.yaml';
}

if (!$project->hasTestKernel()) {
$filesToRemove[] = 'bin/console';
$filesToRemove[] = '.github/workflows/symfony-lint.yaml';
}

foreach ($filesToRemove as $fileToRemove) {
$file = u($distPath)
->append('/')
Expand Down
1 change: 1 addition & 0 deletions src/Config/ProjectsConfiguration.php
Expand Up @@ -42,6 +42,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->scalarNode('custom_gitattributes_part')->defaultNull()->end()
->scalarNode('custom_doctor_rst_whitelist_part')->defaultNull()->end()
->booleanNode('has_documentation')->defaultTrue()->end()
->booleanNode('has_test_kernel')->defaultTrue()->end()
->scalarNode('documentation_badge_slug')->defaultNull()->end()
->arrayNode('branches')
->normalizeKeys(false)
Expand Down
9 changes: 9 additions & 0 deletions src/Domain/Value/Project.php
Expand Up @@ -43,6 +43,7 @@ final class Project
private array $phpunitExtensions;

private bool $hasDocumentation;
private bool $hasTestKernel;
private bool $phpstan;
private bool $psalm;
private ?string $customGitignorePart;
Expand All @@ -59,6 +60,7 @@ private function __construct(
array $excludedFiles,
array $phpunitExtensions,
bool $hasDocumentation,
bool $hasTestKernel,
bool $phpstan,
bool $psalm,
?string $customGitignorePart,
Expand All @@ -73,6 +75,7 @@ private function __construct(
$this->package = $package;
$this->branches = $branches;
$this->hasDocumentation = $hasDocumentation;
$this->hasTestKernel = $hasTestKernel;
$this->phpstan = $phpstan;
$this->psalm = $psalm;
$this->excludedFiles = $excludedFiles;
Expand Down Expand Up @@ -109,6 +112,7 @@ public static function fromValues(string $name, array $config, Package $package)
$excludedFiles,
$phpunitExtensions,
$config['has_documentation'],
$config['has_test_kernel'],
$config['phpstan'],
$config['psalm'],
$config['custom_gitignore_part'],
Expand Down Expand Up @@ -225,6 +229,11 @@ public function hasDocumentation(): bool
return $this->hasDocumentation;
}

public function hasTestKernel(): bool
{
return $this->hasTestKernel;
}

public function usesPHPStan(): bool
{
return $this->phpstan;
Expand Down
2 changes: 1 addition & 1 deletion templates/project/.github/workflows/symfony-lint.yaml.twig
Expand Up @@ -91,7 +91,7 @@ jobs:
run: bin/console lint:xliff src tests --format=github

yaml:
name: YAML files
name: YML files

runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions tests/Command/Dispatcher/DispatchFilesCommandTest.php
Expand Up @@ -80,6 +80,7 @@ public function projectProvider(): iterable
custom_gitattributes_part: ~
custom_doctor_rst_whitelist_part: ~
has_documentation: true
has_test_kernel: true
documentation_badge_slug: ~
branches:
master:
Expand Down
9 changes: 9 additions & 0 deletions tests/Domain/Value/ProjectTest.php
Expand Up @@ -31,6 +31,7 @@ final class ProjectTest extends TestCase
custom_gitattributes_part: ~
custom_doctor_rst_whitelist_part: ~
has_documentation: true
has_test_kernel: true
documentation_badge_slug: ~
branches:
master:
Expand Down Expand Up @@ -94,6 +95,7 @@ public function valid(): void
static::assertNull($project->customGitignorePart());
static::assertNull($project->customGitattributesPart());
static::assertTrue($project->hasDocumentation());
static::assertTrue($project->hasTestKernel());
static::assertTrue($project->isBundle());
}

Expand Down Expand Up @@ -138,6 +140,7 @@ public function isBundleProvider(): iterable
custom_gitattributes_part: ~
custom_doctor_rst_whitelist_part: ~
has_documentation: true
has_test_kernel: true
documentation_badge_slug: 'sonataadminbundle2'
branches:
master:
Expand Down Expand Up @@ -167,6 +170,7 @@ public function isBundleProvider(): iterable
custom_gitattributes_part: ~
custom_doctor_rst_whitelist_part: ~
has_documentation: true
has_test_kernel: true
documentation_badge_slug: ~
branches:
master:
Expand Down Expand Up @@ -457,6 +461,7 @@ public function documentationBadgeSlugProvider(): iterable
custom_gitattributes_part: ~
custom_doctor_rst_whitelist_part: ~
has_documentation: true
has_test_kernel: true
documentation_badge_slug: ~
branches:
master:
Expand Down Expand Up @@ -485,6 +490,7 @@ public function documentationBadgeSlugProvider(): iterable
custom_gitattributes_part: ~
custom_doctor_rst_whitelist_part: ~
has_documentation: true
has_test_kernel: true
documentation_badge_slug: 'sonataadminbundle2'
branches:
master:
Expand Down Expand Up @@ -543,6 +549,7 @@ public function defaultBranchProvider(): iterable
custom_gitattributes_part: ~
custom_doctor_rst_whitelist_part: ~
has_documentation: true
has_test_kernel: true
documentation_badge_slug: ~
branches:
master:
Expand Down Expand Up @@ -571,6 +578,7 @@ public function defaultBranchProvider(): iterable
custom_gitattributes_part: ~
custom_doctor_rst_whitelist_part: ~
has_documentation: true
has_test_kernel: true
documentation_badge_slug: ~
branches:
master:
Expand Down Expand Up @@ -610,6 +618,7 @@ public function defaultBranchProvider(): iterable
custom_gitattributes_part: ~
custom_doctor_rst_whitelist_part: ~
has_documentation: true
has_test_kernel: true
documentation_badge_slug: ~
branches:
master:
Expand Down

0 comments on commit 3104010

Please sign in to comment.