Skip to content

Commit

Permalink
feat: first implementation (#1)
Browse files Browse the repository at this point in the history
* feat!: first implementation

* chore: add implementation health check

* chore: add testes

* chore: add tests + stubs

* chore: corrige em versoes antigas

* chore: create function to get timestamp

* chore: update phpunit.xml + gitignore

* chore: adiciona testes unitarios

* chore: add sonar

* chore: atualiza função para pegar memoria

* chore: remove arquivos

* chore: atualiza dev com xdebug

* chore: atualiza testes

* chore: add scripts to run tests

* chore: add tests to runners

* chore: update gitignore

* chore: remove composer.lock do git

* docs: add documentação
  • Loading branch information
lucasvillatore authored Jun 27, 2023
1 parent a2584a1 commit 5eb1c78
Show file tree
Hide file tree
Showing 47 changed files with 2,187 additions and 19 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: xdebug

- name: Install dependencies with composer
run: composer update --no-ansi --no-interaction --no-progress

- name: Run tests with phpunit/phpunit
run: vendor/bin/phpunit --coverage-clover=coverage.xml

- name: Fix code coverage paths
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@

vendor/
reports/
.phpunit.cache/
.phpunit.result.cache
composer.lock
51 changes: 51 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/app" : "${workspaceFolder}"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"test": "./vendor/bin/phpunit --colors",
"test:coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors --coverage-html ./reports"
}
}
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
build:
context: .
dockerfile: ./docker/php8.1/Dockerfile
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- .:/app
user: $UID:$GID
4 changes: 3 additions & 1 deletion docker/php7.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ RUN pecl channel-update pecl.php.net \
&& pecl install xdebug-2.6.0 \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
RUN docker-php-ext-enable xdebug

COPY ./docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
2 changes: 1 addition & 1 deletion docker/php7.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ RUN pecl channel-update pecl.php.net \
&& pecl install xdebug-2.7.0 \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

COPY --from=composer:2.0 /usr/bin/composer /usr/bin/composer
RUN docker-php-ext-enable xdebug

COPY ./docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
2 changes: 2 additions & 0 deletions docker/php7.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ RUN pecl channel-update pecl.php.net \
&& pecl install xdebug-2.8.0 \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN docker-php-ext-enable xdebug

COPY ./docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
2 changes: 2 additions & 0 deletions docker/php7.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ RUN pecl channel-update pecl.php.net \
&& pecl install xdebug-2.9.0 \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN docker-php-ext-enable xdebug

COPY ./docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
2 changes: 2 additions & 0 deletions docker/php8.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ RUN pecl channel-update pecl.php.net \
&& pecl install xdebug-3.1.3 \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN docker-php-ext-enable xdebug

COPY ./docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
2 changes: 2 additions & 0 deletions docker/php8.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ RUN pecl channel-update pecl.php.net \
&& pecl install xdebug-3.2.1 \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN docker-php-ext-enable xdebug

COPY ./docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
16 changes: 5 additions & 11 deletions docker/xdebug.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
[xdebug]
zend_extension=xdebug.so

xdebug.mode=develop,debug,coverage
xdebug.cli_color=1
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1

xdebug.profiler_output_dir="/tmp"
xdebug.profiler_output_name="cachegrind.out.%H.%t.%p"

xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.mode=develop,coverage,debug,profile
xdebug.idekey=vsc
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal
xdebug.discover_client_host=0
17 changes: 14 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
## Documentação Técnica
# Documentação Técnica

<!--- Acesse o link no confluence para ver mais sobre o plugin techdocs
https://madeiramadeira.atlassian.net/wiki/spaces/DX/pages/2792980526/TechDocs>
- [Instalação](./instalacao.md)
- [Uso](./uso.md)

## Versões suportadas

Todas as versões são garantidas por testes unitários que são testados no momento do CI.

- [x] PHP 7.1
- [x] PHP 7.2
- [x] PHP 7.3
- [x] PHP 7.4
- [x] PHP 8.0
- [x] PHP 8.1
12 changes: 12 additions & 0 deletions docs/instalacao.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Usando a biblioteca

**Instalação:**

No terminal, rode:

```bash
$ composer config repositories.lib-php-health-check git git@github.com:madeiramadeirabr/lib-php-health-check.git
$ composer require madeiramadeirabr/lib-php-health-check
```

A partir disso já é possível usar a biblioteca.
Loading

0 comments on commit 5eb1c78

Please sign in to comment.