Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
tg666 committed Nov 20, 2023
0 parents commit 6aa0f64
Show file tree
Hide file tree
Showing 76 changed files with 3,915 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
50 changes: 50 additions & 0 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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: 7.4
tools: composer:v2

- 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: 7.4
tools: composer:v2

- 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/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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: ['7.4', '8.0', '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

- 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
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Application
composer.lock
vendor/
coverage.xml

# Project files etc.
.idea

# MacOS
.DS_Store
107 changes: 107 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

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

$finder = Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');

return (new Config())
->registerCustomFixers(new CustomFixers())
->setUsingCache(false)
->setIndent(" ")
->setRules([
'@PSR2' => true,
'array_syntax' => [
'syntax' => 'short'
],
'trailing_comma_in_multiline' => [
'elements' => [
'arguments',
'arrays',
],
],
'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' => true,
'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,
])
->setRiskyAllowed(true)
->setFinder($finder);
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM php:7.4.33-cli-alpine3.16 AS php74

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 \
&& docker-php-ext-enable pcov

CMD tail -f /dev/null

FROM php:8.0.28-cli-alpine3.16 AS php80

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 \
&& docker-php-ext-enable pcov

CMD tail -f /dev/null

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 \
&& docker-php-ext-enable pcov

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 \
&& docker-php-ext-enable pcov

CMD tail -f /dev/null
63 changes: 63 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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=74 make tests.run
PHP=80 make tests.run
PHP=81 make tests.run
PHP=82 make tests.run

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

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

stan:
PHP=74 make composer.update
docker exec 68publishers.amp-client-php.74 vendor/bin/phpstan analyse

coverage:
PHP=74 make composer.update
docker exec 68publishers.amp-client-php.74 vendor/bin/tester -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.amp-client-php.$(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.amp-client-php.$(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.amp-client-php.$(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.amp-client-php.$(PHP) vendor/bin/tester -C -s ./tests
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div align="center" style="text-align: center; margin-bottom: 50px">
<h1 align="center">AMP Client</h1>
</div>

## Installation

```sh
$ composer require 68publishers/amp-client
```
40 changes: 40 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "68publishers/amp-client",
"description": "",
"keywords": ["68publishers", "amp", "amp-client"],
"license": "proprietary",
"authors": [
{
"name": "Tomáš Glawaty",
"email": "[email protected]"
}
],
"require": {
"php": "^7.4 || ^8.0",
"ext-json": "*",
"guzzlehttp/guzzle": "^7.7"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.17",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.14",
"mockery/mockery": "^1.6",
"nette/tester": "^2.4",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-nette": "^1.2",
"roave/security-advisories": "dev-latest",
"symplify/phpstan-rules": "12.0.2.72"
},
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"SixtyEightPublishers\\AmpClient\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"SixtyEightPublishers\\AmpClient\\Tests\\": "tests/"
}
}
}
Loading

0 comments on commit 6aa0f64

Please sign in to comment.