diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..c276b3b --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,17 @@ +version = 1 + +[[analyzers]] +name = "php" +enabled = true + +[[analyzers]] +name = "test-coverage" +enabled = true + +[[analyzers]] +name = "secrets" +enabled = true + +[[analyzers]] +name = "shell" +enabled = true \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..201ba10 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,75 @@ +name: CI + +on: [ push ] + +jobs: + build-php: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v2" + with: + path: "vendor" + key: "php-8.1-composer-${{ hashFiles('composer.json') }}" + - uses: php-actions/composer@v6 + with: + php_version: "8.1" + version: 2 + dev: yes + args: --no-interaction --no-progress --prefer-dist --no-scripts + php-l: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: "Run php -l on all files in src" + run: > + find src -type f -name '*.php' -exec php -l {} \; + tests: + runs-on: ubuntu-latest + needs: build-php + steps: + - uses: actions/checkout@v2 + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v2" + with: + path: "vendor" + key: "php-8.1-composer-${{ hashFiles('composer.json') }}" + restore-keys: "php-8.1-composer" + - uses: php-actions/composer@v6 + with: + php_version: "8.1" + php_extensions: pcov + version: 2 + dev: yes + args: --no-interaction --no-progress --prefer-dist + - uses: php-actions/phpstan@v3 + with: + path: src + memory_limit: 1G + level: 8 + php_version: "8.1" +# - name: Run phpunit +# run: php bin/phpunit --coverage-text + + release: + runs-on: ubuntu-latest + needs: tests + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v2 + with: + extra_plugins: | + @semantic-release/commit-analyzer + @semantic-release/release-notes-generator + @semantic-release/changelog + @semantic-release/github + @semantic-release/git + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: New release + if: steps.semantic.outputs.new_release_published == 'true' + run: | + echo ${{ steps.semantic.outputs.new_release_version }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..cefcc92 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Lint +on: [ push ] +jobs: + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + tools: php-cs-fixer + - name: Run phpcbf + run: php-cs-fixer fix --rules=@PSR2 src + - name: Run phpcbf cache file + run: rm .php-cs-fixer.cache + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Apply php-cs-fixer changes diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a9875b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +composer.lock diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..5d6ed54 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,10 @@ +{ + "branches": ["main"], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/changelog", + "@semantic-release/github", + "@semantic-release/git" + ] +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..949b576 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 LAHAXE Arnaud + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1af6bcf --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# HealthCheck system checker + +## Installation + +Install checker: + +```bash + composer require alahaxe/healthcheck-redis +``` + +Register service in your app: + +```yaml + Alahaxe\HealthCheckBundle\Checks\Redis\RedisCheck: + arguments: + # @see https://symfony.com/doc/current/components/cache/adapters/redis_adapter.html#configure-the-connection + $dns: "redis://abcdef@localhost?timeout=5" + # optional + $name: "redis_01" + tags: ['lahaxearnaud.healthcheck.check'] +``` diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..17384a6 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,14 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 0.1.x | :white_check_mark: | + +## Reporting a Vulnerability + +If you find any security issue in this repository please contact github@lahaxe.fr before creating an Issue diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..bd40550 --- /dev/null +++ b/composer.json @@ -0,0 +1,23 @@ +{ + "name": "alahaxe/healthcheck-redis", + "description": "Redis checks for alahaxe/healthcheck-bundle", + "type": "library", + "license": "MIT", + "autoload": { + "psr-4": { + "Alahaxe\\HealthCheckBundle\\Checks\\Redis\\": "src/" + } + }, + "authors": [ + { + "name": "LAHAXE Arnaud", + "email": "lahaxe.arnaud@gmail.com" + } + ], + "minimum-stability": "stable", + "require": { + "php": "^8.1", + "alahaxe/healthcheck-contracts": "^1.0", + "symfony/cache": "^5.4 || ^6.0" + } +} diff --git a/src/RedisCheck.php b/src/RedisCheck.php new file mode 100644 index 0000000..7008814 --- /dev/null +++ b/src/RedisCheck.php @@ -0,0 +1,38 @@ +dsn); + } catch (\Throwable $exception) { + $status = CheckStatus::STATUS_INCIDENT; + } + + return new CheckStatus( + $this->name, + __CLASS__, + $status + ); + } +}