From 13d020fd73cf35c595e351adeebe37bbc07822a8 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 26 Jan 2024 10:40:34 +0100 Subject: [PATCH 1/4] feat: migrate from travis to github --- .github/workflows/code_checks.yaml | 86 +++++++++++++++++++ .travis.yml | 24 ------ README.md | 4 +- .../RatioProvider/ECBRatioProviderTest.php | 2 +- composer.json | 5 +- phpunit.xml.dist | 4 +- tools/.gitignore | 2 - tools/composer.json | 5 -- 8 files changed, 93 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/code_checks.yaml delete mode 100644 .travis.yml delete mode 100644 tools/.gitignore delete mode 100644 tools/composer.json diff --git a/.github/workflows/code_checks.yaml b/.github/workflows/code_checks.yaml new file mode 100644 index 00000000..4c4d1d8e --- /dev/null +++ b/.github/workflows/code_checks.yaml @@ -0,0 +1,86 @@ +name: Code_Checks + +on: ["push", "pull_request"] + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.2'] + stability: [ prefer-stable ] + symfony-version: ['7.0.*'] + include: + - php: '8.0' + symfony-version: 5.4.* + stability: prefer-lowest + - php: '8.0' + symfony-version: 5.4.* + stability: prefer-stable + - php: '8.1' + symfony-version: 6.0.* + stability: prefer-stable + - php: '8.2' + symfony-version: 7.0.* + stability: prefer-stable + - php: '8.3' + symfony-version: 7.0.* + stability: prefer-stable + + name: PHP ${{ matrix.php }} - ${{ matrix.symfony-version }} - ${{ matrix.stability }} + steps: + # basically git clone + - uses: actions/checkout@v4 + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.composer/cache/files + key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + # use PHP of specific version + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: pcov, curl + coverage: pcov + + - name: Install dependencies + env: + SYMFONY_REQUIRE: ${{ matrix.symfony-version }} + run: | + composer global config --no-plugins allow-plugins.symfony/flex true + composer global require --no-progress --no-scripts --no-plugins symfony/flex + composer update --no-interaction --prefer-dist + vendor/bin/simple-phpunit install + + - name: Execute tests + env: + SYMFONY_DEPRECATIONS_HELPER: 'weak' + run: vendor/bin/phpunit --coverage-text + + + cs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + coverage: none + - run: | + composer install --no-progress + composer require friendsofphp/php-cs-fixer "^3.48" + vendor/bin/php-cs-fixer + + psalm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + coverage: none + - run: composer install --no-progress + - run: vendor/bin/psalm diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b2a835cb..00000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: php - -matrix: - include: - - php: 8.0 - env: 'HIGHEST_LOWEST="update"' - - php: 8.0 - env: 'HIGHEST_LOWEST="update --prefer-lowest"' - - php: 8.1 - env: 'HIGHEST_LOWEST="update"' - - php: 8.1 - env: 'HIGHEST_LOWEST="update --prefer-lowest"' - fast_finish: true - -before_script: - - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --working-dir=tools - -install: - - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer -n ${HIGHEST_LOWEST-install} --prefer-dist --no-interaction - -script: - - tools/vendor/bin/php-cs-fixer --dry-run --diff - - vendor/bin/psalm - - vendor/bin/phpunit --coverage-text diff --git a/README.md b/README.md index 27f4f93f..601d7ffc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ TbbcMoneyBundle =============== -[![Build Status](https://img.shields.io/travis/TheBigBrainsCompany/TbbcMoneyBundle/master.svg?style=flat-square)](https://travis-ci.org/TheBigBrainsCompany/TbbcMoneyBundle) +[![Build Status](https://github.com/TheBigBrainsCompany/TbbcMoneyBundle/actions/workflows/code_checks.yaml/badge.svg)](https://github.com/TheBigBrainsCompany/TbbcMoneyBundle/actions/workflows/code_checks.yaml) [![PHP](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg?style=flat-square)](https://php.net) [![Symfony](https://img.shields.io/badge/symfony-%5E4%7C%5E5-green.svg?style=flat-square)](https://symfony.com) [![Downloads](https://img.shields.io/packagist/dt/tbbc/money-bundle.svg?style=flat-square)](https://packagist.org/packages/tbbc/money-bundle/stats) @@ -15,7 +15,7 @@ a Symfony project. This library is based on Fowler's [Money pattern](http://blog.verraes.net/2011/04/fowler-money-pattern-in-php/) -* This bundle is tested and is stable with Symfony 3.4, 4.3, 4.4, 5.0, 6.0 +* This bundle is tested and is stable with Symfony 3.4, 4.3, 4.4, 5.0, 6.0, 7.0 Quick Start ----------- diff --git a/Tests/Pair/RatioProvider/ECBRatioProviderTest.php b/Tests/Pair/RatioProvider/ECBRatioProviderTest.php index a3aef032..4341886a 100644 --- a/Tests/Pair/RatioProvider/ECBRatioProviderTest.php +++ b/Tests/Pair/RatioProvider/ECBRatioProviderTest.php @@ -55,7 +55,7 @@ public function testNotCorrectReferenceCode(): void public function testUnknownCurrency(): void { $this->expectException(MoneyException::class); - $this->expectExceptionMessage('The currency code "" does not exists'); + $this->expectExceptionMessage('The currency code "" does not exist'); $this->ratio->fetchRatio('EUR', ''); } diff --git a/composer.json b/composer.json index 1b7544c2..5f1862e9 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "florianv/exchanger": "^2.0", "php-http/message": "^1.0", "php-http/guzzle6-adapter": "^2.0", - "vimeo/psalm": "^4.13", + "vimeo/psalm": "^4.13 | ^5.20", "symfony/phpunit-bridge": "^5.4|^6.0|^7.0", "phpunit/phpunit": "^9.5", "symfony/yaml": "^5.4|^6.0|^7.0", @@ -52,12 +52,11 @@ }, "autoload-dev": { "psr-4": { - "Tbbc\\MoneyBundle\\Tests\\": "tests" + "Tbbc\\MoneyBundle\\Tests\\": "Tests" } }, "scripts": { "fix": [ - "tools/vendor/bin/php-cs-fixer fix", "vendor/bin/psalm", "vendor/bin/phpunit --coverage-text --coverage-html=.build" ] diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7bda8476..0ae64f8e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ - @@ -10,7 +10,7 @@ - tests + Tests diff --git a/tools/.gitignore b/tools/.gitignore deleted file mode 100644 index 88e99d50..00000000 --- a/tools/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -vendor -composer.lock \ No newline at end of file diff --git a/tools/composer.json b/tools/composer.json deleted file mode 100644 index f0b7eda0..00000000 --- a/tools/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "friendsofphp/php-cs-fixer": "^3.4" - } -} From cd8f621f2fc6c71c5b9d75f04a7cc86f439a96d8 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 26 Jan 2024 11:16:01 +0100 Subject: [PATCH 2/4] feat: migrate from travis to github, allow phpunit 10 --- Tests/Form/Type/SimpleMoneyTypeTest.php | 2 +- ...tractRatioProviderTest.php => AbstractRatioProvider.php} | 2 +- .../RatioProvider/ExchangerAdapterRatioProviderTest.php | 2 +- Tests/Pair/RatioProvider/StaticRatioProviderTest.php | 2 +- Tests/Twig/Extension/CurrencyExtensionTest.php | 2 +- Tests/Twig/Extension/MoneyExtensionTest.php | 2 +- composer.json | 2 +- phpunit.xml.dist | 6 ++++-- 8 files changed, 11 insertions(+), 9 deletions(-) rename Tests/Pair/RatioProvider/{AbstractRatioProviderTest.php => AbstractRatioProvider.php} (97%) diff --git a/Tests/Form/Type/SimpleMoneyTypeTest.php b/Tests/Form/Type/SimpleMoneyTypeTest.php index 65689bad..1f1ed808 100644 --- a/Tests/Form/Type/SimpleMoneyTypeTest.php +++ b/Tests/Form/Type/SimpleMoneyTypeTest.php @@ -107,7 +107,7 @@ protected function getExtensions(): array $currencies = ['EUR', 'USD']; $referenceCurrency = 'EUR'; - if ('testBindValidDecimals' === $this->getName()) { + if ('testBindValidDecimals' === $this->name()) { $decimals = 3; } diff --git a/Tests/Pair/RatioProvider/AbstractRatioProviderTest.php b/Tests/Pair/RatioProvider/AbstractRatioProvider.php similarity index 97% rename from Tests/Pair/RatioProvider/AbstractRatioProviderTest.php rename to Tests/Pair/RatioProvider/AbstractRatioProvider.php index da967a84..673730df 100644 --- a/Tests/Pair/RatioProvider/AbstractRatioProviderTest.php +++ b/Tests/Pair/RatioProvider/AbstractRatioProvider.php @@ -13,7 +13,7 @@ * * @author Hugues Maignol */ -abstract class AbstractRatioProviderTest extends TestCase +abstract class AbstractRatioProvider extends TestCase { /** * The currently tested RatioProvider. diff --git a/Tests/Pair/RatioProvider/ExchangerAdapterRatioProviderTest.php b/Tests/Pair/RatioProvider/ExchangerAdapterRatioProviderTest.php index 0d83749d..9b0ebba2 100644 --- a/Tests/Pair/RatioProvider/ExchangerAdapterRatioProviderTest.php +++ b/Tests/Pair/RatioProvider/ExchangerAdapterRatioProviderTest.php @@ -11,7 +11,7 @@ use Tbbc\MoneyBundle\Pair\RatioProvider\ExchangerAdapterRatioProvider; use Tbbc\MoneyBundle\Pair\RatioProviderInterface; -class ExchangerAdapterRatioProviderTest extends AbstractRatioProviderTest +class ExchangerAdapterRatioProviderTest extends AbstractRatioProvider { protected function getRatioProvider(): RatioProviderInterface { diff --git a/Tests/Pair/RatioProvider/StaticRatioProviderTest.php b/Tests/Pair/RatioProvider/StaticRatioProviderTest.php index cf5acdf7..ead65bb6 100644 --- a/Tests/Pair/RatioProvider/StaticRatioProviderTest.php +++ b/Tests/Pair/RatioProvider/StaticRatioProviderTest.php @@ -7,7 +7,7 @@ use Tbbc\MoneyBundle\Pair\RatioProvider\StaticRatioProvider; use Tbbc\MoneyBundle\Pair\RatioProviderInterface; -class StaticRatioProviderTest extends AbstractRatioProviderTest +class StaticRatioProviderTest extends AbstractRatioProvider { protected function getRatioProvider(): RatioProviderInterface { diff --git a/Tests/Twig/Extension/CurrencyExtensionTest.php b/Tests/Twig/Extension/CurrencyExtensionTest.php index 33f8da1c..3e0b00f6 100644 --- a/Tests/Twig/Extension/CurrencyExtensionTest.php +++ b/Tests/Twig/Extension/CurrencyExtensionTest.php @@ -38,7 +38,7 @@ public function testCurrency($template, $expected): void $this->assertSame($expected, $this->getTemplate($template)->render($this->variables)); } - public function getCurrencyTests(): array + public static function getCurrencyTests(): array { return [ ['{{ currency|currency_name }}', 'EUR'], diff --git a/Tests/Twig/Extension/MoneyExtensionTest.php b/Tests/Twig/Extension/MoneyExtensionTest.php index 0a9d2094..30fc68af 100644 --- a/Tests/Twig/Extension/MoneyExtensionTest.php +++ b/Tests/Twig/Extension/MoneyExtensionTest.php @@ -60,7 +60,7 @@ public function testMoney($template, $expected): void $this->assertSame($expected, $this->getTemplate($template)->render($this->variables)); } - public function getMoneyTests(): array + public static function getMoneyTests(): array { return [ ['{{ price|money_localized_format }}', "1\u{202f}234\u{202f}567,89\u{a0}€"], diff --git a/composer.json b/composer.json index 5f1862e9..ad1ea7ed 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "php-http/guzzle6-adapter": "^2.0", "vimeo/psalm": "^4.13 | ^5.20", "symfony/phpunit-bridge": "^5.4|^6.0|^7.0", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^9.6|^10.5", "symfony/yaml": "^5.4|^6.0|^7.0", "http-interop/http-factory-guzzle": "^1.2" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0ae64f8e..aebb4556 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,8 @@ - + From ceed16fd0ac0c6a754aa33b4f64a05390de685a4 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 26 Jan 2024 11:19:18 +0100 Subject: [PATCH 3/4] feat: migrate from travis to github, allow phpunit 10 --- Tests/Form/Type/SimpleMoneyTypeTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Tests/Form/Type/SimpleMoneyTypeTest.php b/Tests/Form/Type/SimpleMoneyTypeTest.php index 1f1ed808..bfd0097a 100644 --- a/Tests/Form/Type/SimpleMoneyTypeTest.php +++ b/Tests/Form/Type/SimpleMoneyTypeTest.php @@ -107,7 +107,13 @@ protected function getExtensions(): array $currencies = ['EUR', 'USD']; $referenceCurrency = 'EUR'; - if ('testBindValidDecimals' === $this->name()) { + # PHPUnit 10 + if (method_exists($this, 'name') && 'testBindValidDecimals' === $this->name()) { + $decimals = 3; + } + + # PHPUnit 9 + if (method_exists($this, 'getName') && 'testBindValidDecimals' === $this->getName()) { $decimals = 3; } From d192d6ee79cb568d57dedb2173f0e52baf020e2b Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 26 Jan 2024 11:21:37 +0100 Subject: [PATCH 4/4] feat: migrate from travis to github, allow phpunit 10 --- .github/workflows/code_checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_checks.yaml b/.github/workflows/code_checks.yaml index 4c4d1d8e..b7bfc793 100644 --- a/.github/workflows/code_checks.yaml +++ b/.github/workflows/code_checks.yaml @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v4 - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.composer/cache/files key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}