From 68ed2d2be0c8784548f1a8448077c19846ad5f54 Mon Sep 17 00:00:00 2001 From: mychidarko Date: Sun, 13 Oct 2024 01:00:20 +0000 Subject: [PATCH] feat: switch to alchemy v2 --- .github/workflows/lint.yml | 34 ++++++++++ .github/workflows/php-cs-fixer.yml | 23 ------- .github/workflows/tests.yml | 13 ++-- .gitignore | 5 +- .php_cs.dist.php | 34 ---------- alchemy.yml | 61 ++++++++++++++++++ composer.json | 100 +++++++++++++++-------------- phpunit.xml | 18 ------ src/Config.php | 2 +- 9 files changed, 159 insertions(+), 131 deletions(-) create mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/php-cs-fixer.yml delete mode 100644 .php_cs.dist.php create mode 100644 alchemy.yml delete mode 100644 phpunit.xml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..7877bd0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,34 @@ +name: Lint code + +on: [push] + +jobs: + lint: + runs-on: ubuntu-latest + strategy: + fail-fast: true + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: json, zip + tools: composer:v2 + coverage: none + + - name: Install PHP dependencies + run: composer update --no-interaction --no-progress + + - name: Run Linter + run: composer run lint + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: 'chore: fix styling' diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml deleted file mode 100644 index f77cc76..0000000 --- a/.github/workflows/php-cs-fixer.yml +++ /dev/null @@ -1,23 +0,0 @@ -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: 'chore: fix styling' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a52d86e..9435a7f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,14 +1,15 @@ name: Run Tests -on: ['push', 'pull_request'] +on: ["push","pull_request"] jobs: - ci: + tests: runs-on: ${{ matrix.os }} strategy: + fail-fast: true matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - php: ['7.4', '8.0', '8.1', '8.2', '8.3'] + os: ["ubuntu-latest","macos-latest","windows-latest"] + php: ["8.3","8.2","8.1","8.0","7.4"] name: PHP ${{ matrix.php }} - ${{ matrix.os }} @@ -27,5 +28,5 @@ jobs: - name: Install PHP dependencies run: composer update --no-interaction --no-progress - - name: All Tests - run: php vendor/bin/pest --colors=always --coverage + - name: Run Tests + run: composer run test diff --git a/.gitignore b/.gitignore index 6fa59a2..945d7be 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,7 @@ Thumbs.db *.swp # phpstorm -.idea/* \ No newline at end of file +.idea/* + +# Alchemy +.alchemy diff --git a/.php_cs.dist.php b/.php_cs.dist.php deleted file mode 100644 index 027edf8..0000000 --- a/.php_cs.dist.php +++ /dev/null @@ -1,34 +0,0 @@ -in([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->name('*.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' => false, - '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, - 'method_argument_space' => [ - 'on_multiline' => 'ensure_fully_multiline', - 'keep_multiple_spaces_after_comma' => true, - ], - 'single_trait_insert_per_statement' => true, - ]) - ->setFinder($finder); \ No newline at end of file diff --git a/alchemy.yml b/alchemy.yml new file mode 100644 index 0000000..eb1fae7 --- /dev/null +++ b/alchemy.yml @@ -0,0 +1,61 @@ +app: + - src + +tests: + engine: pest + parallel: true + paths: + - tests + files: + - '*.test.php' + coverage: + processUncoveredFiles: true + +lint: + preset: PSR12 + rules: + single_quote: true + phpdoc_scalar: true + no_unused_imports: true + unary_operator_spaces: true + binary_operator_spaces: true + phpdoc_var_without_name: true + trailing_comma_in_multiline: true + phpdoc_single_line_var_spacing: true + single_trait_insert_per_statement: true + not_operator_with_successor_space: false + array_syntax: + syntax: short + ordered_imports: + sort_algorithm: alpha + method_argument_space: + on_multiline: ensure_fully_multiline + keep_multiple_spaces_after_comma: true + blank_line_before_statement: + statements: + - break + - continue + - declare + - return + - throw + - try + +actions: + run: + - lint + - tests + os: + - ubuntu-latest + - macos-latest + - windows-latest + php: + extensions: json, zip + versions: + - '8.3' + - '8.2' + - '8.1' + - '8.0' + - '7.4' + events: + - push + - pull_request diff --git a/composer.json b/composer.json index bceb296..c2e265b 100644 --- a/composer.json +++ b/composer.json @@ -1,52 +1,56 @@ { - "name": "leafs/leaf", - "description": "Elegant PHP for modern developers", - "keywords": [ - "microframework", - "rest", - "router", - "leaf", - "php", - "framework" - ], - "homepage": "https://leafphp.dev", - "type": "library", - "license": "MIT", - "authors": [ - { - "name": "Michael Darko", - "email": "mickdd22@gmail.com", - "homepage": "https://mychi.netlify.app", - "role": "Developer" - } - ], - "autoload": { - "psr-4": { - "Leaf\\": "src" - }, - "files": [ - "src/functions.php" - ] - }, - "minimum-stability": "dev", - "prefer-stable": true, - "require": { - "php": "^7.4|^8.0", - "leafs/http": "*", - "leafs/anchor": "*", - "leafs/exception": "*" - }, - "require-dev": { - "pestphp/pest": "^1.21", - "friendsofphp/php-cs-fixer": "^3.0" - }, - "scripts": { + "name": "leafs/leaf", + "description": "Elegant PHP for modern developers", + "keywords": [ + "microframework", + "rest", + "router", + "leaf", + "php", + "framework" + ], + "homepage": "https://leafphp.dev", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Michael Darko", + "email": "mickdd22@gmail.com", + "homepage": "https://mychi.netlify.app", + "role": "Developer" + } + ], + "autoload": { + "psr-4": { + "Leaf\\": "src" + }, + "files": [ + "src/functions.php" + ] + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": "^7.4|^8.0", + "leafs/http": "*", + "leafs/anchor": "*", + "leafs/exception": "*", + "leafs/alchemy": "dev-next" + }, + "scripts": { "format": "vendor/bin/php-cs-fixer fix --config=.php_cs.dist.php --allow-risky=yes", - "test": "vendor/bin/pest" + "test": "./vendor/bin/alchemy setup --test", + "alchemy": "./vendor/bin/alchemy setup", + "lint": "./vendor/bin/alchemy setup --lint", + "actions": "./vendor/bin/alchemy setup --actions" + }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true + } }, - "config": { - "allow-plugins": { - "pestphp/pest-plugin": true - } - } + "require-dev": { + "pestphp/pest": "^3.3", + "friendsofphp/php-cs-fixer": "^3.64" + } } diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index 4e6c4a9..0000000 --- a/phpunit.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./tests - - - - - ./app - ./src - - - diff --git a/src/Config.php b/src/Config.php index f1d8d9d..16241dc 100644 --- a/src/Config.php +++ b/src/Config.php @@ -216,7 +216,7 @@ public static function reset() protected static function getDiIndex($class) { - $fullName = \explode("\\", \strtolower(\get_class($class))); + $fullName = \explode('\\', \strtolower(\get_class($class))); $className = $fullName[\count($fullName) - 1]; return $className;