Skip to content

Commit

Permalink
Laravel 8 support (#2)
Browse files Browse the repository at this point in the history
* Added Laravel 8 support.
* Dropped Laravel 6 support.
* Dependencies are now optional.
  • Loading branch information
Okipa authored Sep 25, 2020
1 parent 190df9c commit 226461b
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down Expand Up @@ -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 }}
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": [
Expand Down
28 changes: 18 additions & 10 deletions config/supervisor-downtime-notifier.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

use NotificationChannels\Webhook\WebhookChannel;

return [

/*
Expand All @@ -19,13 +17,13 @@
'production' => [
'sudo' => true,
'processes' => [
// 'laravel-queue-production-worker:*',
// 'laravel-horizon-project-production:*',
]
],
'staging' => [
'preprod' => [
'sudo' => true,
'processes' => [
// 'laravel-queue-staging-worker:*',
// 'laravel-horizon-project-preprod:*',
]
],
],
Expand Down Expand Up @@ -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 protected]'],
'mail' => [
'to' => '[email protected]',
],

'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',
],

];
21 changes: 21 additions & 0 deletions docs/upgrade-guides/from-v1-to-v2.md
Original file line number Diff line number Diff line change
@@ -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.
23 changes: 13 additions & 10 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
Expand All @@ -8,21 +9,23 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
</php>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<logging/>
</phpunit>

0 comments on commit 226461b

Please sign in to comment.