Skip to content

Commit

Permalink
Merge pull request #116 from Hi-Folks/develop
Browse files Browse the repository at this point in the history
v0.4.3
  • Loading branch information
roberto-butti authored Oct 19, 2021
2 parents 8d0802f + 059b6cd commit d990674
Show file tree
Hide file tree
Showing 54 changed files with 2,176 additions and 1,751 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/auto-generated-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
branches:
- main
- develop
- features/**

jobs:
laravel-tests:
Expand Down Expand Up @@ -32,7 +31,7 @@ jobs:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '7.4','8.0' ]
dependency-stability: [ prefer-stable ]
dependency-stability: [ 'prefer-stable' ]

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

Expand Down Expand Up @@ -93,7 +92,7 @@ jobs:
- 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 -c ./phpstan.neon --no-progress
94 changes: 94 additions & 0 deletions .github/workflows/dependency-stability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# GithHub Actions Workflow generated with Ghygen
# Original configuration: http://gh-actions-yaml-generator.test?code=598d9be9c7539d79c6fc033ff98593d7
name: dependency stability
on:
push:
branches:
- features/add_stability_level_options

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-none','prefer-stable','prefer-lowest' ]

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: '16.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:
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
53 changes: 53 additions & 0 deletions .github/workflows/psalm-sarif.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# GithHub Actions Workflow generated with Ghygen
# Original configuration: https://ghygen.hi-folks.dev?code=134510bb699cebfb255e85ec60955d59
name: Code Scanning - GitHub integration
on:
push:
branches:
- main
- develop

jobs:
laravel-tests:
runs-on: ubuntu-latest

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: 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: Generate key
run: php artisan key:generate

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

# Code quality



- name: Execute Code Static Analysis (PSALM)
run: |
vendor/bin/psalm --report=result.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v1
with:
# Path to SARIF file relative to the root of the repository
sarif_file: result.sarif
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Ghygen (Mysql) Quality Code PHP 8
on:
push:
branches:
- features/**
- tests/**

jobs:
laravel-tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ name: Ghygen (Mysql) Quality Code PHP 8,7
on:
push:
branches:
- main
- develop
- tests/**

jobs:
laravel-tests:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Changelog

## 0.4.3 - 2021-10-19
It is still Hacktoberfest!
- Psalm, create Sarif report for GitHub code scanning integration
- update to Alpinejs 3
- Allow user to set dependency stability (none, the latest stable, the lowest stable), thanks to @marulitua
- Phpstan Level 6 (from 5 to 6, report missing typehints)

## 0.4.2 - 2021-10-12
Hacktoberfest, goes on...
- Updated Cover image
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ __Ghygen__ allows you creating your __Yaml__ file for __GitHub Actions__, for La
- run migrations;
- __execute tests__ via phpunit;
- __execute tests__ via PestPHP;
- static __code analysis__ with phpstan or psalm;
- static __code analysis__ with phpstan or psalm;
- create Sarif report (with Psalm) for __GitHub integration with code scanning__;
- code sniffer (via phpcs for __PSR12__ compatibility);
- __validate Yaml__ file;
- execute __Browser Test__ via Laravel Dusk.
Expand Down
11 changes: 11 additions & 0 deletions app/Console/Commands/GenerateWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class GenerateWorkflow extends Command
{--projectdir= : the directory of the project with composer.json}
{--cache : enable caching packages in the workflow}
{--envfile=' . GuesserFiles::ENV_DEFAULT_TEMPLATE_FILE . ' : the .env file to use in the workflow}
{--prefer-stable : Prefer stable versions of dependencies}
{--prefer-lowest : Prefer lowest versions of dependencies}
';


Expand Down Expand Up @@ -70,6 +72,15 @@ public function handle()
$generator->name = Arr::get($composer, 'name');
$phpversion = Arr::get($composer, 'require.php', "");
$generator->detectPhpVersion($phpversion);
if ($this->option("prefer-stable") && $this->option("prefer-lowest")) {
$generator->dependencyStability = [ 'prefer-stable', 'prefer-lowest' ];
} elseif ($this->option("prefer-lowest")) {
$generator->dependencyStability = [ 'prefer-lowest' ];
} elseif ($this->option("prefer-stable")) {
$generator->dependencyStability = [ 'prefer-stable' ];
} else {
$generator->dependencyStability = [ 'prefer-none' ];
}

// detect packages
$devPackages = Arr::get($composer, 'require-dev');
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Kernel extends ConsoleKernel
/**
* The Artisan commands provided by your application.
*
* @var array
* @var array<mixed>
*/
protected $commands = [
//
Expand Down
4 changes: 2 additions & 2 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Handler extends ExceptionHandler
/**
* A list of the exception types that are not reported.
*
* @var array
* @var array<mixed>
*/
protected $dontReport = [
//
Expand All @@ -19,7 +19,7 @@ class Handler extends ExceptionHandler
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
* @var array<string>
*/
protected $dontFlash = [
'password',
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Kernel extends HttpKernel
*
* These middleware are run during every request to your application.
*
* @var array
* @var array<mixed>
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
Expand All @@ -26,7 +26,7 @@ class Kernel extends HttpKernel
/**
* The application's route middleware groups.
*
* @var array
* @var array<mixed>
*/
protected $middlewareGroups = [
'web' => [
Expand All @@ -50,7 +50,7 @@ class Kernel extends HttpKernel
*
* These middleware may be assigned to groups or used individually.
*
* @var array
* @var array<mixed>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
Expand Down
23 changes: 16 additions & 7 deletions app/Http/Livewire/ConfiguratorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,29 @@ class ConfiguratorForm extends Component
use LaravelStuff;
use Deploy;

public $code = "";
public $template = "";
public string $code = "";
public string $template = "";

/**
* @var array<mixed>
*/
protected $queryString = [
'code' => ['except' => ''],
'template' => ['except' => '']
];


public $result;
public $errorGeneration;
public string $result;
public string $errorGeneration;

/**
* @var array<mixed>
*/
public $hints;

/**
* @var array<mixed>
*/
protected $rules = [
'name' => 'required|string',
'onPushBranches' => 'exclude_unless:onPush,1|required',
Expand All @@ -74,7 +83,7 @@ private function loadDefaults(): void
}


private function loadFromJson($j): void
private function loadFromJson(object $j): void
{
$this->loadBaseWorkflowFromJson($j);
$this->loadCodeQualityFromJson($j);
Expand Down Expand Up @@ -112,13 +121,13 @@ public function mount(): void



public function updated($propertyName): void
public function updated(string $propertyName): void
{
$this->result = " ";
}


public function template($x): void
public function template(string $x): void
{
if (in_array($x, ["laravelapp", "laravelpostgresql", "laravelpackage", "phppackage"])) {
$this->template = $x;
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Livewire/Dashboard/Daily.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

class Daily extends Component
{
/**
* @var \Illuminate\Support\Collection $daily
*/
public $daily;

public function mount(): void
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Livewire/Dashboard/Latest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

class Latest extends Component
{
/**
* @var mixed $latest
*/
public $latest;

public function mount(): void
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Livewire/Dashboard/Metrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

class Metrics extends Component
{
public $count;
public $total;
public $last4hours;
public $last24hours;
public $last3days;
public int $count;
public int $total;
public int $last4hours;
public int $last24hours;
public int $last3days;

public function mount(): void
{
Expand Down
Loading

0 comments on commit d990674

Please sign in to comment.