From 894500b3996d7207507b1e538aa6bdcf55462f26 Mon Sep 17 00:00:00 2001 From: Roberto Butti Date: Sun, 17 Mar 2024 22:47:42 +0100 Subject: [PATCH 1/7] Upgrading larastan/larastan usage in Workflow --- .../hi_folksghygen-20240317-214618.yml | 83 +++++++++++++++++++ CHANGELOG.md | 1 + app/Console/Commands/GenerateWorkflow.php | 6 +- app/Objects/GuesserFiles.php | 4 +- resources/views/yaml/code_quality.blade.php | 4 +- 5 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/hi_folksghygen-20240317-214618.yml diff --git a/.github/workflows/hi_folksghygen-20240317-214618.yml b/.github/workflows/hi_folksghygen-20240317-214618.yml new file mode 100644 index 0000000..858a8bc --- /dev/null +++ b/.github/workflows/hi_folksghygen-20240317-214618.yml @@ -0,0 +1,83 @@ +name: hi-folks/ghygen +on: + push: + branches: + - main + - develop + - features/** + +jobs: + laravel-tests: + runs-on: ubuntu-latest + + strategy: + matrix: + operating-system: [ubuntu-latest] + php-versions: [ '8.2' ] + dependency-stability: [ 'prefer-none' ] + + name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}} + + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + - name: Install NPM packages + run: npm ci + - name: Build frontend + run: npm run development + - name: Install PHP versions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.example', '.env');" + - name: Install Dependencies + if: steps.vendor-cache.outputs.cache-hit != 'true' + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: Update Dependencies with latest stable + if: matrix.dependency-stability == 'prefer-stable' + run: composer update --prefer-stable + - name: Update Dependencies with lowest stable + if: matrix.dependency-stability == 'prefer-lowest' + run: composer update --prefer-stable --prefer-lowest + + - name: Generate key + run: php artisan key:generate + - name: Directory Permissions + run: chmod -R 777 storage bootstrap/cache + - name: Run Migrations +# Set environment + env: + SESSION_DRIVER: array + DB_CONNECTION: sqlite + DB_DATABASE: ":memory:" + + run: php artisan migrate + + - name: Show dir + run: pwd + - name: PHP Version + run: php --version + +# Code quality + + - name: Execute tests (Unit and Feature tests) via PestPHP +# Set environment + env: + SESSION_DRIVER: array + DB_CONNECTION: sqlite + DB_DATABASE: ":memory:" + + run: vendor/bin/pest + + + + - name: Execute Code Static Analysis (PHP Stan + Larastan) + run: | + vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dd1cdd..57114cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - actions/checkout@v4 - actions/setup-node@v4 - actions/cache@v4 +- Upgrading larastan usage in the Workflow ## 1.0.0 - 2024-03-17 - Upgrading to Laravel v11 diff --git a/app/Console/Commands/GenerateWorkflow.php b/app/Console/Commands/GenerateWorkflow.php index 14319e1..5e524b0 100644 --- a/app/Console/Commands/GenerateWorkflow.php +++ b/app/Console/Commands/GenerateWorkflow.php @@ -111,7 +111,7 @@ public function handle() $generator->name ); - $phpversion = Arr::get($composer, 'require.php', '8.0'); + $phpversion = Arr::get($composer, 'require.php', '8.3'); $stepPhp = $generator->detectPhpVersion($phpversion); $reportExecution->addValueInfo('PHP versions', $stepPhp); @@ -154,7 +154,7 @@ public function handle() $reportExecution->addValueComment('Code sniffer', 'Not detected'); } // nunomaduro/larastan - $larastan = Arr::get($devPackages, 'nunomaduro/larastan', ''); + $larastan = Arr::get($devPackages, 'larastan/larastan', ''); if ($larastan !== '') { $generator->stepExecuteStaticAnalysis = true; $generator->stepInstallStaticAnalysis = false; @@ -237,7 +237,7 @@ public function handle() } if ($guesserFiles->packageExists()) { $generator->stepNodejs = true; - $generator->stepNodejsVersion = '18.x'; + $generator->stepNodejsVersion = '20.x'; $versionFromNvmrc = $generator->readNvmrc($guesserFiles ->getNvmrcPath()); if ($versionFromNvmrc !== '') { diff --git a/app/Objects/GuesserFiles.php b/app/Objects/GuesserFiles.php index 9347694..9d30015 100644 --- a/app/Objects/GuesserFiles.php +++ b/app/Objects/GuesserFiles.php @@ -190,8 +190,8 @@ private function somethingExists(string $methodPath, bool $isDirCheck = false): */ public static function detectLaravelVersionFromTestbench(string $testbenchVersion): array { - $listLaravelVersions = ['6.*', '7.*', '8.*', '9.*', '10.*']; - $listTestBenchVersions = ['4.0', '5.0', '6.0', '7.0', '8.0']; + $listLaravelVersions = ['6.*', '7.*', '8.*', '9.*', '10.*', '11.*']; + $listTestBenchVersions = ['4.0', '5.0', '6.0', '7.0', '8.0', '9.0']; $stepLaravelVersions = []; $i = 0; diff --git a/resources/views/yaml/code_quality.blade.php b/resources/views/yaml/code_quality.blade.php index 1e9a27d..6904232 100644 --- a/resources/views/yaml/code_quality.blade.php +++ b/resources/views/yaml/code_quality.blade.php @@ -31,12 +31,12 @@ - name: Execute Code Static Analysis (PHP Stan + Larastan) run: | @if ($stepInstallStaticAnalysis) - composer require --dev nunomaduro/larastan + composer require --dev larastan/larastan @endif @if ($stepPhpstanUseNeon) vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress @else - vendor/bin/phpstan analyse {{ $stepDirStaticAnalysis }} -c ./vendor/nunomaduro/larastan/extension.neon --level=4 --no-progress + vendor/bin/phpstan analyse {{ $stepDirStaticAnalysis }} -c ./vendor/larastan/larastan/extension.neon --level=4 --no-progress @endif @elseif ($stepToolStaticAnalysis == 'psalmlaravel') - name: Execute Code Static Analysis (PSALM) From f833802a27979e20aadfc43e697233249f3adc12 Mon Sep 17 00:00:00 2001 From: Roberto Butti Date: Sun, 17 Mar 2024 22:48:31 +0100 Subject: [PATCH 2/7] Update hi_folksghygen-20240317-214618.yml --- .github/workflows/hi_folksghygen-20240317-214618.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/hi_folksghygen-20240317-214618.yml b/.github/workflows/hi_folksghygen-20240317-214618.yml index 858a8bc..ddac72a 100644 --- a/.github/workflows/hi_folksghygen-20240317-214618.yml +++ b/.github/workflows/hi_folksghygen-20240317-214618.yml @@ -5,6 +5,7 @@ on: - main - develop - features/** + - upgrade/** jobs: laravel-tests: From da3cb2ac8a0c952c5020bff21c2a13b995a6974e Mon Sep 17 00:00:00 2001 From: Roberto Butti Date: Sun, 17 Mar 2024 22:50:11 +0100 Subject: [PATCH 3/7] Update phpstan-install.yaml --- tests/Feature/mock-asserts/phpstan-install.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Feature/mock-asserts/phpstan-install.yaml b/tests/Feature/mock-asserts/phpstan-install.yaml index 90e1506..98b175d 100644 --- a/tests/Feature/mock-asserts/phpstan-install.yaml +++ b/tests/Feature/mock-asserts/phpstan-install.yaml @@ -1,4 +1,4 @@ - name: Execute Code Static Analysis (PHP Stan + Larastan) run: | - composer require --dev nunomaduro/larastan - vendor/bin/phpstan analyse app -c ./vendor/nunomaduro/larastan/extension.neon --level=4 --no-progress + composer require --dev larastan/larastan + vendor/bin/phpstan analyse app -c ./vendor/larastan/larastan/extension.neon --level=4 --no-progress From 036095c05898e8b03e92f7f77f49ee17f62ab447 Mon Sep 17 00:00:00 2001 From: Roberto Butti Date: Sun, 17 Mar 2024 22:50:15 +0100 Subject: [PATCH 4/7] Update phpstan-noinstall.yaml --- tests/Feature/mock-asserts/phpstan-noinstall.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/mock-asserts/phpstan-noinstall.yaml b/tests/Feature/mock-asserts/phpstan-noinstall.yaml index 1f04ac4..dacb9d7 100644 --- a/tests/Feature/mock-asserts/phpstan-noinstall.yaml +++ b/tests/Feature/mock-asserts/phpstan-noinstall.yaml @@ -1,3 +1,3 @@ - name: Execute Code Static Analysis (PHP Stan + Larastan) run: | - vendor/bin/phpstan analyse app -c ./vendor/nunomaduro/larastan/extension.neon --level=4 --no-progress + vendor/bin/phpstan analyse app -c ./vendor/larastan/larastan/extension.neon --level=4 --no-progress From d96a76c72ccd968ddcd6950482f8f226515f0016 Mon Sep 17 00:00:00 2001 From: Roberto Butti Date: Sun, 17 Mar 2024 22:51:26 +0100 Subject: [PATCH 5/7] Update hi_folksghygen-20240317-214618.yml --- .github/workflows/hi_folksghygen-20240317-214618.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hi_folksghygen-20240317-214618.yml b/.github/workflows/hi_folksghygen-20240317-214618.yml index ddac72a..4e11ee4 100644 --- a/.github/workflows/hi_folksghygen-20240317-214618.yml +++ b/.github/workflows/hi_folksghygen-20240317-214618.yml @@ -26,7 +26,7 @@ jobs: with: node-version: '20.x' - name: Install NPM packages - run: npm ci + run: npm i - name: Build frontend run: npm run development - name: Install PHP versions From 6cc40bbe48f786c1b14bab4da97830d638161e73 Mon Sep 17 00:00:00 2001 From: Roberto Butti Date: Sun, 17 Mar 2024 22:55:00 +0100 Subject: [PATCH 6/7] Update hi_folksghygen-20240317-214618.yml --- .github/workflows/hi_folksghygen-20240317-214618.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hi_folksghygen-20240317-214618.yml b/.github/workflows/hi_folksghygen-20240317-214618.yml index 4e11ee4..eed53a9 100644 --- a/.github/workflows/hi_folksghygen-20240317-214618.yml +++ b/.github/workflows/hi_folksghygen-20240317-214618.yml @@ -28,7 +28,7 @@ jobs: - name: Install NPM packages run: npm i - name: Build frontend - run: npm run development + run: npm run build - name: Install PHP versions uses: shivammathur/setup-php@v2 with: From 7adbc7148c8c3ca6158c36895906dd02d5738f3e Mon Sep 17 00:00:00 2001 From: Roberto Butti Date: Sun, 17 Mar 2024 22:55:02 +0100 Subject: [PATCH 7/7] Update action_yaml.blade.php --- resources/views/action_yaml.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/action_yaml.blade.php b/resources/views/action_yaml.blade.php index 154e63f..8f71520 100644 --- a/resources/views/action_yaml.blade.php +++ b/resources/views/action_yaml.blade.php @@ -50,7 +50,7 @@ run: npm ci @endif - name: Build frontend - run: npm run development + run: npm run build @endif - name: Install PHP versions uses: shivammathur/setup-php@v2