Skip to content

Commit

Permalink
Merge pull request #109 from Hi-Folks/develop
Browse files Browse the repository at this point in the history
v0.4.2
  • Loading branch information
roberto-butti authored Oct 12, 2021
2 parents 5cb3fac + 81732ae commit 8d0802f
Show file tree
Hide file tree
Showing 21 changed files with 647 additions and 369 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/test-phpstanoption.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# GithHub Actions Workflow generated with Ghygen
# Original configuration: http://gh-actions-yaml-generator.test?code=bb2e7e3279c771efaea3812cad069ce7
name: fix-phpstan-option
on:
push:
branches:
- fix-phpstan-option

jobs:
laravel-tests:
runs-on: ubuntu-latest
# Service container Mysql mysql
services:
# Label used to access the service container
mysql:
# Docker Hub image (also with version)
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: db_test_laravel
## map the "external" 33306 port with the "internal" 3306
ports:
- 33306:3306
# Set health checks to wait until mysql database has started (it takes some seconds to start)
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.0','7.4' ]
dependency-stability: [ prefer-stable ]

name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}

steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '15.x'
- name: Cache node_modules directory
uses: actions/cache@v2
id: node_modules-cache
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}
- name: Install NPM packages
if: steps.node_modules-cache.outputs.cache-hit != 'true'
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: 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

- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Run Migrations
# Set environment
env:
DB_CONNECTION: mysql
DB_DATABASE: db_test_laravel
DB_PORT: 33306
DB_USER: root

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 PHPUnit
# Set environment
env:
DB_CONNECTION: mysql
DB_DATABASE: db_test_laravel
DB_PORT: 33306
DB_USER: root

run: vendor/bin/phpunit --testdox


- name: Execute Code Sniffer via phpcs
run: |
vendor/bin/phpcs --standard=PSR12 app
- name: Execute Code Static Analysis (PHP Stan + Larastan)
run: |
vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Changelog
## 0.4.2 - 2021-10-12
Hacktoberfest, goes on...
- Updated Cover image
- Using phpstan.neon file, thanks to @ActuallyConnor
- autodetect usage of phpstan.neon from command line
- better management of title and description in meta html tags. Thanks to @zaratedev


## 0.4.1 - 2021-10-03
It is time for Hacktoberfest!!!
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

phpstan: ## Execute phpstan
vendor/bin/phpstan analyse app -c ./vendor/nunomaduro/larastan/extension.neon --level=5 --no-progress
vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress

test: ## Execute phpunit
php artisan test
Expand Down
2 changes: 2 additions & 0 deletions app/Console/Commands/GenerateWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ public function handle()
$generator->stepExecuteStaticAnalysis = true;
$generator->stepInstallStaticAnalysis = false;
$generator->stepToolStaticAnalysis = "larastan";
$generator->stepPhpstanUseNeon = $guesserFiles->phpstanNeonExists();
} else {
$phpstan = Arr::get($devPackages, "phpstan/phpstan", "");
if ($phpstan !== "") {
$generator->stepExecuteStaticAnalysis = true;
$generator->stepInstallStaticAnalysis = false;
$generator->stepToolStaticAnalysis = "phpstan";
$generator->stepPhpstanUseNeon = $guesserFiles->phpstanNeonExists();
}
}
$generator->stepDusk = false;
Expand Down
17 changes: 5 additions & 12 deletions app/Http/Controllers/ConfiguratorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@ class ConfiguratorController extends Controller
{
public function index(): \Illuminate\View\View
{
$data = [];
$data["title"] = "Ghygen is a GitHub Actions configurator for your Laravel Application.";
$data["description"] = "Setup Database Service, use multiple PHP version,
use multiple Laravel versions, build frontend, cache packages,
execute Browser, Functional, and Unit tests…";
return view('configurator.index', $data);
return view('configurator.index');
}

public function about(): \Illuminate\View\View
{
$data = [];
$data["title"] = "Generate GitHub Actions Config for Laravel Projects with Ghygen";
$data["description"] = "Setup Database Service, use multiple PHP version,
use multiple Laravel versions, build frontend, cache packages,
execute Browser, Functional, and Unit tests…";
return view('configurator.about', $data);
return view('configurator.about', [
'title' => config('gh-action-yaml-generator.data.title_about'),
'description' => config('gh-action-yaml-generator.data.description'),
]);
}
}
7 changes: 1 addition & 6 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ class DashboardController extends Controller
{
public function index(): \Illuminate\View\View
{
$data = [];
$data["title"] = "Ghygen is a GitHub Actions configurator for your Laravel Application.";
$data["description"] = "Setup Database Service, use multiple PHP version,
use multiple Laravel versions, build frontend, cache packages,
execute Browser, Functional, and Unit tests…";
return view('dashboard.index', $data);
return view('dashboard.index');
}
}
13 changes: 13 additions & 0 deletions app/Objects/GuesserFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class GuesserFiles
public const NVMRC_FILE = ".nvmrc";
public const PACKAGE_FILE = "package.json";
public const ARTISAN_FILE = "artisan";
public const PHPSTANNEON_FILE = "phpstan.neon";
public const MIGRATIONS_DIR = "database" . DIRECTORY_SEPARATOR . "migrations";

public const COMPOSER_VAR = "composerFile";
Expand All @@ -22,6 +23,8 @@ class GuesserFiles
public const NVMRC_VAR = "nvmrcFile";
public const PACKAGE_VAR = "packageFile";
public const ARTISAN_VAR = "artisanFile";
public const PHPSTANNEON_VAR = "phpstanNeonFile";


public array $filePaths = [];

Expand All @@ -35,6 +38,7 @@ public function pathFiles(string $projectDir, string $optionEnvWorkflowFile = se
self::PACKAGE_VAR => self::PACKAGE_FILE,
self::ARTISAN_VAR => self::ARTISAN_FILE,
self::MIGRATIONS_VAR => self::MIGRATIONS_DIR,
self::PHPSTANNEON_VAR => self::PHPSTANNEON_FILE,
];
foreach ($arrayFiles as $variable => $file) {
$this->filePaths[$variable] = base_path($file);
Expand Down Expand Up @@ -105,6 +109,15 @@ public function artisanExists(): bool
return $this->somethingExists("getArtisanPath");
}

public function getPhpstanNeonPath(): string
{
return Arr::get($this->filePaths, self::PHPSTANNEON_VAR, "");
}
public function phpstanNeonExists(): bool
{
return $this->somethingExists("getPhpstanNeonPath");
}


public function getMigrationsPath(): string
{
Expand Down
23 changes: 23 additions & 0 deletions app/Providers/ViewServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Providers;

use App\View\Composers\AppDataComposer;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

class ViewServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
View::composer(
['configurator.index', 'dashboard.index'],
AppDataComposer::class
);
}
}
4 changes: 4 additions & 0 deletions app/Traits/Form/CodeQuality.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ trait CodeQuality
public $stepToolStaticAnalysis; // phpstan|larastan|psalmlaravel
public $stepInstallStaticAnalysis; //true
public $stepDusk; // false
public $stepPhpstanUseNeon; // false

public function loadDefaultsCodeQuality(): void
{
Expand All @@ -27,6 +28,7 @@ public function loadDefaultsCodeQuality(): void
$this->stepToolStaticAnalysis = "larastan";
$this->stepInstallStaticAnalysis = true;
$this->stepDusk = false;
$this->stepPhpstanUseNeon = false;
}

public function loadCodeQualityFromJson($j): void
Expand All @@ -37,6 +39,7 @@ public function loadCodeQualityFromJson($j): void
data_fill($j, "stepInstallStaticAnalysis", true);
data_fill($j, "stepToolStaticAnalysis", 'larastan');
data_fill($j, "stepExecutePestphp", false);
data_fill($j, "stepPhpstanUseNeon", false);
$this->stepExecutePhpunit = $j->stepExecutePhpunit;
$this->stepExecutePestphp = $j->stepExecutePestphp;
$this->stepExecuteCodeSniffer = $j->stepExecuteCodeSniffer;
Expand All @@ -61,6 +64,7 @@ public function setDataCodeQuality($data)
$data["stepToolStaticAnalysis"] = $this->stepToolStaticAnalysis;
$data["stepInstallStaticAnalysis"] = $this->stepInstallStaticAnalysis;
$data["stepDusk"] = $this->stepDusk;
$data["stepPhpstanUseNeon"] = $this->stepPhpstanUseNeon;

return $data;
}
Expand Down
16 changes: 16 additions & 0 deletions app/View/Composers/AppDataComposer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\View\Composers;

use Illuminate\View\View;

class AppDataComposer
{
public function compose(View $view)
{
$title = config('gh-action-yaml-generator.data.title');
$description = config('gh-action-yaml-generator.data.description');

$view->with(compact('title', 'description'));
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hifolks/gh-actions-yaml-generator",
"version": "0.4.1",
"version": "0.4.2",
"type": "project",
"description": "Ghygen is a GitHub Actions configurator for your Laravel Application.",
"keywords": [
Expand Down
Loading

0 comments on commit 8d0802f

Please sign in to comment.