Skip to content

Commit a20714d

Browse files
committed
Added Customizer.
1 parent d49e615 commit a20714d

38 files changed

+2080
-46
lines changed

.github/workflows/scaffold-test.yml

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,65 @@ on:
1313
- 'feature/**'
1414

1515
jobs:
16-
scaffold-test:
16+
scaffold-tests-customizer:
1717
runs-on: ubuntu-latest
1818

19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Upgrade sqlite3
24+
run: |
25+
wget https://www.sqlite.org/2024/sqlite-autoconf-3450300.tar.gz -O /tmp/sqlite.tar.gz
26+
tar -xzf /tmp/sqlite.tar.gz -C /tmp
27+
cd /tmp/sqlite-autoconf-3450300
28+
./configure CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1" --prefix=/usr/local
29+
make && sudo make install
30+
sudo ldconfig
31+
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: 8.3
36+
extensions: gd, sqlite, pdo_sqlite
37+
coverage: pcov
38+
ini-values: pcov.directory=.
39+
40+
- name: Install dependencies
41+
run: composer install
42+
working-directory: .scaffold
43+
44+
- name: Check coding standards
45+
run: composer lint
46+
working-directory: .scaffold
47+
48+
- name: Run tests
49+
run: composer test-coverage
50+
working-directory: .scaffold
51+
52+
- name: Upload coverage report as an artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: ${{github.job}}-code-coverage-report
56+
path: .scaffold/.scaffold-coverage-html
57+
if-no-files-found: error
58+
59+
- name: Upload coverage report to Codecov
60+
uses: codecov/codecov-action@v4
61+
if: ${{ env.CODECOV_TOKEN != '' }}
62+
with:
63+
directory: .scaffold/.scaffold-coverage-html
64+
fail_ci_if_error: true
65+
token: ${{ secrets.CODECOV_TOKEN }}
66+
env:
67+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
68+
69+
scaffold-test-scripts:
70+
runs-on: ubuntu-latest
71+
72+
needs:
73+
- scaffold-tests-customizer
74+
1975
steps:
2076
- name: Checkout code
2177
uses: actions/checkout@v4
@@ -54,23 +110,23 @@ jobs:
54110
55111
- name: Install dependencies
56112
run: npm ci
57-
working-directory: .scaffold/tests
113+
working-directory: .scaffold
58114

59115
- name: Run tests
60-
run: kcov --include-pattern=.sh,.bash --bash-parse-files-in-dir=. --exclude-pattern=vendor,node_modules,.scaffold-coverage-html,.scaffold "$(pwd)"/.scaffold-coverage-html .scaffold/tests/node_modules/.bin/bats .scaffold/tests/bats
116+
run: kcov --include-pattern=.sh,.bash --bash-parse-files-in-dir=. --exclude-pattern=vendor,node_modules,.scaffold-coverage-html,.scaffold "$(pwd)"/.scaffold/.scaffold-coverage-html .scaffold/node_modules/.bin/bats .scaffold/tests/bats
61117

62118
- name: Upload coverage report as an artifact
63119
uses: actions/upload-artifact@v4
64120
with:
65121
name: ${{github.job}}-code-coverage-report
66-
path: ./.scaffold-coverage-html
122+
path: .scaffold/.scaffold-coverage-html
67123
if-no-files-found: error
68124

69125
- name: Upload coverage report to Codecov
70126
uses: codecov/codecov-action@v4
71127
if: ${{ env.CODECOV_TOKEN != '' }}
72128
with:
73-
directory: ./.scaffold-coverage-html
129+
directory: .scaffold/.scaffold-coverage-html
74130
fail_ci_if_error: true
75131
token: ${{ secrets.CODECOV_TOKEN }}
76132
env:
@@ -93,6 +149,10 @@ jobs:
93149

94150
scaffold-test-docs:
95151
runs-on: ubuntu-latest
152+
needs:
153+
- scaffold-test-scripts
154+
- scaffold-tests-customizer
155+
- scaffold-test-actions
96156

97157
steps:
98158
- name: Checkout code
@@ -119,7 +179,7 @@ jobs:
119179
uses: nwtgck/actions-netlify@v3.0
120180
with:
121181
github-token: ${{ secrets.GITHUB_TOKEN }}
122-
publish-dir: '.scaffold/docs/build'
182+
publish-dir: .scaffold/docs/build
123183
production-branch: 1.x
124184
deploy-message: "Deploy from GitHub Actions"
125185
enable-pull-request-comment: true

.scaffold/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.phpunit.cache
2+
/.scaffold-coverage-html
3+
/cobertura.xml
4+
/coverage
5+
/node_modules
6+
/vendor

.scaffold/composer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "alexskrypnyk/drupal_extension_scaffold_test",
3+
"license": "GPL-2.0-or-later",
4+
"type": "project",
5+
"require": {
6+
"php": ">=8.2"
7+
},
8+
"require-dev": {
9+
"composer/composer": "^2.7",
10+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
11+
"drupal/coder": "^8.3",
12+
"ergebnis/composer-normalize": "^2.42",
13+
"helmich/phpunit-json-assert": "^2.0",
14+
"phpcompatibility/php-compatibility": "^9.3",
15+
"phpmd/phpmd": "^2.15",
16+
"phpstan/phpstan": "^1.10",
17+
"phpunit/phpunit": "^11.1",
18+
"rector/rector": "^1.0",
19+
"symfony/filesystem": "^6.0",
20+
"symfony/finder": "^6.0",
21+
"symfony/process": "^6.4"
22+
},
23+
"autoload-dev": {
24+
"psr-4": {
25+
"Drupal\\drupal_extension_scaffold\\Tests\\": "tests/phpunit"
26+
}
27+
},
28+
"config": {
29+
"allow-plugins": {
30+
"dealerdirect/phpcodesniffer-composer-installer": true,
31+
"ergebnis/composer-normalize": true
32+
}
33+
},
34+
"scripts": {
35+
"lint": [
36+
"phpcs",
37+
"phpmd --exclude vendor,vendor-bin,node_modules . text phpmd.xml",
38+
"phpstan",
39+
"rector --clear-cache --dry-run"
40+
],
41+
"lint-fix": [
42+
"rector --clear-cache",
43+
"phpcbf"
44+
],
45+
"test": "phpunit --no-coverage",
46+
"test-coverage": "phpunit"
47+
}
48+
}
File renamed without changes.
File renamed without changes.

.scaffold/phpcs.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="custom">
3+
<description>Custom PHPCS standard.</description>
4+
5+
<!-- Using Drupal coding standard as a base-fix. -->
6+
<rule ref="Drupal"/>
7+
<!-- Checks that the strict_types has been declared. -->
8+
<rule ref="Generic.PHP.RequireStrictTypes" />
9+
10+
<!-- Show sniff codes in all reports -->
11+
<arg value="s"/>
12+
<!-- Show progress of the run. -->
13+
<arg value="p"/>
14+
<arg name="colors"/>
15+
16+
<file>src</file>
17+
<file>tests/phpunit</file>
18+
19+
<!-- Allow long array lines in tests. -->
20+
<rule ref="Drupal.Arrays.Array.LongLineDeclaration">
21+
<exclude-pattern>*.Test\.php</exclude-pattern>
22+
<exclude-pattern>*.TestCase\.php</exclude-pattern>
23+
<exclude-pattern>*.test</exclude-pattern>
24+
</rule>
25+
26+
<!-- Allow missing function names in tests. -->
27+
<rule ref="Drupal.Commenting.FunctionComment.Missing">
28+
<exclude-pattern>*.Test\.php</exclude-pattern>
29+
<exclude-pattern>*.TestCase\.php</exclude-pattern>
30+
<exclude-pattern>*.test</exclude-pattern>
31+
</rule>
32+
</ruleset>

.scaffold/phpmd.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Custom PHPMD ruleset."
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
7+
8+
<rule ref="rulesets/unusedcode.xml"/>
9+
<rule ref="rulesets/codesize.xml"/>
10+
<rule ref="rulesets/cleancode.xml/MissingImport">
11+
<properties>
12+
<property name="ignore-global" value="true"/>
13+
</properties>
14+
</rule>
15+
</ruleset>

.scaffold/phpstan.neon

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
##
2+
# Configuration file for PHPStan static code checking, see https://phpstan.org .
3+
#
4+
5+
parameters:
6+
7+
level: 9
8+
9+
paths:
10+
- src
11+
- tests/phpunit
12+
13+
excludePaths:
14+
- vendor/*
15+
- node_modules/*
16+
17+
ignoreErrors:
18+
-
19+
# Since tests and data providers do not have to have parameter docblocks,
20+
# it is not possible to specify the type of the parameter, so we ignore
21+
# this error.
22+
message: '#.*no value type specified in iterable type array.#'
23+
path: tests/phpunit/*
24+
reportUnmatched: false

.scaffold/phpunit.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".phpunit.cache"
6+
executionOrder="depends,defects"
7+
requireCoverageMetadata="false"
8+
beStrictAboutCoverageMetadata="false"
9+
beStrictAboutOutputDuringTests="true"
10+
failOnRisky="true"
11+
failOnWarning="true"
12+
displayDetailsOnTestsThatTriggerWarnings="true"
13+
displayDetailsOnTestsThatTriggerErrors="true"
14+
displayDetailsOnTestsThatTriggerNotices="true">
15+
<testsuites>
16+
<testsuite name="default">
17+
<directory>tests/phpunit</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<source restrictNotices="true"
22+
restrictWarnings="true"
23+
ignoreIndirectDeprecations="true">
24+
<include>
25+
<directory>src</directory>
26+
</include>
27+
<exclude>
28+
<directory>tests/phpunit</directory>
29+
</exclude>
30+
</source>
31+
32+
<coverage
33+
includeUncoveredFiles="true"
34+
pathCoverage="false"
35+
ignoreDeprecatedCodeUnits="true"
36+
disableCodeCoverageIgnore="false">
37+
<report>
38+
<html outputDirectory=".scaffold-coverage-html" lowUpperBound="50" highLowerBound="90"/>
39+
<cobertura outputFile="cobertura.xml"/>
40+
</report>
41+
</coverage>
42+
</phpunit>

.scaffold/rector.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Rector configuration.
6+
*
7+
* Usage:
8+
* ./vendor/bin/rector process .
9+
*
10+
* @see https://github.com/palantirnet/drupal-rector/blob/main/rector.php
11+
*/
12+
13+
declare(strict_types=1);
14+
15+
use Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector;
16+
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
17+
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
18+
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
19+
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
20+
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
21+
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
22+
use Rector\Config\RectorConfig;
23+
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
24+
use Rector\Set\ValueObject\SetList;
25+
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
26+
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
27+
28+
return static function (RectorConfig $rectorConfig): void {
29+
$rectorConfig->paths([
30+
__DIR__ . '/src',
31+
__DIR__ . '/tests/phpunit',
32+
]);
33+
34+
$rectorConfig->sets([
35+
SetList::PHP_82,
36+
SetList::CODE_QUALITY,
37+
SetList::CODING_STYLE,
38+
SetList::DEAD_CODE,
39+
SetList::INSTANCEOF,
40+
SetList::TYPE_DECLARATION,
41+
]);
42+
43+
$rectorConfig->rule(DeclareStrictTypesRector::class);
44+
45+
$rectorConfig->skip([
46+
// Rules added by Rector's rule sets.
47+
ArraySpreadInsteadOfArrayMergeRector::class,
48+
CountArrayToEmptyArrayComparisonRector::class,
49+
DisallowedEmptyRuleFixerRector::class,
50+
InlineArrayReturnAssignRector::class,
51+
NewlineAfterStatementRector::class,
52+
NewlineBeforeNewAssignSetRector::class,
53+
PostIncDecToPreIncDecRector::class,
54+
RemoveAlwaysTrueIfConditionRector::class,
55+
SimplifyEmptyCheckOnEmptyArrayRector::class,
56+
// Dependencies.
57+
'*/vendor/*',
58+
'*/node_modules/*',
59+
]);
60+
61+
$rectorConfig->fileExtensions([
62+
'php',
63+
'inc',
64+
]);
65+
66+
$rectorConfig->importNames(TRUE, FALSE);
67+
$rectorConfig->importShortClasses(FALSE);
68+
};

.scaffold/src/CustomizeCommand.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Scaffold;
6+
7+
use Composer\Command\BaseCommand;
8+
use Symfony\Component\Console\Input\InputInterface;
9+
use Symfony\Component\Console\Output\OutputInterface;
10+
11+
/**
12+
* Class CustomizeCommand.
13+
*
14+
* Customize project.
15+
*/
16+
class CustomizeCommand extends BaseCommand {
17+
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
protected function configure(): void {
22+
$this
23+
->setName('customize')
24+
->setDescription('Customize project');
25+
}
26+
27+
/**
28+
* {@inheritdoc}
29+
*/
30+
protected function execute(InputInterface $input, OutputInterface $output): int {
31+
$output->write('Started customize command');
32+
33+
return 0;
34+
}
35+
36+
}

.scaffold/tests/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)