Skip to content

Commit

Permalink
implemented basic ci
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Oct 10, 2023
1 parent 3aed3fc commit b2a7560
Show file tree
Hide file tree
Showing 186 changed files with 3,352 additions and 3,583 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: PHP CI

on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, xml, gd, zip, pdo_mysql, sockets, intl, bcmath, gmp
coverage: xdebug

- name: Update and Install additional packages
run: |
sudo apt-get update
sudo apt-get install -y libzip-dev libgd-dev libfreetype6-dev libjpeg-dev libpng-dev imagemagick libmagickwand-dev libmemcached-dev libgeos-dev libgmp-dev default-mysql-client libicu-dev
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run Lint
run: composer lint

# - name: Run Tests -- Will add tests back after phppest issue https://github.com/pestphp/pest/issues/920 is fixed
# run: composer test:unit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ composer.lock
/vendor/
.phpunit.result.cache
.php_cs.cache
.php-cs-fixer.cache
*.swp
*.swo
.DS_Store
9 changes: 5 additions & 4 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . DIRECTORY_SEPARATOR . 'tests')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'src')
->append(['.php_cs']);
->append(['.php-cs-fixer.php']);

$rules = [
'@Symfony' => true,
Expand All @@ -18,11 +18,12 @@
],
'concat_space' => ['spacing' => 'one'],
'not_operator_with_space' => false,
'increment_style' => ['style' => 'post'],
'indentation_type' => true,
'single_quote' => true,
];

$rules['increment_style'] = ['style' => 'post'];

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setUsingCache(true)
->setRules($rules)
->setFinder($finder);
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@
"xantios/mimey": "^2.2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16.4",
"pestphp/pest": "^0.3.8",
"phpstan/phpstan": "^0.12.48",
"symfony/var-dumper": "^5.2.0"
"friendsofphp/php-cs-fixer": "^3.34.1",
"nunomaduro/collision": "^5.11.0|^6.4.0",
"pestphp/pest": "^1.22.6",
"phpstan/phpstan": "^1.10.38",
"symfony/var-dumper": "^5.4.29"
},
"autoload": {
"psr-4": {
Expand Down
36 changes: 14 additions & 22 deletions src/Auth/Schemas/Developers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,45 @@ class Developers
{
/**
* The permission schema Name.
*
* @var string
*/
public string $name = 'developers';

/**
* The permission schema Polict Name.
*
* @var string
*/
public string $policyName = 'Developers';

/**
* Guards these permissions should apply to.
*
* @var array
*/
public array $guards = ['web'];

/**
* The permission schema resources.
*
* @var array
*/
public array $resources = [
[
'name' => 'api-key',
'actions' => ['roll', 'export']
'name' => 'api-key',
'actions' => ['roll', 'export'],
],
[
'name' => 'webhook',
'actions' => []
'name' => 'webhook',
'actions' => [],
],
[
'name' => 'socket',
'actions' => [],
'remove_actions' => ['create', 'update', 'delete']
'name' => 'socket',
'actions' => [],
'remove_actions' => ['create', 'update', 'delete'],
],
[
'name' => 'log',
'actions' => [],
'remove_actions' => ['create', 'update', 'delete', 'export']
'name' => 'log',
'actions' => [],
'remove_actions' => ['create', 'update', 'delete', 'export'],
],
[
'name' => 'event',
'actions' => [],
'remove_actions' => ['create', 'update', 'delete']
]
'name' => 'event',
'actions' => [],
'remove_actions' => ['create', 'update', 'delete'],
],
];
}
28 changes: 9 additions & 19 deletions src/Auth/Schemas/IAM.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,43 @@ class IAM
{
/**
* The permission schema Name.
*
* @var string
*/
public string $name = 'iam';

/**
* The permission schema Polict Name.
*
* @var string
*/
public string $policyName = 'IAM';

/**
* Guards these permissions should apply to.
*
* @var array
*/
public array $guards = ['web'];

/**
* Direct permissions for the schema.
*
* @var array
*/
public array $permissions = ['change-password'];

/**
* The permission schema resources.
*
* @var array
*/
public array $resources = [
[
'name' => 'group',
'actions' => ['export']
'name' => 'group',
'actions' => ['export'],
],
[
'name' => 'user',
'actions' => ['deactivate', 'export']
'name' => 'user',
'actions' => ['deactivate', 'export'],
],
[
'name' => 'role',
'actions' => ['export']
'name' => 'role',
'actions' => ['export'],
],
[
'name' => 'policy',
'actions' => []
]
'name' => 'policy',
'actions' => [],
],
];
}
23 changes: 12 additions & 11 deletions src/Casts/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

use Fleetbase\Support\Utils;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Support\Str;

class Json implements CastsAttributes
{
/**
* Cast the given value.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param array $attributes
*
* @return array
*/
public function get($model, $key, $value, $attributes)
Expand All @@ -25,10 +24,11 @@ public function get($model, $key, $value, $attributes)
/**
* Prepare the given value for storage.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param array $value
* @param array $attributes
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param array $value
* @param array $attributes
*
* @return string
*/
public function set($model, $key, $value, $attributes)
Expand All @@ -37,9 +37,10 @@ public function set($model, $key, $value, $attributes)
}

/**
* Unwrap JSON string and unescape JSON and decode JSON
*
* Unwrap JSON string and unescape JSON and decode JSON.
*
* @param string $json
*
* @return string
*/
public static function decode($json)
Expand Down
18 changes: 7 additions & 11 deletions src/Casts/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

namespace Fleetbase\Casts;

use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Fleetbase\Support\Utils;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class Money implements CastsAttributes
{
/**
* Cast the given value.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return mixed
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param array $attributes
*/
public function get($model, $key, $value, $attributes)
{
Expand All @@ -24,11 +22,9 @@ public function get($model, $key, $value, $attributes)
/**
* Prepare the given value for storage.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return mixed
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param array $attributes
*/
public function set($model, $key, $value, $attributes)
{
Expand Down
16 changes: 6 additions & 10 deletions src/Casts/PolymorphicType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ class PolymorphicType implements CastsAttributes
/**
* Cast the given value.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return mixed
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param array $attributes
*/
public function get($model, $key, $value, $attributes)
{
Expand All @@ -24,11 +22,9 @@ public function get($model, $key, $value, $attributes)
/**
* Prepare the given value for storage.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return mixed
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param array $attributes
*/
public function set($model, $key, $value, $attributes)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Console/Commands/BackupDatabase/MysqlS3Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Fleetbase\Console\Commands\BackupDatabase;

use Illuminate\Console\Command;
use Aws\S3\S3Client;
use Aws\S3\MultipartUploader;
use Aws\Exception\MultipartUploadException;
use Aws\S3\MultipartUploader;
use Aws\S3\S3Client;
use Illuminate\Console\Command;
use Symfony\Component\Process\Process;

class MysqlS3Backup extends Command
Expand All @@ -32,7 +32,7 @@ class MysqlS3Backup extends Command
public function handle()
{
$connections = ['mysql', 'sandbox'];
$databases = array_map(
$databases = array_map(
function ($connectionName) {
return config('database.connections.' . $connectionName . '.database');
},
Expand Down Expand Up @@ -100,10 +100,10 @@ function ($connectionName) {

// Upload to S3
$s3config = config('laravel-mysql-s3-backup.s3');
$s3 = new S3Client($s3config);
$s3 = new S3Client($s3config);

$bucket = config('laravel-mysql-s3-backup.s3.bucket');
$key = basename($fileName);
$key = basename($fileName);

if ($folder = config('laravel-mysql-s3-backup.s3.folder')) {
$key = $folder . '/' . $key;
Expand All @@ -118,7 +118,7 @@ function ($connectionName) {
$fileName,
[
'bucket' => $bucket,
'key' => $key,
'key' => $key,
]
);

Expand Down
Loading

0 comments on commit b2a7560

Please sign in to comment.