Skip to content

Commit

Permalink
feat(init): Project init
Browse files Browse the repository at this point in the history
  • Loading branch information
lahaxearnaud committed Jan 2, 2022
0 parents commit 5c51003
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -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
75 changes: 75 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor/
composer.lock
10 changes: 10 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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']
```
14 changes: 14 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -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 [email protected] before creating an Issue
23 changes: 23 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
}
],
"minimum-stability": "stable",
"require": {
"php": "^8.1",
"alahaxe/healthcheck-contracts": "^1.0",
"symfony/cache": "^5.4 || ^6.0"
}
}
38 changes: 38 additions & 0 deletions src/RedisCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Alahaxe\HealthCheckBundle\Checks\Redis;

use _PHPStan_71572f9a1\Psr\Log\LoggerAwareTrait;
use Alahaxe\HealthCheck\Contracts\CheckInterface;
use Alahaxe\HealthCheck\Contracts\CheckStatus;
use Alahaxe\HealthCheck\Contracts\CheckStatusInterface;
use Psr\Cache\CacheException;
use Psr\Log\LoggerAwareInterface;
use Symfony\Component\Cache\Adapter\RedisAdapter;

class RedisCheck implements CheckInterface, LoggerAwareInterface
{
use LoggerAwareTrait;

public function __construct(
protected string $dsn,
protected string $name = 'redis'
) {
}

public function check(): CheckStatusInterface
{
$status = CheckStatus::STATUS_OK;
try {
RedisAdapter::createConnection($this->dsn);
} catch (\Throwable $exception) {
$status = CheckStatus::STATUS_INCIDENT;
}

return new CheckStatus(
$this->name,
__CLASS__,
$status
);
}
}

0 comments on commit 5c51003

Please sign in to comment.