Skip to content

Commit

Permalink
Merge pull request #46 from Hi-Folks/develop
Browse files Browse the repository at this point in the history
Merge from develop
  • Loading branch information
roberto-butti authored Apr 9, 2021
2 parents 4ac9be9 + e7b2f8e commit a5c3007
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 123 deletions.
148 changes: 67 additions & 81 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,70 @@
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

strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.0','7.4' ]
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}}

steps:
- uses: actions/checkout@v2

- 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: 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: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via PHPUnit
# Set environment
env:
SESSION_DRIVER: array

run: vendor/bin/phpunit --testdox
laravel-tests:
runs-on: ubuntu-latest

strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.0','7.4','7.3' ]
dependency-stability: [ prefer-stable ]

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: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist




- name: Show dir
run: pwd
- name: PHP Version
run: php --version

- 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: |
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
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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


4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
52 changes: 22 additions & 30 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" />
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<php>
<env name="DB_CONNECTION" value="testing" />
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="DB_CONNECTION" value="testing"/>
</php>
</phpunit>
32 changes: 32 additions & 0 deletions phpunit.xml.dist.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" />
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<php>
<env name="DB_CONNECTION" value="testing" />
</php>
</phpunit>
8 changes: 4 additions & 4 deletions src/Console/LaraLensCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down Expand Up @@ -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());
Expand Down
5 changes: 3 additions & 2 deletions src/Lens/Traits/DatabaseLens.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand All @@ -56,7 +57,7 @@ public function dbConnection()
}

public function getDatabaseConnectionInfos(
ConnectionInterface $dbConnection,
Connection $dbConnection,
ResultLens $results,
$checkTable,
$columnSorting
Expand Down
2 changes: 1 addition & 1 deletion src/Lens/Traits/FilesystemLens.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down

0 comments on commit a5c3007

Please sign in to comment.