Skip to content

Commit

Permalink
Merge pull request #66 from Hi-Folks/develop
Browse files Browse the repository at this point in the history
v0.3.0
  • Loading branch information
roberto-butti authored Apr 15, 2021
2 parents 5436bb5 + 83f46e2 commit 8fdf018
Show file tree
Hide file tree
Showing 13 changed files with 418 additions and 80 deletions.
61 changes: 50 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
# GithHub Actions Workflow generated with Ghygen
# Original configuration: http://gh-actions-yaml-generator.test?code=b7bcc081364231214c674c75585195e1
name: Test Workflow autogenerated Yaml
# Original configuration: http://gh-actions-yaml-generator.test?code=780e67116804a2e621be488784a4f99a
name: Template - Laravel application
on:
push:
branches:
- main
- develop
- features/**

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' ]
php-versions: [ '8.0','7.4' ]
dependency-stability: [ prefer-stable ]

name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
Expand All @@ -40,6 +59,17 @@ jobs:
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
Expand All @@ -59,29 +89,38 @@ jobs:
- name: Run Migrations
# Set environment
env:
SESSION_DRIVER: array
DB_CONNECTION: sqlite
DB_DATABASE: ":memory:"
DB_CONNECTION: mysql
DB_DATABASE: db_test_laravel
DB_PORT: 33306
DB_USER: root

run: php artisan migrate

- name: Show Laravel versions
run: php artisan --version
- 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:
SESSION_DRIVER: array
DB_CONNECTION: sqlite
DB_DATABASE: ":memory:"
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: |
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.3.0 - 2021-04-15
### Add
- Select Template option: Laravel application, PHP package, Laravel package ( #62 );
- Select tool for code static analysis ( #63 )


## 0.2.5 - 2021-04-12
### Add
- New option for installing phpstan in workflow
Expand Down
3 changes: 3 additions & 0 deletions Makefile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ buildfrontend: ## execute npm task to compile frontend assets (js and css...)
optimize: ## Optimize application in production
ssh ${SSH_ALIAS} "cd ${WEB_DIR}; php artisan config:cache; php artisan route:cache; php artisan view:cache"

laralens: ## Execute Diagnostic on the server
ssh ${SSH_ALIAS} "cd ${WEB_DIR}; php artisan laralens:diagnostic"

deploy: buildfrontend rsynca copyenvprod migrate
134 changes: 78 additions & 56 deletions app/Http/Livewire/ConfiguratorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ class ConfiguratorForm extends Component
use LaravelStuff;

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

protected $queryString = ['code' => ['except' => '']];
protected $queryString = [
'code' => ['except' => ''],
'template' => ['except' => '']
];

public const DB_TYPE_NONE = "none";
public const DB_TYPE_MYSQL = "mysql";
Expand Down Expand Up @@ -116,71 +120,77 @@ private function loadDefaults()
$this->loadDefaultsLaravelStuff();
}

private function loadFromJson($j)
{
data_fill($j, "stepDirCodeSniffer", "app");
$this->name = $j->name;
$this->onPush = $j->on_push;
$this->onPushBranches = $j->on_push_branches;
$this->onPullrequest = $j->on_pullrequest;
$this->onPullrequestBranches = $j->on_pullrequest_branches;
$this->manualTrigger = $j->manual_trigger;
if (isset($j->mysqlService)) {
if ($j->mysqlService === true) {
$this->databaseType = self::DB_TYPE_MYSQL;
} elseif ($j->mysqlService === false) {
$this->databaseType = self::DB_TYPE_NONE;
}
} else {
$this->databaseType = $j->databaseType;
}
$this->mysqlDatabase = $j->mysqlDatabase;
$this->mysqlPasswordType = $j->mysqlPasswordType;
$this->mysqlPassword = $j->mysqlPassword;
$this->mysqlVersion = $j->mysqlVersion;
$this->mysqlDatabaseName = $j->mysqlDatabaseName;
$this->mysqlDatabasePort = $j->mysqlDatabasePort;
if (isset($j->postgresqlDatabase)) {
$this->postgresqlDatabase = $j->postgresqlDatabase;
$this->postgresqlPasswordType =
isset($j->postgresqlPasswordType) ?
$j->postgresqlPasswordType :
$this->postgresqlPasswordType;
$this->postgresqlPassword =
isset($j->postgresqlPassword) ?
$j->postgresqlPassword :
$this->postgresqlPassword;
$this->postgresqlVersion =
isset($j->postgresqlVersion) ?
$j->postgresqlVersion :
$this->postgresqlVersion;
$this->postgresqlDatabaseName =
isset($j->postgresqlDatabaseName) ?
$j->postgresqlDatabaseName :
$this->postgresqlDatabaseName;
$this->postgresqlDatabasePort =
isset($j->postgresqlDatabasePort) ?
$j->postgresqlDatabasePort :
$this->postgresqlDatabasePort;
}
$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->loadCodeQualityFromJson($j);
$this->loadLaravelStuffFromJson($j);
}
public function mount()
{
$this->fill(request()->only('code'));
Log::debug(__METHOD__ . ' Code : ' . $this->code);
$codeNotFound = false;
$this->loadDefaults();
if ($this->template != "") {
$this->template($this->template);
}
if ($this->code != "") {
$confModel = Configuration::getByCode($this->code);
if ($confModel) {
//$j = json_decode($confModel->configuration);
$j = $confModel->configuration;
Log::debug(__METHOD__ . ' Name : ' . $j->name);
$this->name = $j->name;
$this->onPush = $j->on_push;
$this->onPushBranches = $j->on_push_branches;
$this->onPullrequest = $j->on_pullrequest;
$this->onPullrequestBranches = $j->on_pullrequest_branches;
$this->manualTrigger = $j->manual_trigger;
if (isset($j->mysqlService)) {
if ($j->mysqlService === true) {
$this->databaseType = self::DB_TYPE_MYSQL;
} elseif ($j->mysqlService === false) {
$this->databaseType = self::DB_TYPE_NONE;
}
} else {
$this->databaseType = $j->databaseType;
}
$this->mysqlDatabase = $j->mysqlDatabase;
$this->mysqlPasswordType = $j->mysqlPasswordType;
$this->mysqlPassword = $j->mysqlPassword;
$this->mysqlVersion = $j->mysqlVersion;
$this->mysqlDatabaseName = $j->mysqlDatabaseName;
$this->mysqlDatabasePort = $j->mysqlDatabasePort;
if (isset($j->postgresqlDatabase)) {
$this->postgresqlDatabase = $j->postgresqlDatabase;
$this->postgresqlPasswordType =
isset($j->postgresqlPasswordType) ?
$j->postgresqlPasswordType :
$this->postgresqlPasswordType;
$this->postgresqlPassword =
isset($j->postgresqlPassword) ?
$j->postgresqlPassword :
$this->postgresqlPassword;
$this->postgresqlVersion =
isset($j->postgresqlVersion) ?
$j->postgresqlVersion :
$this->postgresqlVersion;
$this->postgresqlDatabaseName =
isset($j->postgresqlDatabaseName) ?
$j->postgresqlDatabaseName :
$this->postgresqlDatabaseName;
$this->postgresqlDatabasePort =
isset($j->postgresqlDatabasePort) ?
$j->postgresqlDatabasePort :
$this->postgresqlDatabasePort;
}
$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->loadCodeQualityFromJson($j);
$this->loadLaravelStuffFromJson($j);
$this->loadFromJson($j);
} else {
$codeNotFound = true;
}
Expand Down Expand Up @@ -235,6 +245,18 @@ public function updated($propertyName)
}


public function template($x)
{
if (in_array($x, ["laravelapp", "laravelpackage", "phppackage"])) {
$this->template = $x;
$this->code = "";
$j = json_decode(file_get_contents(resource_path('templates/json/' . $x . '.json')));
$this->loadFromJson($j);
} else {
$this->template = "";
}
}

public function submitForm()
{
try {
Expand Down
5 changes: 5 additions & 0 deletions app/Traits/Form/CodeQuality.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ trait CodeQuality
public $stepInstallCodeSniffer; //true
public $stepExecuteStaticAnalysis; // false
public $stepDirStaticAnalysis; // app
public $stepToolStaticAnalysis; // phpstan|larastan
public $stepInstallStaticAnalysis; //true
public $stepDusk; // false

Expand All @@ -21,6 +22,7 @@ public function loadDefaultsCodeQuality()
$this->stepInstallCodeSniffer = true;
$this->stepExecuteStaticAnalysis = false;
$this->stepDirStaticAnalysis = "app";
$this->stepToolStaticAnalysis = "larastan";
$this->stepInstallStaticAnalysis = true;
$this->stepDusk = false;
}
Expand All @@ -31,12 +33,14 @@ public function loadCodeQualityFromJson($j)
data_fill($j, "stepInstallCodeSniffer", true);
data_fill($j, "stepDirStaticAnalysis", "app");
data_fill($j, "stepInstallStaticAnalysis", true);
data_fill($j, "stepToolStaticAnalysis", 'larastan');
$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->stepToolStaticAnalysis = $j->stepToolStaticAnalysis;
$this->stepInstallStaticAnalysis = $j->stepInstallStaticAnalysis;
$this->stepDusk = $j->stepDusk;
}
Expand All @@ -49,6 +53,7 @@ public function setDataCodeQuality($data)
$data["stepInstallCodeSniffer"] = $this->stepInstallCodeSniffer;
$data["stepExecuteStaticAnalysis"] = $this->stepExecuteStaticAnalysis;
$data["stepDirStaticAnalysis"] = $this->stepDirStaticAnalysis;
$data["stepToolStaticAnalysis"] = $this->stepToolStaticAnalysis;
$data["stepInstallStaticAnalysis"] = $this->stepInstallStaticAnalysis;
$data["stepDusk"] = $this->stepDusk;

Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8fdf018

Please sign in to comment.