Skip to content

Commit

Permalink
Merge pull request #61 from Hi-Folks/develop
Browse files Browse the repository at this point in the history
v0.2.5
  • Loading branch information
roberto-butti authored Apr 12, 2021
2 parents 06fa4c8 + 35eb615 commit 5436bb5
Show file tree
Hide file tree
Showing 24 changed files with 714 additions and 350 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/psr12-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ jobs:

- name: Execute Code Sniffer via phpcs
run: |
composer require --dev squizlabs/php_codesniffer
vendor/bin/phpcs --standard=PSR12 app
- 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
Expand Down
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Changelog

## 0.2.4 - WIP
## 0.2.5 - 2021-04-12
### Add
- New option for installing phpstan in workflow
- New option for installing phpcs in workflow
- New option for defining directory to check for phpcs ("app" default )
- New option for defining directory to check for phpstan ("app" default)
- New option for execute (or not) 'php artisan key:generate'
- New option for copying .env template
- Install Phpstan and phpcs as composer dev

### Change
- Upgrade PHP packages


## 0.2.4 - 2021-04-05
### Add
- Add Postgresql database

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ __Ghygen__ allows you creating your __Yaml__ file for __GitHub Actions__, for La
- select __multiple Laravel__ versions (8, 7, 6), useful if you are developing a Laravel Package and you want to test it with multiple Laravel version;
- select __Node__ version for NPM (npm run something);
- caching node packages;
- setup __Mysql__ service;
- setup __Mysql__ Database service;
- setup __PostgreSQL__ Database service;
- setup __Sqlite__ in memory database;
- run migrations;
- __execute tests__ via phpunit;
- static __code analysis__;
Expand Down
65 changes: 17 additions & 48 deletions app/Http/Livewire/ConfiguratorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Http\Livewire;

use App\Models\Configuration;
use App\Traits\Form\CodeQuality;
use App\Traits\Form\LaravelStuff;
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
use Illuminate\Support\Facades\Cache;
Expand All @@ -23,6 +25,8 @@
class ConfiguratorForm extends Component
{
use WithRateLimiting;
use CodeQuality;
use LaravelStuff;

public $code = "";

Expand All @@ -33,7 +37,6 @@ class ConfiguratorForm extends Component
public const DB_TYPE_SQLITE = "sqlite";
public const DB_TYPE_POSTGRESQL = "postgresql";


public $name;
public $onPush;
public $onPushBranches;
Expand All @@ -53,22 +56,14 @@ class ConfiguratorForm extends Component
public $postgresqlVersion;
public $postgresqlDatabaseName;
public $postgresqlDatabasePort;
public $stepEnvTemplateFile; // .env.ci
public $stepPhpVersions; // 7.4
public $stepNodejs; // false
public $stepNodejsVersion; // 12.x
public $stepCachePackages; //true
public $stepCacheVendors; //true
public $stepCacheNpmModules; // true
public $stepFixStoragePermissions; //true
public $stepRunMigrations; // true
public $stepExecutePhpunit; //true
public $stepExecuteCodeSniffer; //false
public $stepExecuteStaticAnalysis; // false
public $stepDusk; // false
public $matrixLaravel; // false
public $matrixLaravelVersions; // []
public $matrixTestbenchDependencies;



public $result;
public $errorGeneration;
Expand Down Expand Up @@ -110,27 +105,15 @@ private function loadDefaults()
$this->postgresqlVersion = "latest";
$this->postgresqlDatabaseName = "db_test_laravel";
$this->postgresqlDatabasePort = 55432;
$this->stepEnvTemplateFile = ".env.example";
$this->stepPhpVersions = ["8.0", "7.4"];
$this->stepNodejs = false;
$this->stepNodejsVersion = "14.x";
$this->stepCachePackages = true;
$this->stepCacheVendors = true;
$this->stepCacheNpmModules = true;
$this->stepFixStoragePermissions = true;
$this->stepRunMigrations = true;
$this->stepExecutePhpunit = true;
$this->stepExecuteCodeSniffer = false;
$this->stepExecuteStaticAnalysis = false;
$this->stepDusk = false;
$this->matrixLaravel = false;
$this->matrixLaravelVersions = [];
$this->matrixTestbenchDependencies = [
"8.*" => "6.*",
"7.*" => "5.*",
"6.*" => "4.*"
]; // mapping laravel versions with testbench version as dependency
// the key is the laravel ver, the value is the orchestratestbench version

$this->loadDefaultsCodeQuality();
$this->loadDefaultsLaravelStuff();
}

public function mount()
Expand Down Expand Up @@ -189,22 +172,15 @@ public function mount()
$j->postgresqlDatabasePort :
$this->postgresqlDatabasePort;
}
$this->stepEnvTemplateFile = $j->stepEnvTemplateFile;
$this->stepPhpVersions = $j->stepPhpVersions;
$this->stepNodejs = $j->stepNodejs;
$this->stepNodejsVersion = $j->stepNodejsVersion;
$this->stepCachePackages = $j->stepCachePackages;
$this->stepCacheVendors = $j->stepCacheVendors;
$this->stepCacheNpmModules = $j->stepCacheNpmModules;
$this->stepFixStoragePermissions = $j->stepFixStoragePermissions;
$this->stepRunMigrations = $j->stepRunMigrations;
$this->stepExecutePhpunit = $j->stepExecutePhpunit;
$this->stepExecuteCodeSniffer = $j->stepExecuteCodeSniffer;
$this->stepExecuteStaticAnalysis = $j->stepExecuteStaticAnalysis;
$this->stepDusk = $j->stepDusk;
$this->matrixLaravel = $j->matrixLaravel;
$this->matrixLaravelVersions = $j->matrixLaravelVersions;
$this->matrixTestbenchDependencies = (array) $j->matrixTestbenchDependencies;

$this->loadCodeQualityFromJson($j);
$this->loadLaravelStuffFromJson($j);
} else {
$codeNotFound = true;
}
Expand Down Expand Up @@ -318,27 +294,20 @@ public function submitForm()
"on_pullrequest",
"on_pullrequest_branches",
"manual_trigger",
"stepEnvTemplateFile",
"stepPhpVersions",
"stepNodejs",
"stepNodejsVersion",
"stepCachePackages",
"stepCacheVendors",
"stepCacheNpmModules",
"stepFixStoragePermissions",
"stepRunMigrations",
"stepExecutePhpunit",
"stepExecuteCodeSniffer",
"stepExecuteStaticAnalysis",
"stepDusk",
"matrixLaravel",
"matrixLaravelVersions",
"matrixTestbenchDependencies"
"stepCacheNpmModules"
);
$data = $this->setDataCodeQuality($data);
$data = $this->setDataLaravelStuff($data);

$data["stepPhpVersionsString"] = self::arrayToString($this->stepPhpVersions);
$data["on_pullrequest_branches"] = self::split($this->onPullrequestBranches);
$data["on_push_branches"] = self::split($this->onPushBranches);
$data["matrixLaravelVersionsString"] = self::arrayToString($this->matrixLaravelVersions);


$stringResult = view('action_yaml', $data)->render();
$this->errorGeneration = "";
Expand Down
57 changes: 57 additions & 0 deletions app/Traits/Form/CodeQuality.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace App\Traits\Form;

trait CodeQuality
{
public $stepExecutePhpunit; //true
public $stepExecuteCodeSniffer; //false
public $stepDirCodeSniffer; // app
public $stepInstallCodeSniffer; //true
public $stepExecuteStaticAnalysis; // false
public $stepDirStaticAnalysis; // app
public $stepInstallStaticAnalysis; //true
public $stepDusk; // false

public function loadDefaultsCodeQuality()
{
$this->stepExecutePhpunit = true;
$this->stepExecuteCodeSniffer = false;
$this->stepDirCodeSniffer = "app";
$this->stepInstallCodeSniffer = true;
$this->stepExecuteStaticAnalysis = false;
$this->stepDirStaticAnalysis = "app";
$this->stepInstallStaticAnalysis = true;
$this->stepDusk = false;
}

public function loadCodeQualityFromJson($j)
{
data_fill($j, "stepDirCodeSniffer", "app");
data_fill($j, "stepInstallCodeSniffer", true);
data_fill($j, "stepDirStaticAnalysis", "app");
data_fill($j, "stepInstallStaticAnalysis", true);
$this->stepExecutePhpunit = $j->stepExecutePhpunit;
$this->stepExecuteCodeSniffer = $j->stepExecuteCodeSniffer;
$this->stepDirCodeSniffer = $j->stepDirCodeSniffer;
$this->stepInstallCodeSniffer = $j->stepInstallCodeSniffer;
$this->stepExecuteStaticAnalysis = $j->stepExecuteStaticAnalysis;
$this->stepDirStaticAnalysis = $j->stepDirStaticAnalysis;
$this->stepInstallStaticAnalysis = $j->stepInstallStaticAnalysis;
$this->stepDusk = $j->stepDusk;
}

public function setDataCodeQuality($data)
{
$data["stepExecutePhpunit"] = $this->stepExecutePhpunit;
$data["stepExecuteCodeSniffer"] = $this->stepExecuteCodeSniffer;
$data["stepDirCodeSniffer"] = $this->stepDirCodeSniffer;
$data["stepInstallCodeSniffer"] = $this->stepInstallCodeSniffer;
$data["stepExecuteStaticAnalysis"] = $this->stepExecuteStaticAnalysis;
$data["stepDirStaticAnalysis"] = $this->stepDirStaticAnalysis;
$data["stepInstallStaticAnalysis"] = $this->stepInstallStaticAnalysis;
$data["stepDusk"] = $this->stepDusk;

return $data;
}
}
61 changes: 61 additions & 0 deletions app/Traits/Form/LaravelStuff.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace App\Traits\Form;

trait LaravelStuff
{
public $stepFixStoragePermissions; //true
public $stepRunMigrations; // true
public $stepGenerateKey; // true
public $stepEnvTemplateFile; // ".env.example"
public $stepCopyEnvTemplateFile; // true
public $matrixLaravel; // false
public $matrixLaravelVersions; // []
public $matrixTestbenchDependencies;

public function loadDefaultsLaravelStuff()
{
$this->stepFixStoragePermissions = true;
$this->stepRunMigrations = true;
$this->stepGenerateKey = true;
$this->stepEnvTemplateFile = ".env.example";
$this->stepCopyEnvTemplateFile = true;
$this->matrixLaravel = false;
$this->matrixLaravelVersions = [];
$this->matrixTestbenchDependencies = [
"8.*" => "6.*",
"7.*" => "5.*",
"6.*" => "4.*"
]; // mapping laravel versions with testbench version as dependency
// the key is the laravel ver, the value is the orchestratestbench version
}

public function loadLaravelStuffFromJson($j)
{
data_fill($j, "stepGenerateKey", true);
data_fill($j, "stepCopyEnvTemplateFile", true);
$this->stepFixStoragePermissions = $j->stepFixStoragePermissions;
$this->stepRunMigrations = $j->stepRunMigrations;
$this->stepGenerateKey = $j->stepGenerateKey;
$this->stepEnvTemplateFile = $j->stepEnvTemplateFile;
$this->stepCopyEnvTemplateFile = $j->stepCopyEnvTemplateFile;
$this->matrixLaravel = $j->matrixLaravel;
$this->matrixLaravelVersions = $j->matrixLaravelVersions;
$this->matrixTestbenchDependencies = (array) $j->matrixTestbenchDependencies;
}

public function setDataLaravelStuff($data)
{
$data["stepFixStoragePermissions"] = $this->stepFixStoragePermissions;
$data["stepRunMigrations"] = $this->stepRunMigrations;
$data["stepGenerateKey"] = $this->stepGenerateKey;
$data["stepEnvTemplateFile"] = $this->stepEnvTemplateFile;
$data["stepCopyEnvTemplateFile"] = $this->stepCopyEnvTemplateFile;
$data["matrixLaravel"] = $this->matrixLaravel;
$data["matrixLaravelVersions"] = $this->matrixLaravelVersions;
$data["matrixTestbenchDependencies"] = $this->matrixTestbenchDependencies;
$data["matrixLaravelVersionsString"] = self::arrayToString($this->matrixLaravelVersions);

return $data;
}
}
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
"laravel/sail": "^0.0.5",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"nunomaduro/larastan": "^0.7.1",
"phpunit/phpunit": "^9.3.3"
"nunomaduro/larastan": "^0.7.2",
"phpunit/phpunit": "^9.3.3",
"squizlabs/php_codesniffer": "^3.6"
},
"config": {
"optimize-autoloader": true,
Expand Down
Loading

0 comments on commit 5436bb5

Please sign in to comment.