From 145ce06288b69e2864e3ab5978182c6d58e7a123 Mon Sep 17 00:00:00 2001 From: farhad Date: Sun, 16 Jan 2022 11:48:15 +0330 Subject: [PATCH] WIP --- .github/FUNDING.yml | 1 + .github/workflows/php-cs-fixer.yml | 23 +++++++++++++ .github/workflows/run-tests.yml | 54 ++++++++++++++++++++++++++++++ .php_cs.dist.php | 40 ++++++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100755 .github/FUNDING.yml create mode 100755 .github/workflows/php-cs-fixer.yml create mode 100755 .github/workflows/run-tests.yml create mode 100644 .php_cs.dist.php diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100755 index 0000000..fbb0a46 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: hekmatinasser diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100755 index 0000000..f55d1fa --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,23 @@ +name: Check & fix styling + +on: [push] + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Run PHP CS Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php_cs.dist.php --allow-risky=yes + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Fix styling diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100755 index 0000000..b980745 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,54 @@ +name: run-tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + php: [8.1, 8.0, 7.3, 7.4] + laravel: [6.*,8.*,9.*] + dependency-version: [prefer-lowest, prefer-stable] + include: + - laravel: 8.* + testbench: ^6.23 + - laravel: 6.* + testbench: ^4.9 + - laravel: 9.* + testbench: 7.* + + exclude: + - php: 8.1 + laravel: 6.* + - laravel: 9.* + php: 7.3 + - laravel: 9.* + php: 7.4 + + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.php_cs.dist.php b/.php_cs.dist.php new file mode 100644 index 0000000..8d8a790 --- /dev/null +++ b/.php_cs.dist.php @@ -0,0 +1,40 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->name('*.php') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'trailing_comma_in_multiline' => true, + 'phpdoc_scalar' => true, + 'unary_operator_spaces' => true, + 'binary_operator_spaces' => true, + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], + ], + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_var_without_name' => true, + 'class_attributes_separation' => [ + 'elements' => [ + 'method' => 'one', + ], + ], + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + 'keep_multiple_spaces_after_comma' => true, + ], + 'single_trait_insert_per_statement' => true, + ]) + ->setFinder($finder);