diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..e73d8395e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,68 @@ +# https://help.github.com/en/categories/automating-your-workflow-with-github-actions +# https://github.com/localheinz/php-library-template/blob/master/.github/workflows/continuous-integration.yml +# https://github.com/sebastianbergmann/phpunit/blob/master/.github/workflows/ci.yml + +on: + pull_request: + push: + branches: + - master + tags: + - "**" + +name: "Continuous Integration" + +jobs: + + tests: + name: "Unit Tests" + runs-on: ubuntu-latest + + strategy: + matrix: + php-binary: + - php7.2 + - php7.3 +# - php7.4 + + dependencies: + - lowest + - highest + + steps: + - name: "Checkout" + uses: actions/checkout@v1.1.0 + + - name: "Install lowest dependencies with composer" + if: matrix.dependencies == 'lowest' + run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest --prefer-lowest + + - name: "Install highest dependencies with composer" + if: matrix.dependencies == 'highest' + run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest + + - name: "Run unit tests with phpunit" + run: ${{ matrix.php-binary }} vendor/bin/phpunit --configuration=phpunit.xml --no-coverage + + + code-coverage: + name: "Code Coverage" + runs-on: ubuntu-latest + + steps: + - name: "Checkout" + uses: actions/checkout@v1.1.0 + + - name: "Install locked dependencies with composer" + run: php7.3 $(which composer) install --no-interaction --no-progress --no-suggest + + - name: "Dump Xdebug filter with phpunit/phpunit" + run: php7.3 vendor/bin/phpunit --configuration=phpunit.xml --dump-xdebug-filter=.build/phpunit/xdebug-filter.php + + - name: "Collect code coverage with Xdebug and phpunit/phpunit" + run: php7.3 vendor/bin/phpunit --configuration=phpunit.xml --prepend=.build/phpunit/xdebug-filter.php + + - name: "Send code coverage report to Codecov.io" + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: bash <(curl -s https://codecov.io/bash) diff --git a/.gitignore b/.gitignore index b7d3238f4..6361335f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ -vendor -.idea -tests/Output/output_test.* +.build/* +.idea/* +vendor/* composer.lock -*.phpunit.result.cache diff --git a/.travis.yml b/.travis.yml index 34a1bd0de..e54357109 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,12 @@ language: php matrix: include: - php: 7.4snapshot - - php: nightly + - php: 7.4 +# - php: nightly allow_failures: - php: 7.4snapshot - - php: nightly + - php: 7.4 # ext-gd missing https://travis-ci.community/t/add-php-7-4-branch-to-test-against/2179/16 +# - php: nightly before_install: - pecl channel-update pecl.php.net diff --git a/README.md b/README.md index ca1ba3e40..539d9d5e1 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ namespaced, cleaned up, improved and other stuff. [![Packagist downloads][downloads-badge]][downloads] [![PayPal donate][donate-badge]][donate] +[![Continuous Integration][gh-action-badge]][gh-action] + [packagist-badge]: https://img.shields.io/packagist/v/chillerlan/php-qrcode.svg?style=flat-square [packagist]: https://packagist.org/packages/chillerlan/php-qrcode [license-badge]: https://img.shields.io/github/license/chillerlan/php-qrcode.svg?style=flat-square @@ -25,6 +27,8 @@ namespaced, cleaned up, improved and other stuff. [downloads]: https://packagist.org/packages/chillerlan/php-qrcode/stats [donate-badge]: https://img.shields.io/badge/donate-paypal-ff33aa.svg?style=flat-square [donate]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WLYUNAT9ZTJZ4 +[gh-action-badge]: https://github.com/chillerlan/php-qrcode/workflows/Continuous%20Integration/badge.svg +[gh-action]: https://github.com/chillerlan/php-qrcode/actions Hi, please check out my other projects that are way cooler than qrcodes! diff --git a/composer.json b/composer.json index ff566bdbb..17bed0700 100644 --- a/composer.json +++ b/composer.json @@ -28,10 +28,10 @@ "ext-gd": "*", "ext-json": "*", "ext-mbstring": "*", - "chillerlan/php-settings-container": "^1.1" + "chillerlan/php-settings-container": "^1.2" }, "require-dev": { - "phpunit/phpunit": "^8.3" + "phpunit/phpunit": "^8.4" }, "suggest": { "chillerlan/php-authenticator": "Yet another Google authenticator! Also creates URIs for mobile apps." diff --git a/phpunit.xml b/phpunit.xml index 2a41c5d15..3a9b678d2 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,22 +1,23 @@ - - - - - ./src - - - - - ./tests/ - - + + + + ./src + + + + + ./tests/ + + + + + + + diff --git a/tests/Output/QROutputTestAbstract.php b/tests/Output/QROutputTestAbstract.php index 276a3613e..0bb9c9302 100644 --- a/tests/Output/QROutputTestAbstract.php +++ b/tests/Output/QROutputTestAbstract.php @@ -18,11 +18,11 @@ use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface}; use chillerlan\QRCodeTest\QRTestAbstract; use chillerlan\Settings\SettingsContainerInterface; -/** - */ +use function dirname, file_exists, mkdir; + abstract class QROutputTestAbstract extends QRTestAbstract{ - protected const cachefile = __DIR__.'/output_test.'; + protected const cachefile = __DIR__.'/../../.build/output_test/test.'; protected QROutputInterface $outputInterface; /** @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\QRCode\QROptions */ @@ -33,6 +33,11 @@ abstract class QROutputTestAbstract extends QRTestAbstract{ protected function setUp():void{ parent::setUp(); + $buildDir = dirname($this::cachefile); + if(!file_exists($buildDir)){ + mkdir($buildDir, 0777, true); + } + $this->options = new QROptions; $this->setOutputInterface(); }