Skip to content

Commit

Permalink
Merge pull request #883 from bavix/autofix
Browse files Browse the repository at this point in the history
autofix ecs & rector
  • Loading branch information
rez1dent3 authored Feb 6, 2024
2 parents addf969 + e8c70cc commit e5d16b3
Show file tree
Hide file tree
Showing 102 changed files with 416 additions and 440 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/autofix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: fixer

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
autofix:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: mbstring, pgsql, mysql, sqlite, redis, memcached, bcmath
coverage: pcov
env:
runner: self-hosted

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run rector-fix
run: composer rector-fix

- name: Run ecs-fix
run: composer ecs-fix

- name: Run rector
run: composer rector

- name: Run ecs
run: composer ecs

- name: Run parabench
run: composer parabench

- name: "Check if build has changed"
if: success()
id: has-changes
run: |
echo "stdout<<EOF" >> $GITHUB_OUTPUT
echo "$(git diff --stat)" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Import GPG key
if: ${{ steps.has-changes.outputs.stdout }}
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_BOT }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
fingerprint: ${{ secrets.GPG_FINGERPRINT }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_committer_name: Github bot
git_committer_email: [email protected]

- name: "Commit files"
if: ${{ steps.has-changes.outputs.stdout }}
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
gh pr checkout ${{ github.event.pull_request.number }}
git commit -S -m "autofix" -a
- name: "Push changes"
if: ${{ steps.has-changes.outputs.stdout }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: git push -u origin HEAD
41 changes: 0 additions & 41 deletions .github/workflows/code-style.yaml

This file was deleted.

41 changes: 0 additions & 41 deletions .github/workflows/rector.yaml

This file was deleted.

9 changes: 4 additions & 5 deletions database/2018_11_06_222923_create_transactions_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
return new class() extends Migration
{
public function up(): void
{
Schema::create($this->table(), static function (Blueprint $table) {
Expand All @@ -18,11 +19,9 @@ public function up(): void
$table->decimal('amount', 64, 0);
$table->boolean('confirmed');
$table->json('meta')
->nullable()
;
->nullable();
$table->uuid('uuid')
->unique()
;
->unique();
$table->timestamps();

$table->index(['payable_type', 'payable_id'], 'payable_type_payable_id_ind');
Expand Down
24 changes: 9 additions & 15 deletions database/2018_11_07_192923_create_transfers_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
return new class() extends Migration
{
public function up(): void
{
Schema::create($this->table(), function (Blueprint $table) {
Expand All @@ -17,41 +18,34 @@ public function up(): void
$table->morphs('to');
$table
->enum('status', ['exchange', 'transfer', 'paid', 'refund', 'gift'])
->default('transfer')
;
->default('transfer');

$table
->enum('status_last', ['exchange', 'transfer', 'paid', 'refund', 'gift'])
->nullable()
;
->nullable();

$table->unsignedBigInteger('deposit_id');
$table->unsignedBigInteger('withdraw_id');

$table->decimal('discount', 64, 0)
->default(0)
;
->default(0);

$table->decimal('fee', 64, 0)
->default(0)
;
->default(0);

$table->uuid('uuid')
->unique()
;
->unique();
$table->timestamps();

$table->foreign('deposit_id')
->references('id')
->on($this->transactionTable())
->onDelete('cascade')
;
->onDelete('cascade');

$table->foreign('withdraw_id')
->references('id')
->on($this->transactionTable())
->onDelete('cascade')
;
->onDelete('cascade');
});
}

Expand Down
24 changes: 9 additions & 15 deletions database/2018_11_15_124230_create_wallets_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,26 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
return new class() extends Migration
{
public function up(): void
{
Schema::create($this->table(), static function (Blueprint $table) {
$table->bigIncrements('id');
$table->morphs('holder');
$table->string('name');
$table->string('slug')
->index()
;
->index();
$table->uuid('uuid')
->unique()
;
->unique();
$table->string('description')
->nullable()
;
->nullable();
$table->json('meta')
->nullable()
;
->nullable();
$table->decimal('balance', 64, 0)
->default(0)
;
->default(0);
$table->unsignedSmallInteger('decimal_places')
->default(2)
;
->default(2);
$table->timestamps();

$table->unique(['holder_type', 'holder_id', 'slug']);
Expand All @@ -42,8 +37,7 @@ public function up(): void
$table->foreign('wallet_id')
->references('id')
->on($this->table())
->onDelete('cascade')
;
->onDelete('cascade');
});
}

Expand Down
9 changes: 4 additions & 5 deletions database/2021_11_02_202021_update_wallets_uuid_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
return new class() extends Migration
{
public function up(): void
{
if (Schema::hasColumn($this->table(), 'uuid')) {
Expand All @@ -21,8 +22,7 @@ public function up(): void
$table->uuid('uuid')
->after('slug')
->nullable()
->unique()
;
->unique();
});

Wallet::query()->chunk(10000, static function (Collection $wallets) {
Expand All @@ -34,8 +34,7 @@ public function up(): void

Schema::table($this->table(), static function (Blueprint $table) {
$table->uuid('uuid')
->change()
;
->change();
});
}

Expand Down
9 changes: 4 additions & 5 deletions database/2023_12_30_113122_extra_columns_removed.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
return new class() extends Migration
{
public function up(): void
{
Schema::table($this->table(), function (Blueprint $table) {
Expand All @@ -25,11 +26,9 @@ public function down(): void
{
Schema::table($this->table(), static function (Blueprint $table) {
$table->string('from_type')
->after('from_id')
;
->after('from_id');
$table->string('to_type')
->after('to_id')
;
->after('to_id');
});
}

Expand Down
3 changes: 2 additions & 1 deletion database/2023_12_30_204610_soft_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
return new class() extends Migration
{
public function up(): void
{
Schema::table((new Wallet())->getTable(), static function (Blueprint $table) {
Expand Down
6 changes: 3 additions & 3 deletions database/2024_01_24_185401_add_extra_column_in_transfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
return new class() extends Migration
{
public function up(): void
{
Schema::table($this->table(), static function (Blueprint $table) {
$table->json('extra')
->nullable()
->after('fee')
;
->after('fee');
});
}

Expand Down
Loading

0 comments on commit e5d16b3

Please sign in to comment.