Skip to content

Commit

Permalink
Merge pull request #50 from Hi-Folks/develop
Browse files Browse the repository at this point in the history
v0.2.3
  • Loading branch information
roberto-butti authored Apr 4, 2021
2 parents ea5d706 + 545a029 commit 4197b1b
Show file tree
Hide file tree
Showing 21 changed files with 2,489 additions and 639 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/psr12-phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# GithHub Actions Workflow generated with Ghygen
# Original configuration: http://gh-actions-yaml-generator.test?code=4072d795e78bf272b0ee23c1df8a6e83
name: PSR12 and Static Code Analysis for with PHP 8 ,7.4, 7.3
on:
push:
branches:
- main
- develop
- features/**

jobs:
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: 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: Show Laravel versions
run: php artisan --version
- name: Show dir
run: pwd
- name: PHP Version
run: php --version


- 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: |
vendor/bin/phpstan analyse app -c ./vendor/nunomaduro/larastan/extension.neon --level=4 --no-progress
76 changes: 76 additions & 0 deletions .github/workflows/test-sqlite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# GithHub Actions Workflow generated with Ghygen
# Original configuration: http://gh-actions-yaml-generator.test?code=f6057d1792446de0d97898542edb1b7b
name: Test Sqlite
on:
push:
branches:
- main
- develop
- features/**

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

strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.0' ]
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: '14.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: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Run Migrations
# Set environment
env:
SESSION_DRIVER: array
DB_CONNECTION: sqlite
DB_DATABASE: ":memory:"

run: php artisan migrate

- name: Show Laravel versions
run: php artisan --version
- 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
DB_CONNECTION: sqlite
DB_DATABASE: ":memory:"

run: vendor/bin/phpunit --testdox






89 changes: 89 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# GithHub Actions Workflow generated with Ghygen
# Original configuration: http://gh-actions-yaml-generator.test?code=b7bcc081364231214c674c75585195e1
name: Test Workflow autogenerated Yaml
on:
push:
branches:
- main
- develop
- features/**

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

strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [ '8.0' ]
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: '14.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: 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:
SESSION_DRIVER: array
DB_CONNECTION: sqlite
DB_DATABASE: ":memory:"

run: php artisan migrate

- name: Show Laravel versions
run: php artisan --version
- 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
DB_CONNECTION: sqlite
DB_DATABASE: ":memory:"

run: vendor/bin/phpunit --testdox






9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.2.3 - 2021-04-04
### Add
- Add Sqlite (in memory) support in your workflow (now the user can select: none, mysql or sqlite);
- Add Validation for Laravel version


### Change


## 0.2.2 - 2021-03-07
### Add
- All Hashcode configurations are logged into log_configurations table;
Expand Down
42 changes: 29 additions & 13 deletions app/Http/Livewire/ConfiguratorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ class ConfiguratorForm extends Component

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

public const DB_TYPE_NONE = "none";
public const DB_TYPE_MYSQL = "mysql";
public const DB_TYPE_SQLITE = "sqlite";
public const DB_TYPE_POSTGRESQL = "postgresql";


public $name;
public $onPush;
public $onPushBranches;
public $onPullrequest;
public $onPullrequestBranches;
public $manualTrigger;
public $mysqlService;
public $databaseType; // 'none', 'mysql', 'postgresql', 'sqlite'
public $mysqlDatabase;
public $mysqlPasswordType; // 'skip
public $mysqlPassword; // password
Expand Down Expand Up @@ -67,9 +73,10 @@ class ConfiguratorForm extends Component
'name' => 'required|string',
'onPushBranches' => 'exclude_unless:onPush,1|required',
'onPullrequestBranches' => 'exclude_unless:onPullrequest,1|required',
'mysqlVersion' => 'exclude_unless:mysqlService,1|required',
'mysqlDatabaseName' => 'exclude_unless:mysqlService,1|required',
'mysqlDatabasePort' => 'exclude_unless:mysqlService,1|required|integer',
'mysqlVersion' => 'exclude_unless:databaseType,' . self::DB_TYPE_MYSQL . '|required',
'mysqlDatabaseName' => 'exclude_unless:databaseType,' . self::DB_TYPE_MYSQL . '|required',
'mysqlDatabasePort' => 'exclude_unless:databaseType,' . self::DB_TYPE_MYSQL . '|required|integer',
'matrixLaravelVersions' => 'exclude_unless:matrixLaravel,1|required',
];

private function loadDefaults()
Expand All @@ -80,7 +87,7 @@ private function loadDefaults()
$this->onPullrequest = false;
$this->onPullrequestBranches = ["main", "develop"];
$this->manualTrigger = false;
$this->mysqlService = true;
$this->databaseType = self::DB_TYPE_MYSQL;
$this->mysqlDatabase = "mysql";
$this->mysqlPasswordType = "skip";
$this->mysqlPassword = "DB_PASSWORD";
Expand Down Expand Up @@ -128,7 +135,15 @@ public function mount()
$this->onPullrequest = $j->on_pullrequest;
$this->onPullrequestBranches = $j->on_pullrequest_branches;
$this->manualTrigger = $j->manual_trigger;
$this->mysqlService = $j->mysqlService;
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;
Expand Down Expand Up @@ -228,11 +243,11 @@ public function submitForm()

// Provide some suggestions
$this->hints = [];
if ($values["mysqlService"] and ! $values["stepRunMigrations"]) {
$this->hints[] = "I suggest you to select run migration if you have MySqlService";
if ($values["databaseType"] !== self::DB_TYPE_NONE and ! $values["stepRunMigrations"]) {
$this->hints[] = "I suggest you to select run migration if you have a Database";
}
if (! $values["mysqlService"] and $values["stepRunMigrations"]) {
$this->hints[] = "I suggest you to select Mysql Service if you want to run migrations";
if ($values["databaseType"] === self::DB_TYPE_NONE and $values["stepRunMigrations"]) {
$this->hints[] = "I suggest you to select a Database if you want to run migrations";
}
if ($values["stepDusk"] and ! $values["stepNodejs"]) {
$this->hints[] = "I suggest you to select 'Install node for NPM Build' if you have 'Execute Browser tests'";
Expand All @@ -245,7 +260,7 @@ public function submitForm()
}

$data = $this->compactThis(
"mysqlService",
"databaseType",
"mysqlDatabase",
"mysqlVersion",
"mysqlDatabaseName",
Expand Down Expand Up @@ -296,9 +311,10 @@ public function submitForm()
$hashCode = md5($json);
Configuration::saveConfiguration($hashCode, $data);
$this->code = $hashCode;
$seconds = 60 * 60 * 6; // 6 hours
$seconds = 60 * 60 * 3 ; // 3 hours
$schema = Cache::remember('cache-schema-yaml', $seconds, function () {
return Schema::import('https://json.schemastore.org/github-workflow');
//return Schema::import('https://json.schemastore.org/github-workflow');
return Schema::import(json_decode(file_get_contents(base_path("github-workflow.json"))));
});
$schema->in(json_decode($json));

Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{
"name": "hifolks/gh-actions-yaml-generator",
"type": "project",
Expand Down Expand Up @@ -25,6 +26,7 @@
"symfony/yaml": "^5.2"
},
"require-dev": {
"brianium/paratest": "^6.2",
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/dusk": "^6.11",
Expand Down
Loading

0 comments on commit 4197b1b

Please sign in to comment.