From d462830188e7939bead98b734482b5a97df0dcd6 Mon Sep 17 00:00:00 2001 From: lotyp Date: Wed, 31 Jul 2024 20:04:44 +0300 Subject: [PATCH 01/15] ci: add psalm support --- app/psalm-baseline.xml | 131 +++++++++++++++++++++++++++++++++++++++++ app/psalm.xml | 18 +++++- 2 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 app/psalm-baseline.xml diff --git a/app/psalm-baseline.xml b/app/psalm-baseline.xml new file mode 100644 index 0000000..e436083 --- /dev/null +++ b/app/psalm-baseline.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + dump((new VarCloner())->cloneVar($var), true)]]> + + + + + + + + + + + + + + + + + + + diff --git a/app/psalm.xml b/app/psalm.xml index a7dff04..f32bdf0 100644 --- a/app/psalm.xml +++ b/app/psalm.xml @@ -1,15 +1,29 @@ + + + + + + + + + From 57348aff19b2cf6cc8452dcefbcdeb594c5d0bd8 Mon Sep 17 00:00:00 2001 From: lotyp Date: Wed, 31 Jul 2024 20:05:19 +0300 Subject: [PATCH 02/15] ci: add pest and phpunit xml configs --- app/pest.xml.dist | 36 ++++++++++++++++++++++++++++++++ app/phpunit.xml.dist | 49 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 app/pest.xml.dist create mode 100644 app/phpunit.xml.dist diff --git a/app/pest.xml.dist b/app/pest.xml.dist new file mode 100644 index 0000000..71d3a8a --- /dev/null +++ b/app/pest.xml.dist @@ -0,0 +1,36 @@ + + + + + + + + tests/src/Arch + + + + + app/src + + + + + + + + + + + + + diff --git a/app/phpunit.xml.dist b/app/phpunit.xml.dist new file mode 100644 index 0000000..4e47d9e --- /dev/null +++ b/app/phpunit.xml.dist @@ -0,0 +1,49 @@ + + + + + + + + tests/Unit + + + tests/Feature + + + + + + + + + + + + + + + app/src + + + + + + + + + + + + + From f6d44f2c0be66d1e43da4f196b06455343dc4fc8 Mon Sep 17 00:00:00 2001 From: lotyp Date: Wed, 31 Jul 2024 20:05:58 +0300 Subject: [PATCH 03/15] fix: add memory sqlite driver to speed up testing --- app/app/config/database.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/app/config/database.php b/app/app/config/database.php index d051b4d..9d2e6fc 100644 --- a/app/app/config/database.php +++ b/app/app/config/database.php @@ -50,6 +50,11 @@ * the driver class and its connection options. */ 'drivers' => [ + 'memory' => new Config\SQLiteDriverConfig( + connection: new Config\SQLite\MemoryConnectionConfig(), + queryCache: true + ), + 'sqlite' => new Config\SQLiteDriverConfig( connection: new Config\SQLite\MemoryConnectionConfig(), queryCache: env('DB_QUERY_CACHE', true), From a52c2cf7b06ddd9ab72f14137f4efe202e809bf2 Mon Sep 17 00:00:00 2001 From: lotyp Date: Wed, 31 Jul 2024 20:06:19 +0300 Subject: [PATCH 04/15] test: add basic arch pest tests --- app/tests/src/Arch/DebugTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/tests/src/Arch/DebugTest.php diff --git a/app/tests/src/Arch/DebugTest.php b/app/tests/src/Arch/DebugTest.php new file mode 100644 index 0000000..62c71dc --- /dev/null +++ b/app/tests/src/Arch/DebugTest.php @@ -0,0 +1,13 @@ +expect(['trap', 'dd', 'dump', 'exit', 'die', 'print_r', 'var_dump', 'echo', 'print']) + ->not + ->toBeUsed(); + +arch('do not use compact() in your code') + ->expect(['compact']) + ->not + ->toBeUsed(); From feb2c8b505ad40c243d2da2ca5ffd454b586b91b Mon Sep 17 00:00:00 2001 From: lotyp Date: Wed, 31 Jul 2024 20:06:41 +0300 Subject: [PATCH 05/15] test: remove locale testing --- .../Feature/Controller/HomeControllerTest.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/app/tests/Feature/Controller/HomeControllerTest.php b/app/tests/Feature/Controller/HomeControllerTest.php index 5057f5b..b1f9f20 100644 --- a/app/tests/Feature/Controller/HomeControllerTest.php +++ b/app/tests/Feature/Controller/HomeControllerTest.php @@ -4,11 +4,9 @@ namespace Tests\Feature\Controller; -use Spiral\Bootloader\I18nBootloader; use Spiral\Testing\Http\FakeHttp; use Tests\TestCase; -use function in_array; use function strip_tags; class HomeControllerTest extends TestCase @@ -35,23 +33,6 @@ public function default_action_works(): void ); } - /** - * @test - */ - public function default_action_with_ru_locale(): void - { - if (! in_array(I18nBootloader::class, $this->getRegisteredBootloaders())) { - $this->markTestSkipped('Component `spiral/translator` is not installed.'); - } - - $response = $this->http->withHeader('accept-language', 'ru')->get('/')->assertOk(); - - $this->assertStringContainsString( - 'PHP Framework для будущих инноваторов', - strip_tags((string) $response->getOriginalResponse()->getBody()) - ); - } - /** * @test */ From 2000f9b20962083197c231571d79efc2d94b8ce3 Mon Sep 17 00:00:00 2001 From: lotyp Date: Wed, 31 Jul 2024 20:09:38 +0300 Subject: [PATCH 06/15] ci: add rector config --- app/rector.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/rector.php diff --git a/app/rector.php b/app/rector.php new file mode 100644 index 0000000..aa67a0b --- /dev/null +++ b/app/rector.php @@ -0,0 +1,33 @@ +cacheDirectory(__DIR__ . '/.build/rector/'); + + $rectorConfig->import(__DIR__ . '/vendor/fakerphp/faker/rector-migrate.php'); + + $rectorConfig->paths([ + __DIR__ . '/app/src/', + __DIR__ . '/tests/', + __DIR__ . '/.php-cs-fixer.dist.php', + __DIR__ . '/rector.php', + __DIR__ . '/functions.php', + __DIR__ . '/app.php', + ]); + + $rectorConfig->phpVersion(ValueObject\PhpVersion::PHP_83); + + $rectorConfig->rules([ + Php81\Rector\Property\ReadOnlyPropertyRector::class, + ]); + + $rectorConfig->sets([ + PHPUnit\Set\PHPUnitSetList::PHPUNIT_100, + ]); +}; From 59e2da692393fc4c749cc1950c6dc8cb6ab17d03 Mon Sep 17 00:00:00 2001 From: lotyp Date: Wed, 31 Jul 2024 20:15:43 +0300 Subject: [PATCH 07/15] ci: apply rector rules --- app/app/src/Domain/User/Entity/User.php | 6 +++--- .../src/Endpoint/Console/CreateUserCommand.php | 4 ++-- app/app/src/Endpoint/Console/DoNothing.php | 2 +- app/app/src/Endpoint/Console/PingCommand.php | 2 +- .../Feature/Controller/HomeControllerTest.php | 15 ++++++--------- app/tests/Feature/Job/PingTest.php | 11 +++++++---- app/tests/TestCase.php | 4 ++++ app/tests/Unit/DemoTest.php | 11 +++++------ 8 files changed, 29 insertions(+), 26 deletions(-) diff --git a/app/app/src/Domain/User/Entity/User.php b/app/app/src/Domain/User/Entity/User.php index b55a05d..087e642 100644 --- a/app/app/src/Domain/User/Entity/User.php +++ b/app/app/src/Domain/User/Entity/User.php @@ -17,11 +17,11 @@ class User * @psalm-suppress PropertyNotSetInConstructor */ #[Column(type: 'primary')] - private int $id; + private readonly int $id; public function __construct( - #[Column(type: 'string')] private string $username, - #[Column(type: 'string')] private string $email, + #[Column(type: 'string')] private readonly string $username, + #[Column(type: 'string')] private readonly string $email, ) { } diff --git a/app/app/src/Endpoint/Console/CreateUserCommand.php b/app/app/src/Endpoint/Console/CreateUserCommand.php index 03d2e90..c6230e0 100644 --- a/app/app/src/Endpoint/Console/CreateUserCommand.php +++ b/app/app/src/Endpoint/Console/CreateUserCommand.php @@ -22,11 +22,11 @@ class CreateUserCommand extends Command { #[Argument(description: 'User name')] #[Question(question: 'Provide username')] - private string $username; + private readonly string $username; #[Argument(description: 'User E-mail')] #[Question(question: 'Provide e-mail address')] - private string $email; + private readonly string $email; public function __invoke(CreateUserService $service): int { diff --git a/app/app/src/Endpoint/Console/DoNothing.php b/app/app/src/Endpoint/Console/DoNothing.php index da066e5..70793b3 100644 --- a/app/app/src/Endpoint/Console/DoNothing.php +++ b/app/app/src/Endpoint/Console/DoNothing.php @@ -28,7 +28,7 @@ final class DoNothing extends Command { #[Argument(description: 'Task name')] #[Question(question: 'Provide task name')] - private string $name; + private readonly string $name; #[Option( shortcut: 't', diff --git a/app/app/src/Endpoint/Console/PingCommand.php b/app/app/src/Endpoint/Console/PingCommand.php index 2803dee..c0f7457 100644 --- a/app/app/src/Endpoint/Console/PingCommand.php +++ b/app/app/src/Endpoint/Console/PingCommand.php @@ -28,7 +28,7 @@ final class PingCommand extends Command { #[Argument(description: 'Site url')] #[Question(question: 'Provide a site url')] - private string $site; + private readonly string $site; public function __invoke(QueueInterface $queue): int { diff --git a/app/tests/Feature/Controller/HomeControllerTest.php b/app/tests/Feature/Controller/HomeControllerTest.php index b1f9f20..7854d89 100644 --- a/app/tests/Feature/Controller/HomeControllerTest.php +++ b/app/tests/Feature/Controller/HomeControllerTest.php @@ -4,12 +4,13 @@ namespace Tests\Feature\Controller; +use PHPUnit\Framework\Attributes\Test; use Spiral\Testing\Http\FakeHttp; use Tests\TestCase; use function strip_tags; -class HomeControllerTest extends TestCase +final class HomeControllerTest extends TestCase { private FakeHttp $http; @@ -20,26 +21,22 @@ protected function setUp(): void $this->http = $this->fakeHttp(); } - /** - * @test - */ + #[Test] public function default_action_works(): void { $response = $this->http->get('/')->assertOk(); - $this->assertStringContainsString( + self::assertStringContainsString( 'The PHP Framework for future Innovators', strip_tags((string) $response->getOriginalResponse()->getBody()) ); } - /** - * @test - */ + #[Test] public function interact_with_console(): void { $output = $this->runCommand('views:reset'); - $this->assertStringContainsString('cache', $output); + self::assertStringContainsString('cache', $output); } } diff --git a/app/tests/Feature/Job/PingTest.php b/app/tests/Feature/Job/PingTest.php index 48a2519..cfa82bb 100644 --- a/app/tests/Feature/Job/PingTest.php +++ b/app/tests/Feature/Job/PingTest.php @@ -5,13 +5,18 @@ namespace Tests\Feature\Job; use App\Endpoint\Job\Ping; +use PHPUnit\Framework\Attributes\Test; +use Spiral\Queue\Exception\InvalidArgumentException; use Spiral\Testing\Queue\FakeQueue; use Tests\TestCase; -class PingTest extends TestCase +final class PingTest extends TestCase { private FakeQueue $connection; + /** + * @throws InvalidArgumentException + */ protected function setUp(): void { parent::setUp(); @@ -19,9 +24,7 @@ protected function setUp(): void $this->connection = $this->fakeQueue()->getConnection(); } - /** - * @test - */ + #[Test] public function job_pushed(): void { $this->connection->push(Ping::class, ['value' => 'hello world']); diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php index 54c6ea2..f8737be 100644 --- a/app/tests/TestCase.php +++ b/app/tests/TestCase.php @@ -11,6 +11,7 @@ use Spiral\Testing\TestCase as BaseTestCase; use Spiral\Translator\TranslatorInterface; use Tests\App\TestKernel; +use Throwable; class TestCase extends BaseTestCase { @@ -39,6 +40,9 @@ protected function tearDown(): void // $this->cleanUpRuntimeDirectory(); } + /** + * @throws Throwable + */ public function createAppInstance(Container $container = new Container()): TestableKernelInterface { return TestKernel::create( diff --git a/app/tests/Unit/DemoTest.php b/app/tests/Unit/DemoTest.php index 55d6f9e..ada5a17 100644 --- a/app/tests/Unit/DemoTest.php +++ b/app/tests/Unit/DemoTest.php @@ -4,19 +4,18 @@ namespace Tests\Unit; +use PHPUnit\Framework\Attributes\Test; use Tests\TestCase; -class DemoTest extends TestCase +final class DemoTest extends TestCase { - /** - * @test - */ + #[Test] public function demo(): void { $expected = true; $actual = false; - $this->assertTrue($expected); - $this->assertFalse($actual); + self::assertTrue($expected); + self::assertFalse($actual); } } From f117b428d3d35366fb3c867bd4e67c4c45f17467 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 1 Aug 2024 15:10:34 +0300 Subject: [PATCH 08/15] ci: migrate rector to use fluent config approach --- app/rector.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/app/rector.php b/app/rector.php index aa67a0b..9fe1704 100644 --- a/app/rector.php +++ b/app/rector.php @@ -7,27 +7,21 @@ use Rector\PHPUnit; use Rector\ValueObject; -return static function (Config\RectorConfig $rectorConfig): void { - $rectorConfig->cacheDirectory(__DIR__ . '/.build/rector/'); - - $rectorConfig->import(__DIR__ . '/vendor/fakerphp/faker/rector-migrate.php'); - - $rectorConfig->paths([ +return Config\RectorConfig::configure() + ->withCache(__DIR__ . '/.build/rector/') + ->withPaths([ __DIR__ . '/app/src/', __DIR__ . '/tests/', __DIR__ . '/.php-cs-fixer.dist.php', __DIR__ . '/rector.php', __DIR__ . '/functions.php', __DIR__ . '/app.php', - ]); - - $rectorConfig->phpVersion(ValueObject\PhpVersion::PHP_83); - - $rectorConfig->rules([ + ]) + ->withPhpVersion(ValueObject\PhpVersion::PHP_83) + ->withRules([ Php81\Rector\Property\ReadOnlyPropertyRector::class, - ]); - - $rectorConfig->sets([ + ]) + ->withSets([ PHPUnit\Set\PHPUnitSetList::PHPUNIT_100, - ]); -}; + ]) +; From 5cf4e60d20cbea1c623f54f60370b8b13a94bfdb Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 1 Aug 2024 15:10:47 +0300 Subject: [PATCH 09/15] ci: add rector workflow --- .github/workflows/refactoring.yml | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/refactoring.yml diff --git a/.github/workflows/refactoring.yml b/.github/workflows/refactoring.yml new file mode 100644 index 0000000..dbcbecd --- /dev/null +++ b/.github/workflows/refactoring.yml @@ -0,0 +1,73 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - develop + paths: + - 'app/config/**' + - 'app/src/**' + - 'app/tests/**' + - 'app/.php-cs-fixer.dist.php' + - 'app/rector.php' + +name: ⚙️ Refactoring + +env: + # Disable docker support in Makefile + APP_RUNNER: 'cd app &&' + +jobs: + refactoring: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: refactoring-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.3' + dependencies: + - locked + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: 🛠️ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets + ini-values: error_reporting=E_ALL + coverage: none + + - name: 🛠️ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: 🤖 Validate composer.json and composer.lock + run: make validate-composer + + - name: 🔍 Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + with: + working-directory: app + + - name: ♻️ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + working-directory: app + dependencies: ${{ matrix.dependencies }} + + - name: ⚙️ Run automated refactoring with rector/rector + run: make refactor-ci From 9d0956bbfb928a1d67c8c3519beaee0531858771 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 1 Aug 2024 21:25:04 +0300 Subject: [PATCH 10/15] ci: workflow updates --- .github/workflows/coding-standards.yml | 14 ++--- .github/workflows/refactoring.yml | 4 +- .github/workflows/security-analysis.yml | 68 +++++++++++++++++++++++++ .github/workflows/shellcheck.yml | 23 +++++++++ 4 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/security-analysis.yml create mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index ad74399..4a1fe7b 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -24,7 +24,7 @@ jobs: pull-requests: read steps: - name: 📦 Check out the codebase - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - name: 🧐 Lint commits using "commitlint" uses: wagoid/commitlint-github-action@v6.0.1 @@ -45,7 +45,7 @@ jobs: pull-requests: read steps: - name: 📦 Check out the codebase - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - name: 🧐 Lint YAML files uses: ibiqlik/action-yamllint@v3.1.1 @@ -62,7 +62,7 @@ jobs: group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} steps: - name: 📦 Check out the codebase - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - name: 🧐 Lint Markdown files uses: DavidAnson/markdownlint-cli2-action@v16.0.0 @@ -92,7 +92,7 @@ jobs: contents: write steps: - name: 🛠️ Setup PHP - uses: shivammathur/setup-php@2.30.5 + uses: shivammathur/setup-php@2.31.1 with: php-version: ${{ matrix.php-version }} extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets @@ -101,7 +101,7 @@ jobs: tools: phive - name: 📦 Check out the codebase - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - name: 🛠️ Setup problem matchers run: | @@ -162,7 +162,7 @@ jobs: git config --global core.eol lf - name: 🛠️ Setup PHP - uses: shivammathur/setup-php@2.30.5 + uses: shivammathur/setup-php@2.31.1 with: php-version: ${{ matrix.php-version }} extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, decimal @@ -170,7 +170,7 @@ jobs: coverage: none - name: 📦 Check out the codebase - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - name: 🛠️ Setup problem matchers run: | diff --git a/.github/workflows/refactoring.yml b/.github/workflows/refactoring.yml index dbcbecd..b40a8cf 100644 --- a/.github/workflows/refactoring.yml +++ b/.github/workflows/refactoring.yml @@ -35,10 +35,10 @@ jobs: - locked steps: - name: 📦 Check out the codebase - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 - name: 🛠️ Setup PHP - uses: shivammathur/setup-php@2.30.5 + uses: shivammathur/setup-php@2.31.1 with: php-version: ${{ matrix.php-version }} extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets diff --git a/.github/workflows/security-analysis.yml b/.github/workflows/security-analysis.yml new file mode 100644 index 0000000..77a5940 --- /dev/null +++ b/.github/workflows/security-analysis.yml @@ -0,0 +1,68 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + - develop + +name: 🔐 Security analysis + +env: + # Disable docker support in Makefile + APP_RUNNER: 'cd app &&' + +jobs: + security-analysis: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: security-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.3' + dependencies: + - locked + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: 🛠️ Setup PHP + uses: shivammathur/setup-php@2.31.1 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, sockets + ini-values: error_reporting=E_ALL + coverage: none + + - name: 🛠️ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: 🤖 Validate composer.json and composer.lock + run: make validate-composer + + - name: 🔍 Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + with: + working-directory: app + + - name: ♻️ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + working-directory: app + dependencies: ${{ matrix.dependencies }} + + - name: 🐛 Check installed packages for security vulnerability advisories + run: make lint-audit diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..ea848d6 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,23 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + - develop + +name: 🐞 Differential shell-check + +permissions: + contents: read + +jobs: + shellcheck: + uses: wayofdev/gh-actions/.github/workflows/shellcheck.yml@v3.1.1 + with: + os: ubuntu-latest + severity: warning + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + +... From b4144e02786c112e741efe49e3fbd86687542b82 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 1 Aug 2024 22:31:12 +0300 Subject: [PATCH 11/15] ci: dependency, testing and analysis workflows --- .github/workflows/dependency-analysis.yml | 149 +++++++++++++++ .github/workflows/static-analysis.yml | 133 +++++++++++++ .github/workflows/testing.yml | 223 ++++++++++++++++++++++ 3 files changed, 505 insertions(+) create mode 100644 .github/workflows/dependency-analysis.yml create mode 100644 .github/workflows/static-analysis.yml create mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/dependency-analysis.yml b/.github/workflows/dependency-analysis.yml new file mode 100644 index 0000000..5ae7ea7 --- /dev/null +++ b/.github/workflows/dependency-analysis.yml @@ -0,0 +1,149 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + - develop + paths: + - 'app/config/**' + - 'app/src/**' + - 'app/tests/**' + - 'app/.php-cs-fixer.dist.php' + - 'app/app.php' + - 'app/functions.php' + - 'app/composer.json' + - 'app/composer.lock' + - 'app/composer-require-checker.json' + +name: 🔐 Dependency analysis + +env: + # Disable docker support in Makefile + APP_RUNNER: 'cd app &&' + +jobs: + dependency-analysis: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: dependency-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.3' + dependencies: + - locked + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: 🛠️ Setup PHP + uses: shivammathur/setup-php@2.31.1 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql + ini-values: error_reporting=E_ALL + coverage: none + tools: phive + + - name: 🛠️ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: 🤖 Validate composer.json and composer.lock + run: make validate-composer + + - name: 🔍 Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + with: + working-directory: app + + - name: ♻️ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + working-directory: app + dependencies: ${{ matrix.dependencies }} + + - name: 📥 Install dependencies with phive + working-directory: app + env: + PHIVE_HOME: .phive + run: phive install --trust-gpg-keys 0xC00543248C87FB13,0x033E5F8D801A2F8D,0x47436587D82C4A39 + shell: bash + + - name: 🔬 Run maglnet/composer-require-checker + working-directory: app + run: .phive/composer-require-checker check --ansi --config-file="$(pwd)/composer-require-checker.json" --verbose + + deptrac: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: deptrac-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.3' + dependencies: + - locked + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: 🛠️ Setup PHP + uses: shivammathur/setup-php@2.31.1 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql + ini-values: error_reporting=E_ALL + coverage: none + tools: phive + + - name: 🛠️ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: 🤖 Validate composer.json and composer.lock + run: make validate-composer + + - name: 🔍 Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + with: + working-directory: app + + - name: ♻️ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + working-directory: app + dependencies: ${{ matrix.dependencies }} + + - name: 📥 Install dependencies with phive + working-directory: app + env: + PHIVE_HOME: .phive + run: phive install --trust-gpg-keys 0xC00543248C87FB13,0x033E5F8D801A2F8D,0x47436587D82C4A39 + shell: bash + + - name: 🔬 Run deptrac + run: make lint-deptrac-ci diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..43e7cef --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,133 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + - develop + paths: + - 'app/config/**' + - 'app/src/**' + - 'app/tests/**' + - 'app/.php-cs-fixer.dist.php' + - 'app/composer.json' + - 'app/composer.lock' + - 'app/phpstan.neon.dist' + - 'app/phpstan-baseline.neon' + - 'app/psalm.xml' + - 'app/psalm-baseline.xml' + +name: 🔍 Static analysis + +env: + # Disable docker support in Makefile + APP_RUNNER: 'cd app &&' + +jobs: + phpstan: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: phpstan-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.3' + dependencies: + - locked + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: 🛠️ Setup PHP + uses: shivammathur/setup-php@2.31.1 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, opcache, pcntl, posix + ini-values: error_reporting=E_ALL + coverage: none + + - name: 🛠️ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: 🤖 Validate composer.json and composer.lock + run: make validate-composer + + - name: 🔍 Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + with: + working-directory: app + + - name: ♻️ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + working-directory: app + dependencies: ${{ matrix.dependencies }} + + - name: 🔍 Run static analysis using phpstan/phpstan + run: make lint-stan-ci + + psalm: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: psalm-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.3' + dependencies: + - locked + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: 🛠️ Setup PHP + uses: shivammathur/setup-php@2.31.1 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, pdo_mysql, curl, fileinfo, opcache, pcntl, posix + ini-values: error_reporting=E_ALL + coverage: xdebug + + - name: 🛠️ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: 🤖 Validate composer.json and composer.lock + run: make validate-composer + + - name: 🔍 Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + with: + working-directory: app + + - name: ♻️ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + working-directory: app + dependencies: ${{ matrix.dependencies }} + + - name: 🔍 Run static analysis using vimeo/psalm + run: make lint-psalm-ci diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..79ef87a --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,223 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + - develop + push: + branches: + - master + +name: 🧪 Testing + +env: + # Disable docker support in Makefile + APP_RUNNER: 'cd app &&' + APP_NAME: laravel + SHARED_SERVICES_NAMESPACE: ss + COMPOSE_PROJECT_NAME: laravel-starter-tpl + +jobs: + code-coverage: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: code-coverage-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.php-version }}-${{ matrix.dependencies }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.3' + dependencies: + - locked + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: 🛠️ Setup PHP + uses: shivammathur/setup-php@2.31.1 + with: + php-version: ${{ matrix.php-version }} + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, pdo_mysql, pdo_sqlite, curl, fileinfo, opcache, pcntl, posix + ini-values: error_reporting=E_ALL + coverage: xdebug + + - name: 🛠️ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: 🤖 Validate composer.json and composer.lock + run: make validate-composer + + - name: 🔍 Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + with: + working-directory: app + + - name: ♻️ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + working-directory: app + dependencies: ${{ matrix.dependencies }} + + - name: 🛠️ Prepare environment + run: | + make env + cp -rf .env app/.env + + - name: 🔑 Generate secret application key + working-directory: app + run: php artisan key:generate + + - name: 🧪 Collect code coverage with Xdebug and pestphp/pest + working-directory: app + run: composer test:cc + + - name: 📤 Upload code coverage report to Codecov + uses: codecov/codecov-action@v4.4.1 + with: + files: app/.build/phpunit/logs/clover.xml + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + + arch-testing: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: arch-testing-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.php-version }}-${{ matrix.dependencies }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.3' + dependencies: + - locked + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: 🛠️ Setup PHP + uses: shivammathur/setup-php@2.31.1 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite + ini-values: error_reporting=E_ALL + coverage: xdebug + + - name: 🛠️ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: 🤖 Validate composer.json and composer.lock + run: make validate-composer + + - name: 🔍 Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + with: + working-directory: app + + - name: ♻️ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + working-directory: app + dependencies: ${{ matrix.dependencies }} + + - name: 🛠️ Prepare environment + run: | + make env + cp -rf .env app/.env + + - name: 🔑 Generate secret application key + working-directory: app + run: php artisan key:generate + + - name: 🧪 Run architecture tests using pestphp/pest + working-directory: app + run: composer test:arch + + mutation-testing: + timeout-minutes: 16 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: mutation-testing-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.3' + dependencies: + - locked + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.7 + + - name: 🛠️ Setup PHP + uses: shivammathur/setup-php@2.31.1 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite + ini-values: error_reporting=E_ALL + coverage: xdebug + + - name: 🛠️ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: 🤖 Validate composer.json and composer.lock + run: make validate-composer + + - name: 🔍 Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1 + with: + working-directory: app + + - name: ♻️ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer + uses: wayofdev/gh-actions/actions/composer/install@v3.1.1 + with: + working-directory: app + dependencies: ${{ matrix.dependencies }} + + - name: 🛠️ Prepare environment + run: | + make env + cp -rf .env app/.env + + - name: 🔑 Generate secret application key + working-directory: app + run: php artisan key:generate + + - name: 🧪 Run mutation testing using Xdebug and infection/infection + working-directory: app + run: composer infect:ci + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} From bc20e700c2a4602fde36b096abf3d13a1967036c Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 1 Aug 2024 23:29:47 +0300 Subject: [PATCH 12/15] refactor: flattern application structure --- Makefile | 4 + app/.php-cs-fixer.dist.php | 5 +- app/app.php | 18 +-- app/composer.json | 2 +- app/composer.lock | 22 +-- app/{app => }/config/cache.php | 2 +- app/{app => }/config/cycle.php | 0 app/{app => }/config/database.php | 0 app/{app => }/config/mailer.php | 0 app/{app => }/config/migration.php | 0 app/{app => }/config/queue.php | 0 app/{app => }/config/scaffolder.php | 0 app/{app => }/config/session.php | 2 +- app/{app => }/config/storage.php | 0 app/{app => }/config/temporal.php | 0 app/{app => }/migrations/.gitignore | 0 ...230222.132457_0_0_default_create_users.php | 0 app/pest.xml.dist | 2 +- app/phpstan-baseline.neon | 131 ++++++++++++++++++ app/phpstan.neon.dist | 13 ++ app/phpunit.xml.dist | 2 +- app/psalm-baseline.xml | 56 +++++--- app/psalm.xml | 2 +- .../Application/Bootloader/AppBootloader.php | 0 .../Bootloader/ExceptionHandlerBootloader.php | 0 .../Bootloader/LoggingBootloader.php | 0 .../Bootloader/PersistenceBootloader.php | 0 .../Bootloader/RoutesBootloader.php | 0 .../src/Application/Exception/Handler.php | 0 app/{app => }/src/Application/Kernel.php | 0 app/{app => }/src/Domain/User/Entity/User.php | 0 .../User/Exception/UserNotFoundException.php | 0 .../Repository/UserRepositoryInterface.php | 0 .../Domain/User/Service/CreateUserService.php | 0 .../Endpoint/Console/CreateUserCommand.php | 0 .../src/Endpoint/Console/DoNothing.php | 0 .../src/Endpoint/Console/PingCommand.php | 0 app/{app => }/src/Endpoint/Job/Ping.php | 0 .../src/Endpoint/Web/HomeController.php | 0 .../CycleORM/Typecaster/UuidTypecast.php | 0 .../Persistence/CycleORMUserRepository.php | 0 .../src/Temporal/PaymentActivity.php | 0 .../src/Temporal/PaymentActivityInterface.php | 0 .../src/Temporal/PaymentWorkflow.php | 0 .../src/Temporal/PaymentWorkflowInterface.php | 0 app/tests/TestCase.php | 7 + app/{app => }/views/home.php | 0 47 files changed, 219 insertions(+), 49 deletions(-) rename app/{app => }/config/cache.php (95%) rename app/{app => }/config/cycle.php (100%) rename app/{app => }/config/database.php (100%) rename app/{app => }/config/mailer.php (100%) rename app/{app => }/config/migration.php (100%) rename app/{app => }/config/queue.php (100%) rename app/{app => }/config/scaffolder.php (100%) rename app/{app => }/config/session.php (89%) rename app/{app => }/config/storage.php (100%) rename app/{app => }/config/temporal.php (100%) rename app/{app => }/migrations/.gitignore (100%) rename app/{app => }/migrations/20230222.132457_0_0_default_create_users.php (100%) create mode 100644 app/phpstan-baseline.neon create mode 100644 app/phpstan.neon.dist rename app/{app => }/src/Application/Bootloader/AppBootloader.php (100%) rename app/{app => }/src/Application/Bootloader/ExceptionHandlerBootloader.php (100%) rename app/{app => }/src/Application/Bootloader/LoggingBootloader.php (100%) rename app/{app => }/src/Application/Bootloader/PersistenceBootloader.php (100%) rename app/{app => }/src/Application/Bootloader/RoutesBootloader.php (100%) rename app/{app => }/src/Application/Exception/Handler.php (100%) rename app/{app => }/src/Application/Kernel.php (100%) rename app/{app => }/src/Domain/User/Entity/User.php (100%) rename app/{app => }/src/Domain/User/Exception/UserNotFoundException.php (100%) rename app/{app => }/src/Domain/User/Repository/UserRepositoryInterface.php (100%) rename app/{app => }/src/Domain/User/Service/CreateUserService.php (100%) rename app/{app => }/src/Endpoint/Console/CreateUserCommand.php (100%) rename app/{app => }/src/Endpoint/Console/DoNothing.php (100%) rename app/{app => }/src/Endpoint/Console/PingCommand.php (100%) rename app/{app => }/src/Endpoint/Job/Ping.php (100%) rename app/{app => }/src/Endpoint/Web/HomeController.php (100%) rename app/{app => }/src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php (100%) rename app/{app => }/src/Infrastructure/Persistence/CycleORMUserRepository.php (100%) rename app/{app => }/src/Temporal/PaymentActivity.php (100%) rename app/{app => }/src/Temporal/PaymentActivityInterface.php (100%) rename app/{app => }/src/Temporal/PaymentWorkflow.php (100%) rename app/{app => }/src/Temporal/PaymentWorkflowInterface.php (100%) rename app/{app => }/views/home.php (100%) diff --git a/Makefile b/Makefile index c015ee0..92e1163 100644 --- a/Makefile +++ b/Makefile @@ -175,6 +175,10 @@ purge: ## Stops and removes containers, volumes, networks and images restart: down up ## Runs down and up commands .PHONY: restart +restart-app: ## Restarts app container + $(DOCKER_COMPOSE) restart app +.PHONY: restart-app + clean: ## Stops and removes containers of this project together with volumes $(DOCKER_COMPOSE) rm --force --stop --volumes .PHONY: clean diff --git a/app/.php-cs-fixer.dist.php b/app/.php-cs-fixer.dist.php index 5284167..0d088a9 100644 --- a/app/.php-cs-fixer.dist.php +++ b/app/.php-cs-fixer.dist.php @@ -8,12 +8,15 @@ require_once 'vendor/autoload.php'; $config = ConfigBuilder::createFromRuleSet(new DefaultSet(['static_lambda' => false])) - ->inDir(__DIR__ . '/app') + ->inDir(__DIR__ . '/config') + ->inDir(__DIR__ . '/migrations') + ->inDir(__DIR__ . '/src') ->inDir(__DIR__ . '/tests') ->addFiles([ __FILE__, __DIR__ . '/functions.php', __DIR__ . '/app.php', + __DIR__ . '/rector.php', ]) ->useParallelConfig() ->getConfig() diff --git a/app/app.php b/app/app.php index b47893b..de48676 100644 --- a/app/app.php +++ b/app/app.php @@ -5,23 +5,22 @@ use App\Application\Exception\Handler; use App\Application\Kernel; -// If you forgot to configure some of this in your php.ini file, -// then don't worry, we will set the standard environment -// settings for you. - mb_internal_encoding('UTF-8'); error_reporting((E_ALL | E_STRICT) ^ E_DEPRECATED); ini_set('display_errors', 'stderr'); -// Application helper functions. Must be included before the composer autoloader. require __DIR__ . '/functions.php'; - -// Register Composer's auto loader. require __DIR__ . '/vendor/autoload.php'; -// Initialize shared container, bindings, directories and etc. $app = Kernel::create( - directories: ['root' => __DIR__], + directories: [ + 'root' => __DIR__, + 'app' => __DIR__ . '/src', + 'config' => __DIR__ . '/config', + 'public' => __DIR__ . '/public', + 'runtime' => __DIR__ . '/runtime', + 'views' => __DIR__ . '/views', + ], exceptionHandler: Handler::class, )->run(); @@ -30,4 +29,5 @@ } $code = (int) $app->serve(); + exit($code); diff --git a/app/composer.json b/app/composer.json index de2ce95..da4526a 100644 --- a/app/composer.json +++ b/app/composer.json @@ -84,7 +84,7 @@ "prefer-stable": true, "autoload": { "psr-4": { - "App\\": "app/src" + "App\\": "src" } }, "autoload-dev": { diff --git a/app/composer.lock b/app/composer.lock index e744431..b61a057 100644 --- a/app/composer.lock +++ b/app/composer.lock @@ -10815,16 +10815,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.61.0", + "version": "v3.61.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "737a24b6d531db9c034ac97524ac3a3bde0c20c0" + "reference": "94a87189f55814e6cabca2d9a33b06de384a2ab8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/737a24b6d531db9c034ac97524ac3a3bde0c20c0", - "reference": "737a24b6d531db9c034ac97524ac3a3bde0c20c0", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/94a87189f55814e6cabca2d9a33b06de384a2ab8", + "reference": "94a87189f55814e6cabca2d9a33b06de384a2ab8", "shasum": "" }, "require": { @@ -10906,7 +10906,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.61.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.61.1" }, "funding": [ { @@ -10914,7 +10914,7 @@ "type": "github" } ], - "time": "2024-07-31T08:18:16+00:00" + "time": "2024-07-31T14:33:15+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -12373,16 +12373,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.11.8", + "version": "1.11.9", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec" + "reference": "e370bcddadaede0c1716338b262346f40d296f82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec", - "reference": "6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e370bcddadaede0c1716338b262346f40d296f82", + "reference": "e370bcddadaede0c1716338b262346f40d296f82", "shasum": "" }, "require": { @@ -12427,7 +12427,7 @@ "type": "github" } ], - "time": "2024-07-24T07:01:22+00:00" + "time": "2024-08-01T16:25:18+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", diff --git a/app/app/config/cache.php b/app/config/cache.php similarity index 95% rename from app/app/config/cache.php rename to app/config/cache.php index 9ee13ff..615b8ca 100644 --- a/app/app/config/cache.php +++ b/app/config/cache.php @@ -44,7 +44,7 @@ 'file' => [ // Alias for FileStorage type 'type' => 'file', - 'path' => directory('runtime') . 'cache', + 'path' => directory('runtime') . 'Cache', ], ], diff --git a/app/app/config/cycle.php b/app/config/cycle.php similarity index 100% rename from app/app/config/cycle.php rename to app/config/cycle.php diff --git a/app/app/config/database.php b/app/config/database.php similarity index 100% rename from app/app/config/database.php rename to app/config/database.php diff --git a/app/app/config/mailer.php b/app/config/mailer.php similarity index 100% rename from app/app/config/mailer.php rename to app/config/mailer.php diff --git a/app/app/config/migration.php b/app/config/migration.php similarity index 100% rename from app/app/config/migration.php rename to app/config/migration.php diff --git a/app/app/config/queue.php b/app/config/queue.php similarity index 100% rename from app/app/config/queue.php rename to app/config/queue.php diff --git a/app/app/config/scaffolder.php b/app/config/scaffolder.php similarity index 100% rename from app/app/config/scaffolder.php rename to app/config/scaffolder.php diff --git a/app/app/config/session.php b/app/config/session.php similarity index 89% rename from app/app/config/session.php rename to app/config/session.php index 5d90ecc..ac2756e 100644 --- a/app/app/config/session.php +++ b/app/config/session.php @@ -18,7 +18,7 @@ 'handler' => new Autowire( FileHandler::class, [ - 'directory' => directory('runtime') . 'session', + 'directory' => directory('runtime') . 'Session', 'lifetime' => (int) env('SESSION_LIFETIME', 86400), ] ), diff --git a/app/app/config/storage.php b/app/config/storage.php similarity index 100% rename from app/app/config/storage.php rename to app/config/storage.php diff --git a/app/app/config/temporal.php b/app/config/temporal.php similarity index 100% rename from app/app/config/temporal.php rename to app/config/temporal.php diff --git a/app/app/migrations/.gitignore b/app/migrations/.gitignore similarity index 100% rename from app/app/migrations/.gitignore rename to app/migrations/.gitignore diff --git a/app/app/migrations/20230222.132457_0_0_default_create_users.php b/app/migrations/20230222.132457_0_0_default_create_users.php similarity index 100% rename from app/app/migrations/20230222.132457_0_0_default_create_users.php rename to app/migrations/20230222.132457_0_0_default_create_users.php diff --git a/app/pest.xml.dist b/app/pest.xml.dist index 71d3a8a..db1d89a 100644 --- a/app/pest.xml.dist +++ b/app/pest.xml.dist @@ -20,7 +20,7 @@ - app/src + src diff --git a/app/phpstan-baseline.neon b/app/phpstan-baseline.neon new file mode 100644 index 0000000..55dd25f --- /dev/null +++ b/app/phpstan-baseline.neon @@ -0,0 +1,131 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\$port of class Cycle\\\\Database\\\\Config\\\\MySQL\\\\TcpConnectionConfig constructor expects int\\<1, max\\>\\|numeric\\-string, int given\\.$#" + count: 1 + path: config/database.php + + - + message: "#^Parameter \\$port of class Cycle\\\\Database\\\\Config\\\\Postgres\\\\TcpConnectionConfig constructor expects int\\<1, max\\>\\|numeric\\-string, int given\\.$#" + count: 1 + path: config/database.php + + - + message: "#^Method App\\\\Application\\\\Bootloader\\\\LoggingBootloader\\:\\:__construct\\(\\) has parameter \\$config with generic interface Spiral\\\\Config\\\\ConfiguratorInterface but does not specify its types\\: TClass$#" + count: 1 + path: src/Application/Bootloader/LoggingBootloader.php + + - + message: "#^Property App\\\\Application\\\\Bootloader\\\\LoggingBootloader\\:\\:\\$config is never read, only written\\.$#" + count: 1 + path: src/Application/Bootloader/LoggingBootloader.php + + - + message: "#^Method App\\\\Application\\\\Bootloader\\\\RoutesBootloader\\:\\:middlewareGroups\\(\\) return type with generic class Spiral\\\\Core\\\\Container\\\\Autowire does not specify its types\\: TObject$#" + count: 1 + path: src/Application/Bootloader/RoutesBootloader.php + + - + message: "#^Class App\\\\Domain\\\\User\\\\Entity\\\\User has an uninitialized readonly property \\$id\\. Assign it in the constructor\\.$#" + count: 1 + path: src/Domain/User/Entity/User.php + + - + message: "#^Property App\\\\Domain\\\\User\\\\Entity\\\\User\\:\\:\\$id is never written, only read\\.$#" + count: 1 + path: src/Domain/User/Entity/User.php + + - + message: "#^Class App\\\\Endpoint\\\\Console\\\\CreateUserCommand has an uninitialized readonly property \\$email\\. Assign it in the constructor\\.$#" + count: 1 + path: src/Endpoint/Console/CreateUserCommand.php + + - + message: "#^Class App\\\\Endpoint\\\\Console\\\\CreateUserCommand has an uninitialized readonly property \\$username\\. Assign it in the constructor\\.$#" + count: 1 + path: src/Endpoint/Console/CreateUserCommand.php + + - + message: "#^Property App\\\\Endpoint\\\\Console\\\\CreateUserCommand\\:\\:\\$email is never written, only read\\.$#" + count: 1 + path: src/Endpoint/Console/CreateUserCommand.php + + - + message: "#^Property App\\\\Endpoint\\\\Console\\\\CreateUserCommand\\:\\:\\$username is never written, only read\\.$#" + count: 1 + path: src/Endpoint/Console/CreateUserCommand.php + + - + message: "#^Class App\\\\Endpoint\\\\Console\\\\DoNothing has an uninitialized readonly property \\$name\\. Assign it in the constructor\\.$#" + count: 1 + path: src/Endpoint/Console/DoNothing.php + + - + message: "#^Property App\\\\Endpoint\\\\Console\\\\DoNothing\\:\\:\\$name is never written, only read\\.$#" + count: 1 + path: src/Endpoint/Console/DoNothing.php + + - + message: "#^Class App\\\\Endpoint\\\\Console\\\\PingCommand has an uninitialized readonly property \\$site\\. Assign it in the constructor\\.$#" + count: 1 + path: src/Endpoint/Console/PingCommand.php + + - + message: "#^Property App\\\\Endpoint\\\\Console\\\\PingCommand\\:\\:\\$site is never written, only read\\.$#" + count: 1 + path: src/Endpoint/Console/PingCommand.php + + - + message: "#^Method Spiral\\\\Logger\\\\LogsInterface\\:\\:getLogger\\(\\) invoked with 0 parameters, 1 required\\.$#" + count: 1 + path: src/Endpoint/Job/Ping.php + + - + message: "#^Method App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:cast\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Method App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:cast\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Method App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:uncast\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Method App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:uncast\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Property App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:\\$database is never read, only written\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Property App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:\\$rules type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php + + - + message: "#^Method Spiral\\\\Logger\\\\LogsInterface\\:\\:getLogger\\(\\) invoked with 0 parameters, 1 required\\.$#" + count: 1 + path: src/Temporal/PaymentActivity.php + + - + message: "#^Method App\\\\Temporal\\\\PaymentWorkflowInterface\\:\\:start\\(\\) has no return type specified\\.$#" + count: 1 + path: src/Temporal/PaymentWorkflowInterface.php + + - + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\) with false will always evaluate to true\\.$#" + count: 1 + path: tests/Unit/DemoTest.php + + - + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with true will always evaluate to true\\.$#" + count: 1 + path: tests/Unit/DemoTest.php diff --git a/app/phpstan.neon.dist b/app/phpstan.neon.dist new file mode 100644 index 0000000..ec081f3 --- /dev/null +++ b/app/phpstan.neon.dist @@ -0,0 +1,13 @@ +includes: + - phpstan-baseline.neon +parameters: + # The level 9 is the highest level + level: 8 + paths: + - config/ + - migrations/ + - src/ + - tests/ + excludePaths: + - tests/src/Arch + tmpDir: .build/phpstan/ diff --git a/app/phpunit.xml.dist b/app/phpunit.xml.dist index 4e47d9e..fbe2024 100644 --- a/app/phpunit.xml.dist +++ b/app/phpunit.xml.dist @@ -33,7 +33,7 @@ - app/src + src diff --git a/app/psalm-baseline.xml b/app/psalm-baseline.xml index e436083..bb3ba94 100644 --- a/app/psalm-baseline.xml +++ b/app/psalm-baseline.xml @@ -1,18 +1,26 @@ - + + + + + + dump((new VarCloner())->cloneVar($var), true)]]> + + + - + - + @@ -21,37 +29,37 @@ - + - + - + - + - + - + - + @@ -60,12 +68,12 @@ - + - + @@ -82,7 +90,7 @@ - + @@ -91,12 +99,12 @@ - + - + @@ -104,18 +112,19 @@ - - - - - - dump((new VarCloner())->cloneVar($var), true)]]> - + + + + + + + + @@ -123,6 +132,9 @@ + + + diff --git a/app/psalm.xml b/app/psalm.xml index f32bdf0..68b4e34 100644 --- a/app/psalm.xml +++ b/app/psalm.xml @@ -16,7 +16,7 @@ - + diff --git a/app/app/src/Application/Bootloader/AppBootloader.php b/app/src/Application/Bootloader/AppBootloader.php similarity index 100% rename from app/app/src/Application/Bootloader/AppBootloader.php rename to app/src/Application/Bootloader/AppBootloader.php diff --git a/app/app/src/Application/Bootloader/ExceptionHandlerBootloader.php b/app/src/Application/Bootloader/ExceptionHandlerBootloader.php similarity index 100% rename from app/app/src/Application/Bootloader/ExceptionHandlerBootloader.php rename to app/src/Application/Bootloader/ExceptionHandlerBootloader.php diff --git a/app/app/src/Application/Bootloader/LoggingBootloader.php b/app/src/Application/Bootloader/LoggingBootloader.php similarity index 100% rename from app/app/src/Application/Bootloader/LoggingBootloader.php rename to app/src/Application/Bootloader/LoggingBootloader.php diff --git a/app/app/src/Application/Bootloader/PersistenceBootloader.php b/app/src/Application/Bootloader/PersistenceBootloader.php similarity index 100% rename from app/app/src/Application/Bootloader/PersistenceBootloader.php rename to app/src/Application/Bootloader/PersistenceBootloader.php diff --git a/app/app/src/Application/Bootloader/RoutesBootloader.php b/app/src/Application/Bootloader/RoutesBootloader.php similarity index 100% rename from app/app/src/Application/Bootloader/RoutesBootloader.php rename to app/src/Application/Bootloader/RoutesBootloader.php diff --git a/app/app/src/Application/Exception/Handler.php b/app/src/Application/Exception/Handler.php similarity index 100% rename from app/app/src/Application/Exception/Handler.php rename to app/src/Application/Exception/Handler.php diff --git a/app/app/src/Application/Kernel.php b/app/src/Application/Kernel.php similarity index 100% rename from app/app/src/Application/Kernel.php rename to app/src/Application/Kernel.php diff --git a/app/app/src/Domain/User/Entity/User.php b/app/src/Domain/User/Entity/User.php similarity index 100% rename from app/app/src/Domain/User/Entity/User.php rename to app/src/Domain/User/Entity/User.php diff --git a/app/app/src/Domain/User/Exception/UserNotFoundException.php b/app/src/Domain/User/Exception/UserNotFoundException.php similarity index 100% rename from app/app/src/Domain/User/Exception/UserNotFoundException.php rename to app/src/Domain/User/Exception/UserNotFoundException.php diff --git a/app/app/src/Domain/User/Repository/UserRepositoryInterface.php b/app/src/Domain/User/Repository/UserRepositoryInterface.php similarity index 100% rename from app/app/src/Domain/User/Repository/UserRepositoryInterface.php rename to app/src/Domain/User/Repository/UserRepositoryInterface.php diff --git a/app/app/src/Domain/User/Service/CreateUserService.php b/app/src/Domain/User/Service/CreateUserService.php similarity index 100% rename from app/app/src/Domain/User/Service/CreateUserService.php rename to app/src/Domain/User/Service/CreateUserService.php diff --git a/app/app/src/Endpoint/Console/CreateUserCommand.php b/app/src/Endpoint/Console/CreateUserCommand.php similarity index 100% rename from app/app/src/Endpoint/Console/CreateUserCommand.php rename to app/src/Endpoint/Console/CreateUserCommand.php diff --git a/app/app/src/Endpoint/Console/DoNothing.php b/app/src/Endpoint/Console/DoNothing.php similarity index 100% rename from app/app/src/Endpoint/Console/DoNothing.php rename to app/src/Endpoint/Console/DoNothing.php diff --git a/app/app/src/Endpoint/Console/PingCommand.php b/app/src/Endpoint/Console/PingCommand.php similarity index 100% rename from app/app/src/Endpoint/Console/PingCommand.php rename to app/src/Endpoint/Console/PingCommand.php diff --git a/app/app/src/Endpoint/Job/Ping.php b/app/src/Endpoint/Job/Ping.php similarity index 100% rename from app/app/src/Endpoint/Job/Ping.php rename to app/src/Endpoint/Job/Ping.php diff --git a/app/app/src/Endpoint/Web/HomeController.php b/app/src/Endpoint/Web/HomeController.php similarity index 100% rename from app/app/src/Endpoint/Web/HomeController.php rename to app/src/Endpoint/Web/HomeController.php diff --git a/app/app/src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php b/app/src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php similarity index 100% rename from app/app/src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php rename to app/src/Infrastructure/CycleORM/Typecaster/UuidTypecast.php diff --git a/app/app/src/Infrastructure/Persistence/CycleORMUserRepository.php b/app/src/Infrastructure/Persistence/CycleORMUserRepository.php similarity index 100% rename from app/app/src/Infrastructure/Persistence/CycleORMUserRepository.php rename to app/src/Infrastructure/Persistence/CycleORMUserRepository.php diff --git a/app/app/src/Temporal/PaymentActivity.php b/app/src/Temporal/PaymentActivity.php similarity index 100% rename from app/app/src/Temporal/PaymentActivity.php rename to app/src/Temporal/PaymentActivity.php diff --git a/app/app/src/Temporal/PaymentActivityInterface.php b/app/src/Temporal/PaymentActivityInterface.php similarity index 100% rename from app/app/src/Temporal/PaymentActivityInterface.php rename to app/src/Temporal/PaymentActivityInterface.php diff --git a/app/app/src/Temporal/PaymentWorkflow.php b/app/src/Temporal/PaymentWorkflow.php similarity index 100% rename from app/app/src/Temporal/PaymentWorkflow.php rename to app/src/Temporal/PaymentWorkflow.php diff --git a/app/app/src/Temporal/PaymentWorkflowInterface.php b/app/src/Temporal/PaymentWorkflowInterface.php similarity index 100% rename from app/app/src/Temporal/PaymentWorkflowInterface.php rename to app/src/Temporal/PaymentWorkflowInterface.php diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php index f8737be..4d125a4 100644 --- a/app/tests/TestCase.php +++ b/app/tests/TestCase.php @@ -36,6 +36,8 @@ protected function setUp(): void protected function tearDown(): void { + parent::tearDown(); + // Uncomment this line if you want to clean up runtime directory. // $this->cleanUpRuntimeDirectory(); } @@ -62,6 +64,11 @@ public function defineDirectories(string $root): array { return [ 'root' => $root, + 'app' => $root . '/src', + 'config' => $root . '/config', + 'public' => $root . '/public', + 'runtime' => $root . '/runtime', + 'views' => $root . '/views', ]; } } diff --git a/app/app/views/home.php b/app/views/home.php similarity index 100% rename from app/app/views/home.php rename to app/views/home.php From b7ce21cbd4caa6fb8f1586bef45128147295e266 Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 2 Aug 2024 00:03:22 +0300 Subject: [PATCH 13/15] ci: add infection config --- app/infection.json.dist | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 app/infection.json.dist diff --git a/app/infection.json.dist b/app/infection.json.dist new file mode 100644 index 0000000..ebcde0e --- /dev/null +++ b/app/infection.json.dist @@ -0,0 +1,20 @@ +{ + "ignoreMsiWithNoMutations": true, + "logs": { + "text": ".build/infection/infection-log.txt", + "stryker": { + "report": "develop" + } + }, + "minCoveredMsi": 5, + "minMsi": 2, + "phpUnit": { + "configDir": "./" + }, + "source": { + "directories": [ + "src" + ] + }, + "timeout": 10 +} From 5a866d0a2f8fa62c7c650c2b50148d918d6e1b59 Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 2 Aug 2024 00:17:35 +0300 Subject: [PATCH 14/15] fix: env loading and caching issues --- .env.example | 2 +- .github/workflows/static-analysis.yml | 11 ----------- app/config/cache.php | 17 ++++++----------- app/pest.xml.dist | 2 +- app/phpunit.xml.dist | 2 +- docker-compose.yaml | 2 -- 6 files changed, 9 insertions(+), 27 deletions(-) diff --git a/.env.example b/.env.example index a026d61..684da0c 100644 --- a/.env.example +++ b/.env.example @@ -38,7 +38,7 @@ MONOLOG_DEFAULT_LEVEL=DEBUG QUEUE_CONNECTION=in-memory -CACHE_STORAGE=rr-local +CACHE_STORAGE=roadrunner STORAGE_DEFAULT=default diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 4782544..a977625 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -5,17 +5,6 @@ on: # yamllint disable-line rule:truthy branches: - master - develop - paths: - - 'app/config/**' - - 'app/src/**' - - 'app/tests/**' - - 'app/.php-cs-fixer.dist.php' - - 'app/composer.json' - - 'app/composer.lock' - - 'app/phpstan.neon.dist' - - 'app/phpstan-baseline.neon' - - 'app/psalm.xml' - - 'app/psalm-baseline.xml' name: 🔍 Static analysis diff --git a/app/config/cache.php b/app/config/cache.php index 615b8ca..49a92ce 100644 --- a/app/config/cache.php +++ b/app/config/cache.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use Spiral\Cache\Storage\ArrayStorage; use Spiral\Cache\Storage\FileStorage; /** @@ -14,35 +13,31 @@ /* * The default cache connection that gets used while using this caching library. */ - 'default' => env('CACHE_STORAGE', 'rr-local'), + 'default' => env('CACHE_STORAGE', 'roadrunner'), /* * Aliases, if you want to use domain specific storages. */ 'aliases' => [ // 'user-data' => [ - // 'storage' => 'rr-local', + // 'storage' => 'roadrunner', // 'prefix' => 'user_' // ], - // 'blog-data' => 'rr-local', + // 'blog-data' => 'roadrunner', ], /* - * Here you may define all of the cache "storages" for your application as well as their types. + * Here you may define all the cache "storages" for your application as well as their types. */ 'storages' => [ - 'rr-local' => [ + 'roadrunner' => [ 'type' => 'roadrunner', 'driver' => 'local', ], - - 'local' => [ - // Alias for ArrayStorage type + 'array' => [ 'type' => 'array', ], - 'file' => [ - // Alias for FileStorage type 'type' => 'file', 'path' => directory('runtime') . 'Cache', ], diff --git a/app/pest.xml.dist b/app/pest.xml.dist index db1d89a..6fd8151 100644 --- a/app/pest.xml.dist +++ b/app/pest.xml.dist @@ -27,10 +27,10 @@ - + diff --git a/app/phpunit.xml.dist b/app/phpunit.xml.dist index fbe2024..1d63c21 100644 --- a/app/phpunit.xml.dist +++ b/app/phpunit.xml.dist @@ -40,10 +40,10 @@ - + diff --git a/docker-compose.yaml b/docker-compose.yaml index 6da918d..545bc16 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -28,8 +28,6 @@ services: FAKETIME: '+2h' XDEBUG_MODE: '${XDEBUG_MODE:-off}' PHIVE_HOME: /app/.phive - env_file: - - .env dns: 8.8.8.8 command: /app/rr serve From 054c360a4e13db3dbe0f642f4b832f21062fd926 Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 2 Aug 2024 01:03:53 +0300 Subject: [PATCH 15/15] ci: fix static analysis --- .github/workflows/static-analysis.yml | 1 - app/functions.php | 20 -------------------- app/phpstan-baseline.neon | 5 +++++ app/psalm-baseline.xml | 17 +++++++++-------- 4 files changed, 14 insertions(+), 29 deletions(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index a977625..cec6127 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -3,7 +3,6 @@ on: # yamllint disable-line rule:truthy pull_request: branches: - - master - develop name: 🔍 Static analysis diff --git a/app/functions.php b/app/functions.php index bd4287b..174d7fd 100644 --- a/app/functions.php +++ b/app/functions.php @@ -1,23 +1,3 @@ addDump( - $dumper->dump((new VarCloner())->cloneVar($var), true) - ); - } - - throw $throwable; - } -} diff --git a/app/phpstan-baseline.neon b/app/phpstan-baseline.neon index 55dd25f..fb0e760 100644 --- a/app/phpstan-baseline.neon +++ b/app/phpstan-baseline.neon @@ -80,6 +80,11 @@ parameters: count: 1 path: src/Endpoint/Job/Ping.php + - + message: "#^Access to an undefined property App\\\\Endpoint\\\\Web\\\\HomeController\\:\\:\\$views\\.$#" + count: 1 + path: src/Endpoint/Web/HomeController.php + - message: "#^Method App\\\\Infrastructure\\\\CycleORM\\\\Typecaster\\\\UuidTypecast\\:\\:cast\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" count: 1 diff --git a/app/psalm-baseline.xml b/app/psalm-baseline.xml index bb3ba94..90aa44c 100644 --- a/app/psalm-baseline.xml +++ b/app/psalm-baseline.xml @@ -1,13 +1,5 @@ - - - - - - dump((new VarCloner())->cloneVar($var), true)]]> - - @@ -69,6 +61,15 @@ + + + + + + + + views->render('home')]]> +