Pārlūkot izejas kodu

:octocat: logging & coverage -> .build

codemasher 6 gadi atpakaļ
vecāks
revīzija
17cefd035f
4 mainītis faili ar 44 papildinājumiem un 21 dzēšanām
  1. 24 6
      .github/workflows/tests.yml
  2. 3 4
      .gitignore
  3. 9 8
      phpunit.xml
  4. 8 3
      tests/Output/QROutputTestAbstract.php

+ 24 - 6
.github/workflows/tests.yml

@@ -27,7 +27,6 @@ jobs:
 
 
         dependencies:
         dependencies:
           - lowest
           - lowest
-#          - locked
           - highest
           - highest
 
 
     steps:
     steps:
@@ -38,13 +37,32 @@ jobs:
         if: matrix.dependencies == 'lowest'
         if: matrix.dependencies == 'lowest'
         run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest --prefer-lowest
         run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest --prefer-lowest
 
 
-#      - name: "Install locked dependencies with composer"
-#        if: matrix.dependencies == 'locked'
-#        run: ${{ matrix.php-binary }} $(which composer) install --no-interaction --no-progress --no-suggest
-
       - name: "Install highest dependencies with composer"
       - name: "Install highest dependencies with composer"
         if: matrix.dependencies == 'highest'
         if: matrix.dependencies == 'highest'
         run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest
         run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest
 
 
       - name: "Run unit tests with phpunit"
       - name: "Run unit tests with phpunit"
-        run: ${{ matrix.php-binary }} vendor/bin/phpunit --configuration=phpunit.xml
+        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
 composer.lock
-*.phpunit.result.cache

+ 9 - 8
phpunit.xml

@@ -1,13 +1,9 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<phpunit backupGlobals="false"
-         backupStaticAttributes="false"
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+		 xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
          bootstrap="vendor/autoload.php"
          bootstrap="vendor/autoload.php"
+		 cacheResultFile=".build/phpunit.result.cache"
          colors="true"
          colors="true"
-         convertErrorsToExceptions="true"
-         convertNoticesToExceptions="true"
-         convertWarningsToExceptions="true"
-         processIsolation="false"
-         stopOnFailure="false"
+		 verbose="true"
         >
         >
     <filter>
     <filter>
         <whitelist processUncoveredFilesFromWhitelist="true">
         <whitelist processUncoveredFilesFromWhitelist="true">
@@ -19,4 +15,9 @@
             <directory suffix=".php">./tests/</directory>
             <directory suffix=".php">./tests/</directory>
         </testsuite>
         </testsuite>
     </testsuites>
     </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>
 </phpunit>

+ 8 - 3
tests/Output/QROutputTestAbstract.php

@@ -17,11 +17,11 @@ use chillerlan\QRCode\Data\Byte;
 use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
 use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
 use chillerlan\QRCodeTest\QRTestAbstract;
 use chillerlan\QRCodeTest\QRTestAbstract;
 
 
-/**
- */
+use function dirname, file_exists, mkdir;
+
 abstract class QROutputTestAbstract extends QRTestAbstract{
 abstract class QROutputTestAbstract extends QRTestAbstract{
 
 
-	const cachefile = __DIR__.'/output_test.';
+	const cachefile = __DIR__.'/../../.build/output_test/test.';
 
 
 	/**
 	/**
 	 * @var \chillerlan\QRCode\Output\QROutputInterface
 	 * @var \chillerlan\QRCode\Output\QROutputInterface
@@ -41,6 +41,11 @@ abstract class QROutputTestAbstract extends QRTestAbstract{
 	protected function setUp():void{
 	protected function setUp():void{
 		parent::setUp();
 		parent::setUp();
 
 
+		$buildDir = dirname($this::cachefile);
+		if(!file_exists($buildDir)){
+			mkdir($buildDir, 0777, true);
+		}
+
 		$this->options = new QROptions;
 		$this->options = new QROptions;
 		$this->setOutputInterface();
 		$this->setOutputInterface();
 	}
 	}