Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisdeBest committed Aug 5, 2023
2 parents 8c64047 + b00e461 commit fd3a42b
Show file tree
Hide file tree
Showing 24 changed files with 401 additions and 363 deletions.
29 changes: 29 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
* text=auto

/.docker export-ignore
/config.subsplit-publish.json export-ignore
/.editorconfig export-ignore
/.php-cs-fixer.dist.php export-ignore
/phpstan.neon export-ignore
/phpunit.php export-ignore
/phpunit.xml.dist export-ignore
/.travis.yml export-ignore
/.scrutinizer.yml export-ignore
/CHANGELOG.md export-ignore
/CODE_OF_CONDUCT.md export-ignore
/deprecations.md export-ignore
/docker-composer.yml export-ignore
/README.md export-ignore
/CODE_OF_CONDUCT.md export-ignore
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/bin/ export-ignore
/mocked-functions.php export-ignore
/test_files/ export-ignore
/Tests export-ignore
/**/*Test.php export-ignore
/**/*Stub.php export-ignore
/**/Stub*.php export-ignore
Dockerfile export-ignore
Docker-compose.yaml export-ignore
51 changes: 51 additions & 0 deletions .github/workflows/badge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Coverage-badge

on:
push:
tags:
- '*.*.*'
jobs:
test:
runs-on: ubuntu-latest
name: Generate Coverage Badge
steps:
- uses: actions/checkout@v3

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- name: composer
uses: php-actions/composer@v6
with:
php_version: 8.2
php_extensions: xdebug gd

- name: PHPUnit Tests
uses: php-actions/phpunit@v3
with:
version: 10.2
php_version: 8.2
php_extensions: xdebug gd
bootstrap: vendor/autoload.php
configuration: phpunit.xml.dist
args: --coverage-clover coverage.xml
env:
XDEBUG_MODE: coverage


- name: Generate PHPUnit coverage badge
uses: timkrase/phpunit-coverage-badge@v1.2.0
with:
report: 'coverage.xml'
coverage_badge_path: 'plugin/.coverage/badge.svg'

- name: Commit PHPUnit coverage badge
uses: EndBug/add-and-commit@v9
with:
add: 'badge.svg'
cwd: './plugin/.coverage'
message: 'Update PHPUnit coverage badge'
new_branch: develop
42 changes: 42 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI-coverage

on:
push:
tags:
- '*.*.*'
jobs:
test:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.1', '8.2' ]
php-unit-versions: [ '9.5', '10.2' ]
symfony-versions: [ '6.1', '6.3' ]
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} - PHPUnit ${{ matrix.php-unit-versions }}
steps:
- uses: actions/checkout@v3

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ matrix.symfony-versions }}-${{ hashFiles('**/composer.lock') }}

- name: Install Symfony
run: composer require symfony/framework-bundle:${{ matrix.symfony-versions }}

- name: composer
uses: php-actions/composer@v6
with:
php_version: ${{ matrix.php-versions }}
php_extensions: xdebug gd

- name: PHPUnit Tests
uses: php-actions/phpunit@v3
with:
version: ${{ matrix.php-unit-versions }}
php_version: ${{ matrix.php-versions }}
php_extensions: xdebug gd
bootstrap: vendor/autoload.php
configuration: phpunit.xml.dist
51 changes: 0 additions & 51 deletions .github/workflows/ci.yml

This file was deleted.

1 change: 1 addition & 0 deletions .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"8.2.5","version":"3.15.0","indent":" ","lineEnding":"\n","rules":{"full_opening_tag":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"array_syntax":{"syntax":"short"},"class_attributes_separation":{"elements":{"method":"one","property":"one","trait_import":"one"}}},"hashes":{"src\/Twig\/WebPConversionExtension.php":"5b27e61c20b71ac1ad4b51d03be8578a","src\/WebPConversionBundle.php":"f67051d8b195c82d4053058e4c2ed2c0","src\/DependencyInjection\/Configuration.php":"d2a31e6b9d27855c295f7acc4222aa43","src\/DependencyInjection\/WebPConversionExtension.php":"7026ed23d01d3d9f8e64251d80954d09","src\/Tests\/Test.php":"020eade5bff4c08cd65bf135da69d404","src\/Tests\/TestKernel.php":"7c0a0bd721e3594b5b8987ede896d03f","src\/Traits\/ConvertibleImageTrait.php":"eb95b8c03eb94f3b1d1bfaea1712169b","src\/Model\/Image.php":"8068c3e54387784f49d4eaab77ce4a13","src\/Model\/WebPInformation.php":"8b9bb970c727d110a83abbac28c23345","src\/WebPConversion.php":"02ca14bcda5814580195cf9e5492d222","src\/Service\/ImageConverter.php":"fd779fc8ad26ba859e184c8bd45d11a7","src\/Service\/ImageUploadHelper.php":"34cd835d0b0f9133d6d304b058d6f695","src\/Command\/WebPConversionCommand.php":"c317b3d7d47d8504237d5a7d4a5d9de6"}}
16 changes: 16 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

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

$config = new PhpCsFixer\Config();
return $config->setRules([
'full_opening_tag' => false,
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'yoda_style' => false,
'class_attributes_separation' => [
'elements' => ['method' => 'one', 'property' => 'one', 'trait_import' => 'one']
]
])
->setFinder($finder);
14 changes: 0 additions & 14 deletions .run/runConfigurations/Test.run.xml

This file was deleted.

42 changes: 30 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,46 @@
}
],
"require": {
"php": "^8.0",
"codebuds/webp-converter": "^0.5.1",
"symfony/console": "^5.0 || ^6.0",
"symfony/stopwatch": "^5.0 || ^6.0",
"symfony/finder": "^5.0 || ^6.0",
"symfony/http-foundation": "^5.0 || ^6.0",
"symfony/routing": "^5.0 || ^6.0",
"doctrine/annotations": "^1.13",
"symfony/mime": "^5.0 || ^6.0",
"symfony/validator": "^5.0 || ^6.0",
"php": "^8.1",
"codebuds/webp-converter": "dev-develop",
"symfony/console": "^6.1",
"symfony/stopwatch": "^6.1",
"symfony/finder": "^6.1",
"symfony/http-foundation": "^6.1",
"symfony/routing": "^6.1",
"doctrine/annotations": "^2.0",
"symfony/mime": "^6.1",
"symfony/validator": "^6.1",
"symfony/orm-pack": "^2.1",
"twig/twig": "^2.0 || ^3.0",
"ext-fileinfo": "*"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"symfony/framework-bundle": "^5.0 || ^6.0",
"symfony/phpunit-bridge": "^5.0 || ^6.0"
"symfony/framework-bundle": "^6.1",
"rector/rector": "^0.15.21",
"symfony/phpunit-bridge": "^6.1"
},
"autoload": {
"psr-4": {
"CodeBuds\\WebPConversionBundle\\": "src/"
}
},
"scripts": {
"cs-fix": [
"php-cs-fixer fix --config=.php-cs-fixer.dist.php"
],
"rector": [
"./vendor/bin/rector"
],
"clean": [
"composer rector && composer cs-fix"
],
"test": [
"php -dxdebug.mode=debug ./vendor/bin/simple-phpunit --configuration ./phpunit.xml.dist "
],
"coverage": [
"export XDEBUG_MODE=coverage && php ./vendor/bin/simple-phpunit --configuration ./phpunit.xml.dist --coverage-text"
]
}
}
39 changes: 39 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
services:
# Command
CodeBuds\WebPConversionBundle\Command\WebPConversionCommand:
public: true
arguments:
- '%webp_conversion.quality%'
- '%kernel.project_dir%'
tags:
- { name: 'console.command', command: 'codebuds:webp:convert', alias: 'webp:conv' }

# Twig Extension
CodeBuds\WebPConversionBundle\Twig\WebPConversionExtension:
public: true
arguments:
- '%webp_conversion.quality%'
- '%kernel.project_dir%'
tags:
- { name: 'twig.extension', alias: 'codebuds' }

# Bundle Extension
CodeBuds\WebPConversionBundle\WebPConversion:
public: true
arguments:
- '%webp_conversion.quality%'
- 'CodeBuds\WebPConversionBundle\Service\ImageConverter'

# Services
CodeBuds\WebPConversionBundle\Service\ImageConverter:
public: true

CodeBuds\WebPConversionBundle\Service\ImageUploadHelper:
public: true
arguments:
- '%webp_conversion.upload_path%'
- '%kernel.project_dir%'

# Traits
CodeBuds\WebPConversionBundle\Traits\ConvertibleImageTrait:
public: true
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>src/Tests</directory>
</exclude>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
Expand Down
21 changes: 21 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Symfony\Set\SymfonySetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
SymfonySetList::SYMFONY_61,
LevelSetList::UP_TO_PHP_81,
]);
};
9 changes: 6 additions & 3 deletions src/Command/WebPConversionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use CodeBuds\WebPConverter\WebPConverter;
use Exception;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -15,17 +16,19 @@
use Symfony\Component\Mime\FileinfoMimeTypeGuesser;
use Symfony\Component\Stopwatch\Stopwatch;

#[AsCommand('codebuds:webp:convert')]
class WebPConversionCommand extends Command
{
protected static $defaultName = 'codebuds:webp:convert';

protected const CONVERTABLE_MIME_TYPES = [
'image/jpeg',
'image/png',
'image/gif',
];

public function __construct(private int $quality, private string $projectDir)
public function __construct(
private readonly int $quality,
private readonly string $projectDir,
)
{
parent::__construct();
}
Expand Down
23 changes: 0 additions & 23 deletions src/DependencyInjection/Configuration.php

This file was deleted.

Loading

0 comments on commit fd3a42b

Please sign in to comment.