Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoapaes committed Mar 24, 2022
0 parents commit e7dc8cd
Show file tree
Hide file tree
Showing 14 changed files with 311 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "like/composer-empty",
"dockerComposeFile": [
"../docker-compose.yml"
],
"service": "php",
"shutdownAction": "none",
"workspaceFolder": "/var/www/public/",
"extensions": [
"bmewburn.vscode-intelephense-client",
"hbenl.vscode-test-explorer",
"recca0120.vscode-phpunit",
"eamodio.gitlens",
"mhutchie.git-graph",
"junstyle.php-cs-fixer",
"janbn.git-last-commit-message"
]
}
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
GITHUB_TOKEN=
CODECOMMIT_USER=
CODECOMMIT_PASSWORD=
PHP_VERSION=56|73|74|80
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

on:
push:
branches:
- master

pull_request:

jobs:

test:
strategy:
matrix:
PHP: [56, 73, 74, 80]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Prepare code
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
touch .env
echo "CODECOMMIT_USER=${{ secrets.CODECOMMIT_USER }}" >> .env
echo "CODECOMMIT_PASSWORD=${{ secrets.CODECOMMIT_PASSWORD }}" >> .env
echo "GITHUB_TOKEN=${{ secrets.GH_TOKEN }}" >> .env
echo "PHP_VERSION=$PHP_VERSION" >> .env
- name: Prepare environment
run: |
docker-compose up -d
echo $(docker run -t --network github jwilder/dockerize -wait tcp://php:9000 -timeout 120s)
docker-compose ps
docker-compose logs php
- name: Run PHP Unit
run: |
docker-compose exec -T php composer test
- name: Run PHP Stan
if: matrix.PHP != '56'
run: |
docker-compose exec -T php composer analyse
- name: Run PHP CS Fixer
if: matrix.PHP != '56'
run: |
docker-compose exec -T php composer fix:ci
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/.idea/
/nbproject/
desktop.ini
/vendor/
.env
composer.lock
tests/phpunit.*.xml
.phpunit.result.cache
.php_cs.cache
.php-cs-fixer.cache
51 changes: 51 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

$rules = [
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'multiline_whitespace_before_semicolons' => false,
'echo_tag_syntax' => false,
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'no_useless_else' => true,
'ordered_imports' => ['sort_algorithm' => 'none', 'imports_order' => ['const', 'class', 'function']],
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_indent' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_trim' => true,
'phpdoc_var_without_name' => true,
'phpdoc_to_comment' => true,
'single_quote' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'braces' => [
'allow_single_line_closure' => true,
'position_after_functions_and_oop_constructs' => 'same',
],
];

$excludes = [
'vendor',
'.vscode',
'.github',
'.devcontainer'
];

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude($excludes)
->notName('README.md')
->notName('*.xml')
->notName('*.yml')
->notName('_ide_helper.php')
;

return (new PhpCsFixer\Config())
->setRules($rules)
->setFinder($finder)
->setIndent("\t")
;
58 changes: 58 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

$rules = [
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'no_multiline_whitespace_before_semicolons' => true,
'no_short_echo_tag' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'no_useless_else' => true,
'ordered_imports' => ['sort_algorithm' => 'none', 'imports_order' => ['const', 'class', 'function']],
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_indent' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_trim' => true,
'phpdoc_var_without_name' => true,
'phpdoc_to_comment' => true,
'single_quote' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'braces' => [
'allow_single_line_closure' => true,
'position_after_functions_and_oop_constructs' => 'same'
]
];

$excludes = [
'vendor',
'storage',
'node_modules',
'.vscode',
'.github',
'.devcontainer',
'logs',
'files',
'k8s',
'socket',
'temp'
];

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude($excludes)
->notName('README.md')
->notName('*.xml')
->notName('*.yml')
->notName('_ide_helper.php')
;

return PhpCsFixer\Config::create()
->setRules($rules)
->setFinder($finder)
->setIndent("\t")
;
11 changes: 11 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"recommendations": [
"bmewburn.vscode-intelephense-client",
"hbenl.vscode-test-explorer",
"recca0120.vscode-phpunit",
"eamodio.gitlens",
"mhutchie.git-graph",
"junstyle.php-cs-fixer",
"janbn.git-last-commit-message"
]
}
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"files.encoding": "iso88591",
"[php]": {
"editor.defaultFormatter": "junstyle.php-cs-fixer"
},
"[json]": {
"files.encoding": "utf8",
},
"php-cs-fixer.onsave": true,
"php-cs-fixer.showOutput": false,
"php-cs-fixer.autoFixByBracket": true
}
37 changes: 37 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "likesistemas/nomedalib",
"type": "library",
"description": "Descriçãoo da biblioteca.",
"repositories": [
{"type": "composer", "url": "https://composer.likesistemas.com.br/"}
],
"require": {
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^9.0"
},
"autoload": {
"psr-4": {
"Like\\NomeDaLib\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Like\\NomeDaLib\\Tests\\": "tests/"
}
},
"authors": [
{
"name": "Like Sistemas",
"email": "[email protected]",
"homepage": "https://www.likesistemas.com.br/"
}
],
"scripts": {
"fix": "php-cs-fixer fix",
"fix:ci": "php-cs-fixer fix --dry-run --stop-on-violation",
"test": "phpunit",
"analyse": "phpstan analyse"
}
}
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.7'
networks:
github:
name: github
driver: bridge

services:

php:
image: likesistemas/php-dev:${PHP_VERSION:-56}
environment:
- CODECOMMIT_HOST=git-codecommit.us-east-1.amazonaws.com
- GITHUB_TOKEN=$GITHUB_TOKEN
- CODECOMMIT_USER=$CODECOMMIT_USER
- CODECOMMIT_PASSWORD=$CODECOMMIT_PASSWORD
- URL_SENTRY=${URL_SENTRY}
volumes:
- ./:/var/www/public/
networks:
- github
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 5
paths:
- src
- tests
17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit>
<testsuites>
<testsuite name="tests">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="./tests/phpunit.coverage.xml"/>
<log type="junit" target="./tests/phpunit.report.xml" />
</logging>
</phpunit>
6 changes: 6 additions & 0 deletions src/NomeDaLib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

namespace Like\NomeDaLib;

class NomeDaLib {
}
12 changes: 12 additions & 0 deletions tests/NomeDaLibTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Like\NomeDaLib\Tests;

use Like\NomeDaLib\NomeDaLib;
use PHPUnit\Framework\TestCase;

class NomeDaLibTest extends TestCase {
public function testInstance() {
$this->assertInstanceOf(NomeDaLib::class, new NomeDaLib());
}
}

0 comments on commit e7dc8cd

Please sign in to comment.