From 948c22d5a8984df215ec88394d5835b5cd7a0777 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Thu, 8 Apr 2021 22:13:24 +0200 Subject: [PATCH 01/12] Workflow for test package --- .github/workflows/test.yml | 135 ++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 68 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 58fe6aa..60c1e36 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,84 +1,83 @@ -name: Test Laravel Github action +# GithHub Actions Workflow generated with Ghygen +# Original configuration: https://ghygen.hi-folks.dev?code=bb85a1693f8aa341b4c92d07cea283be +name: Test Laravel Package on: - push: - branches: - - main - - master - - develop - - features/** + push: + branches: + - main + - master + - develop + - features/** + - feature/** jobs: - laravel-tests: - runs-on: ubuntu-latest + laravel-tests: + runs-on: ubuntu-latest - strategy: - matrix: - operating-system: [ubuntu-latest] - php-versions: [ '8.0','7.4' ] - dependency-stability: [ prefer-stable ] + strategy: + matrix: + operating-system: [ubuntu-latest] + php-versions: [ '8.0','7.4','7.3' ] + dependency-stability: [ prefer-stable ] - laravel: [ '8.*','7.*' ] - include: - - laravel: 8.* - testbench: 6.* - - laravel: 7.* - testbench: 5.* + name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}} - name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}} + steps: + - uses: actions/checkout@v2 + - name: Install PHP versions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + - name: Get Composer Cache Directory 2 + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + - uses: actions/cache@v2 + id: actions-cache + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + - name: Cache PHP dependencies + uses: actions/cache@v2 + id: vendor-cache + with: + path: vendor + key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} + - 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 - steps: - - uses: actions/checkout@v2 + - name: Generate key + run: php artisan key:generate - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- + - name: Show Laravel versions + run: php artisan --version + - name: Show dir + run: pwd + - name: PHP Version + run: php --version - - name: Install PHP versions - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - - name: Get Composer Cache Directory 2 - id: composer-cache - run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" - - uses: actions/cache@v2 - id: actions-cache - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - name: Cache PHP dependencies - uses: actions/cache@v2 - id: vendor-cache - with: - path: vendor - key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} - - name: Copy .env - run: php -r "file_exists('.env') || copy('.env.example', '.env');" - - name: Install Laravel Dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest + - name: Execute tests (Unit and Feature tests) via PHPUnit + # Set environment + env: + SESSION_DRIVER: array + run: vendor/bin/phpunit --testdox + - name: Execute Code Sniffer via phpcs + run: | + composer require --dev squizlabs/php_codesniffer + vendor/bin/phpcs --standard=PSR12 app - - name: Create Database - run: | - mkdir -p database - touch database/database.sqlite + - 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 - - name: Execute tests (Unit and Feature tests) via PHPUnit -# Set environment - env: - SESSION_DRIVER: array - run: vendor/bin/phpunit --testdox From 4892232e764192f68c6fe3397cb358544eb55932 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Thu, 8 Apr 2021 22:18:27 +0200 Subject: [PATCH 02/12] avoid copy .env in workflow --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60c1e36..3769ca1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,8 +45,6 @@ jobs: with: path: vendor key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} - - 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 From 562f5c19896440f9b58ee3952832d4b48b81f948 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Thu, 8 Apr 2021 22:21:21 +0200 Subject: [PATCH 03/12] avoid key generate in workflow --- .github/workflows/test.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3769ca1..6b47c72 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,11 +49,9 @@ jobs: if: steps.vendor-cache.outputs.cache-hit != 'true' run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - name: Generate key - run: php artisan key:generate - - name: Show Laravel versions - run: php artisan --version + + - name: Show dir run: pwd - name: PHP Version From 5f0adfde957f5401348df0683d18a1565cd9f3a6 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Thu, 8 Apr 2021 22:25:53 +0200 Subject: [PATCH 04/12] src directory for phpcs and phpstan --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6b47c72..847fca4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -67,12 +67,12 @@ jobs: - name: Execute Code Sniffer via phpcs run: | composer require --dev squizlabs/php_codesniffer - vendor/bin/phpcs --standard=PSR12 app + vendor/bin/phpcs --standard=PSR12 src - 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 + vendor/bin/phpstan analyse src -c ./vendor/nunomaduro/larastan/extension.neon --level=4 --no-progress From 9875bdeca4fd0bd2b389f6043d70bd927fe20415 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Thu, 8 Apr 2021 22:27:33 +0200 Subject: [PATCH 05/12] fix style --- src/Lens/Traits/FilesystemLens.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Lens/Traits/FilesystemLens.php b/src/Lens/Traits/FilesystemLens.php index 6613fd1..8fb9e8e 100644 --- a/src/Lens/Traits/FilesystemLens.php +++ b/src/Lens/Traits/FilesystemLens.php @@ -68,7 +68,7 @@ public function checkFiles() $this->checksBag->addWarningAndHint( "Check storage target link", $this->stripPrefixDir($dir) . " it doesn't exist.", - "Create directory target (for storage link) : ".$dir + "Create directory target (for storage link) : " . $dir ); } From dc1eaa45c309b9c43711e6a4ea567f1137af7df7 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Thu, 8 Apr 2021 22:32:26 +0200 Subject: [PATCH 06/12] fix style --- src/Console/LaraLensCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Console/LaraLensCommand.php b/src/Console/LaraLensCommand.php index c6c91db..6a21ef6 100644 --- a/src/Console/LaraLensCommand.php +++ b/src/Console/LaraLensCommand.php @@ -22,8 +22,8 @@ class LaraLensCommand extends Command {--show=* : show (all|config|runtime|connection|database|migration|php-ext|php-ini)} {--width-label=' . self::DEFAULT_WIDTH . ' : width of column for label} {--width-value=' . self::DEFAULT_WIDTH . ' : width of column for value} - {--style=' . self::DEFAULT_STYLE . ' : style of the output table (' . self::TABLE_STYLES . ')} - {--skip-database : skip database check like connection and migration (if your laravel app doesn\'t need Database)} + {--style=' . self::DEFAULT_STYLE . ' : style for output table (' . self::TABLE_STYLES . ')} + {--skip-database : skip database check (if your laravel app doesn\'t need Database)} '; protected $description = 'Show some application configurations.'; From c916687f233ad591e26cfc69b41814f3e06d7516 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Thu, 8 Apr 2021 22:32:45 +0200 Subject: [PATCH 07/12] adding larastan and phpcs --- .github/workflows/test.yml | 5 ----- composer.json | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 847fca4..8764bff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,11 +69,6 @@ jobs: composer require --dev squizlabs/php_codesniffer vendor/bin/phpcs --standard=PSR12 src - - name: Execute Code Static Analysis (PHP Stan + Larastan) - run: | - composer require --dev nunomaduro/larastan - vendor/bin/phpstan analyse src -c ./vendor/nunomaduro/larastan/extension.neon --level=4 --no-progress - diff --git a/composer.json b/composer.json index 2a1baca..dc65599 100755 --- a/composer.json +++ b/composer.json @@ -28,8 +28,10 @@ "ext-json": "*" }, "require-dev": { + "nunomaduro/larastan": "^0.7.2", "orchestra/testbench": "4.*|5.*|6.*", - "phpunit/phpunit": "^8.0|^9.3" + "phpunit/phpunit": "^8.0|^9.3", + "squizlabs/php_codesniffer": "^3.5" }, "autoload": { "psr-4": { From 1c1376394730f66c87bb3e15b1f2f0bb204fad98 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Fri, 9 Apr 2021 07:05:39 +0200 Subject: [PATCH 08/12] Update Makefile --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f1af603..3329d69 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,18 @@ help: ## Show this help. @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' phpstan: ## Execute phpstan - phpstan analyse src --level=1 + vendor/bin/phpstan analyse src -c ./vendor/nunomaduro/larastan/extension.neon --level=4 --no-progress + test: ## Execute phpunit - vendor/bin/phpunit + vendor/bin/phpunit --testdox coverage: ## Execute the coverage test vendor/bin/phpunit --coverage-text phpcs: ## execute phpcs - phpcs src + vendor/bin/phpcs --standard=PSR12 src -allcheck: phpcs phpstan ## all check +allcheck: phpcs phpstan test ## all check From 9304f67801f62fbaf4305883aab646972a7e3a82 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Fri, 9 Apr 2021 07:05:57 +0200 Subject: [PATCH 09/12] update phpunit configuration --- phpunit.xml.dist | 52 +++++++++++++++++++------------------------- phpunit.xml.dist.bak | 32 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 30 deletions(-) create mode 100644 phpunit.xml.dist.bak diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2ad2830..c4fdcc3 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,32 +1,24 @@ - - - - tests - - - - - src/ - - - - - - - - - - - - + + + + src/ + + + + + + + + + + tests + + + + + + + + diff --git a/phpunit.xml.dist.bak b/phpunit.xml.dist.bak new file mode 100644 index 0000000..2ad2830 --- /dev/null +++ b/phpunit.xml.dist.bak @@ -0,0 +1,32 @@ + + + + + tests + + + + + src/ + + + + + + + + + + + + + From 8d7b267e4c9f77f2a8696a6b4bddab7a53d77aef Mon Sep 17 00:00:00 2001 From: Roberto B Date: Fri, 9 Apr 2021 07:06:27 +0200 Subject: [PATCH 10/12] Fix some "static code check" warning --- src/Console/LaraLensCommand.php | 4 ++-- src/Lens/Traits/DatabaseLens.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Console/LaraLensCommand.php b/src/Console/LaraLensCommand.php index 6a21ef6..187765a 100644 --- a/src/Console/LaraLensCommand.php +++ b/src/Console/LaraLensCommand.php @@ -198,11 +198,11 @@ private function overview($checkTable = "users", $columnSorting = "created_at", } } if ($show & self::OPTION_SHOW_PHPEXTENSIONS) { - $output = $ll->getPhpExtensions($checkTable, $columnSorting); + $output = $ll->getPhpExtensions(); $this->printOutput(["PHP Extensions"], $output->toArray()); } if ($show & self::OPTION_SHOW_PHPINIVALUES) { - $output = $ll->getPhpIniValues($checkTable, $columnSorting); + $output = $ll->getPhpIniValues(); $this->printOutput(["PHP ini config", "Values"], $output->toArray()); } $this->printChecks($ll->checksBag->toArray()); diff --git a/src/Lens/Traits/DatabaseLens.php b/src/Lens/Traits/DatabaseLens.php index 8f7e301..3dc10df 100644 --- a/src/Lens/Traits/DatabaseLens.php +++ b/src/Lens/Traits/DatabaseLens.php @@ -3,6 +3,7 @@ namespace HiFolks\LaraLens\Lens\Traits; use Illuminate\Database\ConnectionInterface; +use Illuminate\Database\Connection; use Illuminate\Database\QueryException; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; @@ -37,7 +38,7 @@ public function getTablesListSqlite() * Try to establish a db connection. * If it fails, return FALSE and fill checksBag. * - * @return false|\Illuminate\Database\ConnectionInterface + * @return false|\Illuminate\Database\Connection */ public function dbConnection() { @@ -56,7 +57,7 @@ public function dbConnection() } public function getDatabaseConnectionInfos( - ConnectionInterface $dbConnection, + Connection $dbConnection, ResultLens $results, $checkTable, $columnSorting From da64af7b2e95754372201ff7a88268cc16662973 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Fri, 9 Apr 2021 07:06:38 +0200 Subject: [PATCH 11/12] add phpstan to workflow --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8764bff..50660df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,8 +66,11 @@ jobs: - name: Execute Code Sniffer via phpcs run: | - composer require --dev squizlabs/php_codesniffer vendor/bin/phpcs --standard=PSR12 src + - name: Execute Code Static Generator via phpstan + run: | + vendor/bin/phpstan analyse src -c ./vendor/nunomaduro/larastan/extension.neon --level=4 --no-progress + From 2b05d412820af3e893b97328b7eb41c326cb39a6 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Fri, 9 Apr 2021 07:12:14 +0200 Subject: [PATCH 12/12] avoid aggressive cache for vendor in workflow --- .github/workflows/test.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 50660df..2c7477c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,14 +39,7 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: | ${{ runner.os }}-composer- - - name: Cache PHP dependencies - uses: actions/cache@v2 - id: vendor-cache - with: - path: vendor - key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} - 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