From 97e374d126ef0d6f96bfcadb22e34d4987949a86 Mon Sep 17 00:00:00 2001 From: Xuan Thinh Date: Mon, 2 Oct 2023 20:10:32 +0700 Subject: [PATCH 1/3] feat: add some workflows to check and style codeformat --- .github/workflows/php-cs-fixer.yml | 26 ++++++++++++++++++ .github/workflows/setup_test.yml | 21 ++++++++++---- .github/workflows/update-changelog.yml | 31 +++++++++++++++++++++ .gitignore | 5 +++- .php-cs-fixer.dist.php | 38 ++++++++++++++++++++++++++ composer.json | 21 +++++++------- 6 files changed, 126 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/php-cs-fixer.yml create mode 100644 .github/workflows/update-changelog.yml create mode 100644 .php-cs-fixer.dist.php diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..802d168 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,26 @@ +name: Check & fix styling + +on: [push] + +permissions: + contents: write + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Run PHP CS Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php-cs-fixer.dist.php --allow-risky=yes + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Fix styling diff --git a/.github/workflows/setup_test.yml b/.github/workflows/setup_test.yml index cc923cd..9ad695e 100644 --- a/.github/workflows/setup_test.yml +++ b/.github/workflows/setup_test.yml @@ -1,21 +1,32 @@ -name: Setup and test +name: Setup & test on: [ push, pull_request ] jobs: tests: - name: Setup and run tests - runs-on: ubuntu-latest + name: Composer P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest ] + php: [ '8.1', '8.2' ] + laravel: [ 10.*, 9.* ] + include: + - laravel: 10.* + testbench: 8.* steps: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: ${{ matrix.php }} + - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Install dependencies run: | composer install --no-interaction --no-progress --no-suggest + - name: Run tests run: | composer validate --strict diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml new file mode 100644 index 0000000..acd4c1d --- /dev/null +++ b/.github/workflows/update-changelog.yml @@ -0,0 +1,31 @@ +name: Update Changelog + +on: + release: + types: [released] + +permissions: + contents: write + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: main + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1 + with: + latest-version: ${{ github.event.release.name }} + release-notes: ${{ github.event.release.body }} + + - name: Commit updated CHANGELOG + uses: stefanzweifel/git-auto-commit-action@v5 + with: + branch: main + commit_message: Update CHANGELOG + file_pattern: CHANGELOG.md diff --git a/.gitignore b/.gitignore index ec0d827..93bffae 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,7 @@ npm-debug.log package-lock.json yarn.lock -/.sass-cache \ No newline at end of file +/.sass-cache + +build +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..70c6500 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,38 @@ +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, + '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); diff --git a/composer.json b/composer.json index 0a8e6b5..2c37da7 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { - "name": "lbiltech/laravel-telegram-git-notifier", + "name": "cslant/laravel-telegram-git-notifier", "description": "Send notification from Gitlab and Github events to Telegram", "keywords": [ - "lbiltech", + "cslant", "telegram-bot", "notify", "git-webhook", @@ -15,7 +15,7 @@ "telegram-bot-github-notify", "telegram-bot-gitlab-notify" ], - "homepage": "https://github.com/lbiltech/laravel-telegram-git-notifier", + "homepage": "https://github.com/cslant/laravel-telegram-git-notifier", "license": "MIT", "authors": [ { @@ -32,29 +32,30 @@ ], "autoload": { "psr-4": { - "LbilTech\\LaravelTelegramGitNotifier\\": "src/" + "CSlant\\LaravelTelegramGitNotifier\\": "src/" } }, "autoload-dev": { "psr-4": { - "LbilTech\\LaravelTelegramGitNotifier\\Tests\\": "tests/" + "CSlant\\LaravelTelegramGitNotifier\\Tests\\": "tests/" } }, "require": { "php": "^8.0", - "lbiltech/telegram-git-notifier": "dev-main" + "CSlant/telegram-git-notifier": "dev-main" }, "require-dev": { - "phpunit/phpunit": "^9.5|^10.0", - "mockery/mockery": "^1.6" + "friendsofphp/php-cs-fixer": "^v3.37.1", + "pestphp/pest": "^2.24", + "phpstan/phpstan": "^1.10.39" }, "support": { - "issues": "https://github.com/lbiltech/laravel-telegram-git-notifier/issues" + "issues": "https://github.com/cslant/laravel-telegram-git-notifier/issues" }, "extra": { "laravel": { "providers": [ - "LbilTech\\LaravelTelegramGitNotifier\\Providers\\TelegramGitNotifierServiceProvider" + "CSlant\\LaravelTelegramGitNotifier\\Providers\\TelegramGitNotifierServiceProvider" ] } }, From 350388f19a46e9039d3d90fc52b992d2339cfc91 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Fri, 3 Nov 2023 23:46:42 +0700 Subject: [PATCH 2/3] refactor: Update namespace to CSlant - Changed primary namespace. - Updated all relevant import 'use' statements throughout the source code to reflect this namespace change. - Checked and ensured that all functionalities remain intact post-refactor. --- .editorconfig | 19 +++++++++++++++++++ .github/workflows/setup_test.yml | 2 ++ composer.json | 18 +++++++++++++++--- config/telegram-git-notifier.php | 4 ++-- phpunit.xml | 4 ++-- routes/bot.php | 2 +- src/Http/Actions/WebhookAction.php | 4 ++-- .../TelegramGitNotifierServiceProvider.php | 2 +- 8 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7f57023 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +; This is the top-most EditorConfig file, which is not inherited by any other files. +; This file is used for unify the coding style for different editors and IDEs. +; More information at https://editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf + +[*.md] +trim_trailing_whitespace = false + +[*.yml] +indent_style = space + +[*.json] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/setup_test.yml b/.github/workflows/setup_test.yml index 9ad695e..5863f5b 100644 --- a/.github/workflows/setup_test.yml +++ b/.github/workflows/setup_test.yml @@ -14,6 +14,8 @@ jobs: include: - laravel: 10.* testbench: 8.* + - laravel: 9.* + testbench: 8.* steps: - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/composer.json b/composer.json index 2c37da7..d0ee56f 100644 --- a/composer.json +++ b/composer.json @@ -41,14 +41,23 @@ } }, "require": { - "php": "^8.0", - "CSlant/telegram-git-notifier": "dev-main" + "php": "^8.1", + "cslant/telegram-git-notifier": "^v1.3.1" }, "require-dev": { "friendsofphp/php-cs-fixer": "^v3.37.1", "pestphp/pest": "^2.24", "phpstan/phpstan": "^1.10.39" }, + "scripts": { + "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes", + "post-install-cmd": [ + "bash vendor/cslant/telegram-git-notifier/install.sh" + ], + "post-update-cmd": [ + "bash vendor/cslant/telegram-git-notifier/install.sh" + ] + }, "support": { "issues": "https://github.com/cslant/laravel-telegram-git-notifier/issues" }, @@ -60,7 +69,10 @@ } }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true + } }, "minimum-stability": "dev", "prefer-stable": true diff --git a/config/telegram-git-notifier.php b/config/telegram-git-notifier.php index d0619f1..0193988 100644 --- a/config/telegram-git-notifier.php +++ b/config/telegram-git-notifier.php @@ -31,11 +31,11 @@ 'author' => [ 'discussion' => env( 'TGN_AUTHOR_DISCUSSION', - 'https://github.com/lbiltech/laravel-telegram-git-notifier/discussions' + 'https://github.com/cslant/laravel-telegram-git-notifier/discussions' ), 'source_code' => env( 'TGN_AUTHOR_SOURCE_CODE', - 'https://github.com/lbiltech/laravel-telegram-git-notifier' + 'https://github.com/cslant/laravel-telegram-git-notifier' ), ], diff --git a/phpunit.xml b/phpunit.xml index 8865424..020d324 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -13,8 +13,8 @@ - + tests - \ No newline at end of file + diff --git a/routes/bot.php b/routes/bot.php index 8b8757a..19c1bb4 100644 --- a/routes/bot.php +++ b/routes/bot.php @@ -1,7 +1,7 @@ Date: Sat, 4 Nov 2023 00:21:33 +0700 Subject: [PATCH 3/3] fix small: style code --- routes/bot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/bot.php b/routes/bot.php index 19c1bb4..71fb44e 100644 --- a/routes/bot.php +++ b/routes/bot.php @@ -1,7 +1,7 @@