From 9e3052ea8255b26dfd6b15f7a09d5ef827312931 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Fri, 8 Dec 2023 16:43:54 +0100 Subject: [PATCH] wip --- .../workflows/{php-cs-fixer.yml => pint.yml} | 8 ++--- .php_cs.dist.php | 35 ------------------- composer.json | 5 ++- phpunit.xml.dist | 17 ++++----- src/Conversions/ConversionCollection.php | 1 - tests/ArchTest.php | 5 +++ tests/Conversions/ImageGenerators/SvgTest.php | 2 +- tests/Pest.php | 10 ++++++ 8 files changed, 30 insertions(+), 53 deletions(-) rename .github/workflows/{php-cs-fixer.yml => pint.yml} (58%) delete mode 100644 .php_cs.dist.php create mode 100644 tests/ArchTest.php diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/pint.yml similarity index 58% rename from .github/workflows/php-cs-fixer.yml rename to .github/workflows/pint.yml index fbec801bb..975ad1728 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/pint.yml @@ -12,12 +12,10 @@ jobs: with: ref: ${{ github.head_ref }} - - name: Run PHP CS Fixer - uses: docker://oskarstark/php-cs-fixer-ga - with: - args: --config=.php_cs.dist.php --allow-risky=yes + - name: Fix styling issues + uses: aglipanci/laravel-pint-action@0.1.0 - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v5 + uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: Fix styling diff --git a/.php_cs.dist.php b/.php_cs.dist.php deleted file mode 100644 index ea229dfc5..000000000 --- a/.php_cs.dist.php +++ /dev/null @@ -1,35 +0,0 @@ -in([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->name('*.php') - ->notName('*.blade.php') - ->ignoreDotFiles(true) - ->ignoreVCS(true); - -return (new PhpCsFixer\Config()) - ->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, - 'method_argument_space' => [ - 'on_multiline' => 'ensure_fully_multiline', - 'keep_multiple_spaces_after_comma' => true, - ], - 'single_trait_insert_per_statement' => true, - ]) - ->setFinder($finder); diff --git a/composer.json b/composer.json index f26e3bb27..ba8e78003 100644 --- a/composer.json +++ b/composer.json @@ -48,11 +48,11 @@ "mockery/mockery": "^1.4", "nunomaduro/larastan": "^2.0", "orchestra/testbench": "^7.0|^8.0", - "pestphp/pest": "^1.21", + "pestphp/pest": "^2.0", "phpstan/extension-installer": "^1.1", "spatie/laravel-ray": "^1.28", "spatie/pdf-to-image": "^2.1", - "spatie/phpunit-snapshot-assertions": "^4.2" + "spatie/pest-plugin-snapshots": "^2.1" }, "conflict": { "php-ffmpeg/php-ffmpeg": "<0.6.1" @@ -91,7 +91,6 @@ "scripts": { "analyse": "vendor/bin/phpstan analyse", "baseline": "vendor/bin/phpstan analyse --generate-baseline", - "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes", "test": "vendor/bin/pest" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3663181f9..e9f469cff 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,16 +1,17 @@ - - - - src/ - - + + tests - + - + + + + src/ + + diff --git a/src/Conversions/ConversionCollection.php b/src/Conversions/ConversionCollection.php index 585092552..a2a89d12b 100644 --- a/src/Conversions/ConversionCollection.php +++ b/src/Conversions/ConversionCollection.php @@ -77,7 +77,6 @@ protected function addConversionsFromRelatedModel(Media $media): void protected function addManipulationsFromDb(Media $media): void { collect($media->manipulations)->each(function ($manipulation, $conversionName) { - ray($manipulation, $conversionName)->red(); $manipulations = new Manipulations($manipulation); $this->addManipulationToConversion($manipulations, $conversionName); diff --git a/tests/ArchTest.php b/tests/ArchTest.php new file mode 100644 index 000000000..fd6a1e4c3 --- /dev/null +++ b/tests/ArchTest.php @@ -0,0 +1,5 @@ +expect(['dd', 'dump', 'ray']) + ->not->toBeUsed(); diff --git a/tests/Conversions/ImageGenerators/SvgTest.php b/tests/Conversions/ImageGenerators/SvgTest.php index d825b30a7..660afb0d3 100644 --- a/tests/Conversions/ImageGenerators/SvgTest.php +++ b/tests/Conversions/ImageGenerators/SvgTest.php @@ -18,4 +18,4 @@ $imageFile = $imageGenerator->convert($media->getPath()); expect(mime_content_type($imageFile))->toEqual('image/jpeg'); -}); +})->skipWhenRunningLocally(); diff --git a/tests/Pest.php b/tests/Pest.php index 4a75f472f..ba2900c47 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -55,3 +55,13 @@ function unserializeAndSerializeModel($model) { return unserialize(serialize($model)); } + +function skipWhenRunningOnGitHub(): bool +{ + return getenv('GITHUB_ACTIONS') !== false; +} + +function skipWhenRunningLocally(): bool +{ + return getenv('GITHUB_ACTIONS') === false; +}