Skip to content

Commit

Permalink
Merge pull request #163 from Hi-Folks/upgrade/larastan-gh-actions
Browse files Browse the repository at this point in the history
Upgrading Larastan GH actions
  • Loading branch information
roberto-butti authored Mar 17, 2024
2 parents 9503064 + 7adbc71 commit d4481ae
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 11 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/hi_folksghygen-20240317-214618.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: hi-folks/ghygen
on:
push:
branches:
- main
- develop
- features/**
- upgrade/**

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 i
- name: Build frontend
run: npm run build
- 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
2 changes: 1 addition & 1 deletion resources/views/action_yaml.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
4 changes: 2 additions & 2 deletions tests/Feature/mock-asserts/phpstan-install.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/Feature/mock-asserts/phpstan-noinstall.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d4481ae

Please sign in to comment.