Skip to content

Commit

Permalink
Upgrading larastan/larastan usage in Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-butti committed Mar 17, 2024
1 parent 9503064 commit 894500b
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 7 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/hi_folksghygen-20240317-214618.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/Console/Commands/GenerateWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 !== '') {
Expand Down
4 changes: 2 additions & 2 deletions app/Objects/GuesserFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions resources/views/yaml/code_quality.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 894500b

Please sign in to comment.