Skip to content

Commit

Permalink
Melhorando cobertura de testes e suporte a novas versões do PHP (#17)
Browse files Browse the repository at this point in the history
* Adicionando gitattributes

* Testes de unidade para os providers

* Adicionando testes unitarios para o CEP Aberto

* WIP Correios

* Testes unitarios do CorreiosProvider

* WIP Testes CepPromise

* Adicionando testes das exceções

* Github Actions e ajustes no composer

* Bumping guzzle version supported

* Bumping PHPunit

* Instalando CS Fixer e usando Github actions

* Update .php_cs.dist.php

* Ignoring php-cs-fixer cache

* Ajustando regras CS Fixer e GithubActions

* Fix styling

* Atualizando Github Actions dos testes

* Update php-cs-fixer.yml

* Ajustando visibilidade do metodo

Co-authored-by: claudsonm <[email protected]>
  • Loading branch information
claudsonm and claudsonm authored Oct 9, 2022
1 parent c80044f commit 766d9b6
Show file tree
Hide file tree
Showing 22 changed files with 666 additions and 2,989 deletions.
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
* text=auto
* text eol=lf

# Ignore all test and documentation with "export-ignore".
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs.dist export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/.all-contributorsrc export-ignore
/phpunit.xml export-ignore
/tests export-ignore
35 changes: 35 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Check & fix styling

on:
push:
branches:
- master
pull_request:
paths:
- '**.php'

jobs:
style:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Fix style
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist.php --allow-risky=yes

- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
branch: ${{ steps.extract_branch.outputs.branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Run Tests"

on:
push:
branches:
- master
pull_request:

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
php: [ 8.1, 8.0, 7.4 ]
dependency-version: [ prefer-lowest, prefer-stable ]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
coverage: none

- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.phpunit.result.cache
.php-cs-fixer.cache
# Created by https://www.gitignore.io/api/macos,linux,windows,composer,sublimetext,phpstorm+all,webstorm+all,jetbrains+all,visualstudiocode
# Edit at https://www.gitignore.io/?templates=macos,linux,windows,composer,sublimetext,phpstorm+all,webstorm+all,jetbrains+all,visualstudiocode

Expand All @@ -8,7 +9,7 @@ composer.phar

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
composer.lock

### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
Expand Down Expand Up @@ -305,4 +306,4 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/macos,linux,windows,composer,sublimetext,phpstorm+all,webstorm+all,jetbrains+all,visualstudiocode
# End of https://www.gitignore.io/api/macos,linux,windows,composer,sublimetext,phpstorm+all,webstorm+all,jetbrains+all,visualstudiocode
99 changes: 0 additions & 99 deletions .php_cs.dist

This file was deleted.

40 changes: 40 additions & 0 deletions .php_cs.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return (new PhpCsFixer\Config())
->setUsingCache(false)
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
131 changes: 0 additions & 131 deletions .styleci.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

Loading

0 comments on commit 766d9b6

Please sign in to comment.