From 226461be9378186e2ed1fc0dbfea0f5c3bc7fe9e Mon Sep 17 00:00:00 2001 From: Arthur LORENT Date: Fri, 25 Sep 2020 10:29:45 +0200 Subject: [PATCH] Laravel 8 support (#2) * Added Laravel 8 support. * Dropped Laravel 6 support. * Dependencies are now optional. --- .gitattributes | 1 + .github/workflows/main.yml | 14 ++++++------- CHANGELOG.md | 10 +++++++++ README.md | 23 ++++++++++++++++---- composer.json | 17 +++++++++------ config/supervisor-downtime-notifier.php | 28 ++++++++++++++++--------- docs/upgrade-guides/from-v1-to-v2.md | 21 +++++++++++++++++++ phpunit.xml | 23 +++++++++++--------- 8 files changed, 100 insertions(+), 37 deletions(-) create mode 100644 docs/upgrade-guides/from-v1-to-v2.md diff --git a/.gitattributes b/.gitattributes index 7f346f6..4bffc1c 100755 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,7 @@ # Ignore all test and documentation with "export-ignore". /.github export-ignore +/docs export-ignore /tests export-ignore /.editorconfig export-ignore /.gitattributes export-ignore diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 581a25c..35c2030 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,12 +15,12 @@ jobs: fail-fast: true matrix: php: ['7.4'] - laravel: ['6.*', '7.*'] + laravel: ['7.*', '8.*'] include: + - laravel: '8.*' + testbench: '6.*' - laravel: '7.*' testbench: '5.*' - - laravel: '6.*' - testbench: '4.*' name: P${{ matrix.php }} - L${{ matrix.laravel }} @@ -49,26 +49,26 @@ jobs: # lower php and laravel versions - name: PHPUnit - if: matrix.php != '7.4' || matrix.laravel != '7.*' + if: matrix.php != '7.4' || matrix.laravel != '8.*' run: vendor/bin/phpunit # last php and laravel versions - name: Code analysis - if: matrix.php == '7.4' && matrix.laravel == '7.*' + if: matrix.php == '7.4' && matrix.laravel == '8.*' run: | vendor/bin/phpcs vendor/bin/phpmd src text phpmd.xml vendor/bin/phpstan analyse - name: PHPUnit + Code coverage - if: matrix.php == '7.4' && matrix.laravel == '7.*' + if: matrix.php == '7.4' && matrix.laravel == '8.*' run: | mkdir -p build/logs vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml - name: Code coverage upload to Coveralls - if: matrix.php == '7.4' && matrix.laravel == '7.*' + if: matrix.php == '7.4' && matrix.laravel == '8.*' env: COVERALLS_RUN_LOCALLY: 1 COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index c6ed013..ba7c4c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [2.0.0](https://github.com/Okipa/laravel-supervisor-downtime-notifier/compare/1.1.0...2.0.0) + +2020-09-25 + +* Added Laravel 8 support. +* Dropped Laravel 6 support. +* Dependencies are now optional. + +:point_right: [See the upgrade guide](/docs/upgrade-guides/from-v1-to-v2.md) + ## [1.1.2](https://github.com/Okipa/laravel-supervisor-downtime-notifier/compare/1.1.1...1.1.2) ## [1.1.1](https://github.com/Okipa/laravel-supervisor-downtime-notifier/compare/1.1.0...1.1.1) diff --git a/README.md b/README.md index dc1c907..5ff5840 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,13 @@ Notifications can be sent by mail, Slack and webhooks (chats often provide a web | Laravel version | PHP version | Package version | |---|---|---| +| ^7.0 | ^7.4 | ^2.0 | | ^6.0 | ^7.4 | ^1.0 | +## Upgrade guide + +* [From v1 to V2](/docs/upgrade-guides/from-v1-to-v2.md) + ## Table of Contents * [Requirements](#requirements) * [Installation](#installation) @@ -53,13 +58,23 @@ That being said, you still can use this package for other servers OS by using yo Install the package with composer: ```bash -composer require "okipa/laravel-supervisor-downtime-notifier:^1.0" +composer require "okipa/laravel-supervisor-downtime-notifier:^2.0" +``` + +If you intend to send `Slack` notifications you will have to install: + +* https://github.com/laravel/slack-notification-channel + +```bash +composer require laravel/slack-notification-channel ``` -In case you want to use `Slack` notifications you'll also have to install: +If you intend to send `webhook` notifications you will have to install: + +* https://github.com/laravel-notification-channels/webhook ```bash -composer require guzzlehttp/guzzle +composer require laravel-notification-channels/webhook ``` ## Configuration @@ -102,7 +117,7 @@ $schedule->command('supervisor:downtime:notify')->everyFifteenMinutes(); And you will be notified if your supervisor service is not running, or if your environment supervisor processes are down when the command will be executed. -To check if everything is correctly configured, you can simulate supervisor downtime detection: +Once everything has been set up, you can check if the configuration is correct by simulating supervisor processes downtime: ```bash php artisan supervisor:downtime:simulate diff --git a/composer.json b/composer.json index 047342a..b3d2c6e 100644 --- a/composer.json +++ b/composer.json @@ -29,15 +29,15 @@ ], "require": { "php": "^7.4", - "illuminate/support": "^6.0||^7.0", - "laravel-notification-channels/webhook": "2.0.*", - "laravel/slack-notification-channel": "^2.0" + "illuminate/support": "^7.0||^8.0" }, "require-dev": { "nunomaduro/larastan": "^0.6", - "orchestra/testbench": "^4.0||^5.0", + "orchestra/testbench": "^5.0||^6.0", "phpmd/phpmd": "^2.8", - "squizlabs/php_codesniffer": "^3.5" + "squizlabs/php_codesniffer": "^3.5", + "laravel-notification-channels/webhook": "^2.0", + "laravel/slack-notification-channel": "^2.0" }, "autoload": { "psr-4": { @@ -54,10 +54,15 @@ "vendor/bin/phpcbf", "vendor/bin/phpcs", "vendor/bin/phpmd config,src text phpmd.xml", - "vendor/bin/phpstan analyse", + "vendor/bin/phpstan analyse --error-format=table --memory-limit=2048M", "vendor/bin/phpunit" ] }, + "suggest": { + "guzzlehttp/guzzle": "Required for sending notifications via Slack", + "laravel/slack-notification-channel": "Required for sending notifications via Slack", + "laravel-notification-channels/webhook": "Required for sending notifications via Webhook" + }, "extra": { "laravel": { "providers": [ diff --git a/config/supervisor-downtime-notifier.php b/config/supervisor-downtime-notifier.php index 0e27318..5221a97 100644 --- a/config/supervisor-downtime-notifier.php +++ b/config/supervisor-downtime-notifier.php @@ -1,7 +1,5 @@ [ 'sudo' => true, 'processes' => [ - // 'laravel-queue-production-worker:*', + // 'laravel-horizon-project-production:*', ] ], - 'staging' => [ + 'preprod' => [ 'sudo' => true, 'processes' => [ - // 'laravel-queue-staging-worker:*', + // 'laravel-horizon-project-preprod:*', ] ], ], @@ -65,13 +63,23 @@ /* * The channels to which the notification will be sent. */ - 'channels' => ['mail', 'slack', WebhookChannel::class], + 'channels' => [ + 'mail', + // 'slack', // Requires laravel/slack-notification-channel package + // NotificationChannels\Webhook\WebhookChannel::class, // Requires laravel-notification-channels/webhook package + ], - 'mail' => ['to' => 'email@example.test'], + 'mail' => [ + 'to' => 'email@example.test', + ], - 'slack' => ['webhookUrl' => 'https://your-slack-webhook.slack.com'], + 'slack' => [ + 'webhookUrl' => 'https://your-slack-webhook.slack.com', + ], - // rocket chat webhook example - 'webhook' => ['url' => 'https://rocket.chat/hooks/1234/5678'], + // Rocket chat webhook example + 'webhook' => [ + 'url' => 'https://rocket.chat/hooks/1234/5678', + ], ]; diff --git a/docs/upgrade-guides/from-v1-to-v2.md b/docs/upgrade-guides/from-v1-to-v2.md new file mode 100644 index 0000000..41a4f5d --- /dev/null +++ b/docs/upgrade-guides/from-v1-to-v2.md @@ -0,0 +1,21 @@ +# Upgrade from v1 to V2 + +Follow the steps below to upgrade the package. + +## Optional dependencies + +The following dependencies are not installed by default anymore: +* https://github.com/laravel/slack-notification-channel +* https://github.com/laravel-notification-channels/webhook + +This allows you to avoid useless dependencies installations if you do not want to send Slack and webhook notifications. + +In the opposite, if you intend to send Slack and/or webhook notifications, install the required dependencies by following the [installation](../../README.md#installation) instructions. + +## See all changes + +See all change with the [comparison tool](https://github.com/Okipa/laravel-table/compare/1.5.0...2.0.0). + +## Undocumented changes + +If you see any forgotten and undocumented change, please submit a PR to add them to this upgrade guide. diff --git a/phpunit.xml b/phpunit.xml index 4627524..d9883b5 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,6 @@ - + stopOnFailure="false" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + + src + + + + + ./tests/ - - - src - - - - - +