Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
tg666 committed Jan 25, 2024
0 parents commit 7dd061d
Show file tree
Hide file tree
Showing 74 changed files with 3,870 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.github export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php-cs-fixer.dist.php export-ignore
docker-compose.yml export-ignore
Dockerfile export-ignore
Makefile export-ignore
phpstan.neon export-ignore
tests export-ignore
52 changes: 52 additions & 0 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Coding style

on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main

jobs:
php-cs-fixer:
name: Php-Cs-Fixer
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: composer:v2
extensions: uopz

- name: Install dependencies
run: composer update --no-progress --prefer-dist --prefer-stable --optimize-autoloader --quiet

- name: Php-Cs-Fixer
run: vendor/bin/php-cs-fixer fix -v --dry-run

php-stan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: composer:v2
extensions: uopz

- name: Install dependencies
run: composer update --no-progress --prefer-dist --prefer-stable --optimize-autoloader --quiet

- name: PhpStan
run: vendor/bin/phpstan analyse
40 changes: 40 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Coverage

on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main

jobs:
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: pcov
extensions: tokenizer, uopz
tools: composer:v2

- name: Install dependencies
run: composer update --no-progress --prefer-dist --prefer-stable --optimize-autoloader

- name: Generate the coverage report
run: vendor/bin/tester -C -s --coverage ./coverage.xml --coverage-src ./src ./tests

- name: Upload the coverage report
env:
COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.3/php-coveralls.phar
php php-coveralls.phar --verbose --config tests/.coveralls.yml
41 changes: 41 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tests

on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main

jobs:
tests:
name: Unit Tests [PHP ${{ matrix.php-versions }}]
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.1', '8.2']
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer:v2
extensions: uopz

- name: Install dependencies
run: composer update --no-progress --prefer-dist --prefer-stable --optimize-autoloader

- name: Run tests
run: vendor/bin/tester -C -s ./tests

- name: Install dependencies (lowest)
run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable --optimize-autoloader

- name: Run tests
run: vendor/bin/tester -C -s ./tests
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
composer.lock
coverage.xml
/vendor
/.idea
110 changes: 110 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php

use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixerCustomFixers\Fixers as CustomFixers;
use PhpCsFixerCustomFixers\Fixer\ConstructorEmptyBracesFixer;
use PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer;

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

return (new Config())
->registerCustomFixers(new CustomFixers())
->setUsingCache(false)
->setIndent(" ")
->setRules([
'@PSR2' => true,
'array_syntax' => [
'syntax' => 'short'
],
'trailing_comma_in_multiline' => [
'elements' => [
'arguments',
'arrays',
'match',
'parameters',
],
],
'constant_case' => [
'case' => 'lower',
],
'declare_strict_types' => true,
'phpdoc_align' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => [
'statements' => [
'break',
'continue',
'declare',
'return'
],
],
'blank_line_after_namespace' => true,
'blank_lines_before_namespace' => [
'max_line_breaks' => 2,
'min_line_breaks' => 2,
],
'return_type_declaration' => [
'space_before' => 'none',
],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => [
'class',
'function',
'const'
],
],
'no_unused_imports' => true,
'single_line_after_imports' => true,
'no_leading_import_slash' => true,
'global_namespace_import' => [
'import_constants' => true,
'import_functions' => true,
'import_classes' => true,
],
'fully_qualified_strict_types' => true,
'concat_space' => [
'spacing' => 'one',
],
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => false,
'remove_inheritdoc' => true,
'allow_unused_params' => false,
],
'no_empty_phpdoc' => true,
'no_blank_lines_after_phpdoc' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_trim' => true,
'no_extra_blank_lines' => [
'tokens' => [
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'throw',
'use',
],
],
'single_trait_insert_per_statement' => true,
'single_class_element_per_statement' => [
'elements' => [
'const',
'property',
],
],
'type_declaration_spaces' => [
'elements' => [
'function',
'property',
],
],
ConstructorEmptyBracesFixer::name() => true,
MultilinePromotedPropertiesFixer::name() => true,
])
->setRiskyAllowed(true)
->setFinder($finder);
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM php:8.1.25-cli-alpine3.18 AS php81

CMD ["/bin/sh"]
WORKDIR /var/www/html

RUN apk add --no-cache --update git
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN apk add --no-cache ${PHPIZE_DEPS} \
&& pecl install pcov \
&& pecl install uopz-7.1.1 \
&& docker-php-ext-enable pcov uopz

CMD tail -f /dev/null

FROM php:8.2.13RC1-cli-alpine3.18 AS php82

CMD ["/bin/sh"]
WORKDIR /var/www/html

RUN apk add --no-cache --update git
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN apk add --no-cache ${PHPIZE_DEPS} \
&& pecl install pcov \
&& pecl install uopz-7.1.1 \
&& docker-php-ext-enable pcov uopz

CMD tail -f /dev/null
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 '68 Publishers

> 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.
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
init:
make stop
make start

stop:
docker compose stop

start:
docker compose up -d

down:
docker compose down

restart:
make stop
make start

tests.all:
PHP=81 make tests.run
PHP=82 make tests.run

cs.fix:
PHP=81 make composer.update
docker exec 68publishers.oauth.81 vendor/bin/php-cs-fixer fix -v

cs.check:
PHP=81 make composer.update
docker exec 68publishers.oauth.81 vendor/bin/php-cs-fixer fix -v --dry-run

stan:
PHP=81 make composer.update
docker exec 68publishers.oauth.81 vendor/bin/phpstan analyse

coverage:
PHP=81 make composer.update
docker exec 68publishers.oauth.81 vendor/bin/tester -p phpdbg -C -s --coverage ./coverage.xml --coverage-src ./src ./tests

composer.update:
ifndef PHP
$(error "PHP argument not set.")
endif
@echo "========== Installing dependencies with PHP $(PHP) ==========" >&2
docker exec 68publishers.oauth.$(PHP) composer update --no-progress --prefer-dist --prefer-stable --optimize-autoloader --quiet

composer.update-lowest:
ifndef PHP
$(error "PHP argument not set.")
endif
@echo "========== Installing dependencies with PHP $(PHP) (prefer lowest dependencies) ==========" >&2
docker exec 68publishers.oauth.$(PHP) composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable --optimize-autoloader --quiet

tests.run:
ifndef PHP
$(error "PHP argument not set.")
endif
PHP=$(PHP) make composer.update
@echo "========== Running tests with PHP $(PHP) ==========" >&2
docker exec 68publishers.oauth.$(PHP) vendor/bin/tester -C -s ./tests
PHP=$(PHP) make composer.update-lowest
@echo "========== Running tests with PHP $(PHP) (prefer lowest dependencies) ==========" >&2
docker exec 68publishers.oauth.$(PHP) vendor/bin/tester -C -s ./tests
Loading

0 comments on commit 7dd061d

Please sign in to comment.