Selaa lähdekoodia

Merge branch 'master' into php-7.4

# Conflicts:
#	tests/Output/QROutputTestAbstract.php
codemasher 6 vuotta sitten
vanhempi
commit
2998b05cf6
7 muutettua tiedostoa jossa 111 lisäystä ja 32 poistoa
  1. 68 0
      .github/workflows/tests.yml
  2. 3 4
      .gitignore
  3. 4 2
      .travis.yml
  4. 4 0
      README.md
  5. 2 2
      composer.json
  6. 22 21
      phpunit.xml
  7. 8 3
      tests/Output/QROutputTestAbstract.php

+ 68 - 0
.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)

+ 3 - 4
.gitignore

@@ -1,5 +1,4 @@
-vendor
-.idea
-tests/Output/output_test.*
+.build/*
+.idea/*
+vendor/*
 composer.lock
-*.phpunit.result.cache

+ 4 - 2
.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

+ 4 - 0
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!
 

+ 2 - 2
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."

+ 22 - 21
phpunit.xml

@@ -1,22 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<phpunit backupGlobals="false"
-         backupStaticAttributes="false"
-         bootstrap="vendor/autoload.php"
-         colors="true"
-         convertErrorsToExceptions="true"
-         convertNoticesToExceptions="true"
-         convertWarningsToExceptions="true"
-         processIsolation="false"
-         stopOnFailure="false"
-        >
-    <filter>
-        <whitelist processUncoveredFilesFromWhitelist="true">
-            <directory suffix=".php">./src</directory>
-        </whitelist>
-    </filter>
-    <testsuites>
-        <testsuite name="php-qrcode test suite">
-            <directory suffix=".php">./tests/</directory>
-        </testsuite>
-    </testsuites>
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+		 xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
+		 bootstrap="vendor/autoload.php"
+		 cacheResultFile=".build/phpunit.result.cache"
+		 colors="true"
+		 verbose="true"
+>
+	<filter>
+		<whitelist processUncoveredFilesFromWhitelist="true">
+			<directory suffix=".php">./src</directory>
+		</whitelist>
+	</filter>
+	<testsuites>
+		<testsuite name="php-qrcode test suite">
+			<directory suffix=".php">./tests/</directory>
+		</testsuite>
+	</testsuites>
+	<logging>
+		<log type="coverage-clover" target=".build/coverage/clover.xml"/>
+		<log type="coverage-xml" target=".build/coverage/coverage-xml"/>
+		<log type="junit" target=".build/logs/junit.xml"/>
+	</logging>
 </phpunit>

+ 8 - 3
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();
 	}