Browse Source

minor #5329 DX: collect coverage with Github Actions (kubawerlos)

This PR was merged into the 2.17 branch.

Discussion
----------

DX: collect coverage with Github Actions

Commits
-------

12313e863 DX: collect coverage with Github Actions
Dariusz Ruminski 4 years ago
parent
commit
1250a10bd4
3 changed files with 22 additions and 30 deletions
  1. 21 2
      .github/workflows/ci.yml
  2. 0 27
      .travis.yml
  3. 1 1
      composer.json

+ 21 - 2
.github/workflows/ci.yml

@@ -34,6 +34,12 @@ jobs:
             PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER: 1
             SYMFONY_DEPRECATIONS_HELPER: 'disabled'
 
+          - operating-system: 'ubuntu-20.04'
+            php-version: '7.4'
+            job-description: 'with calculating code coverage'
+            calculate-code-coverage: 'yes'
+            phpunit-flags: '--testsuite coverage --exclude-group covers-nothing --coverage-clover build/logs/clover.xml'
+
           - operating-system: 'ubuntu-20.04'
             php-version: '7.4'
             job-description: 'with migration rules'
@@ -61,11 +67,18 @@ jobs:
       - name: Checkout code
         uses: actions/checkout@v2
 
+      - name: Get code coverage driver
+        uses: actions/github-script@v3.1
+        id: code-coverage-driver
+        with:
+          script: 'return "${{ matrix.calculate-code-coverage }}" == "yes" ? "pcov" : "none"'
+          result-encoding: string
+
       - name: Setup PHP
         uses: shivammathur/setup-php@v2
         with:
           php-version: ${{ matrix.php-version }}
-          coverage: none
+          coverage: ${{ steps.code-coverage-driver.outputs.result }}
           tools: flex
         env:
           fail-fast: false # disabled as old PHP version cannot run flex
@@ -110,7 +123,13 @@ jobs:
           FAST_LINT_TEST_CASES: ${{ matrix.FAST_LINT_TEST_CASES }}
           PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER: ${{ matrix.PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER }}
           SYMFONY_DEPRECATIONS_HELPER: ${{ matrix.SYMFONY_DEPRECATIONS_HELPER }}
-        run: vendor/bin/phpunit
+        run: vendor/bin/phpunit ${{ matrix.phpunit-flags }}
+
+      - name: Upload coverage results to Coveralls
+        if: matrix.calculate-code-coverage == 'yes'
+        env:
+          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: php vendor/bin/php-coveralls --verbose
 
       - name: Run PHP CS Fixer
         env:

+ 0 - 27
.travis.yml

@@ -22,33 +22,6 @@ before_install:
 
 jobs:
     include:
-        -
-            stage: Test
-            php: 7.4
-            name: 7.4 | Collect coverage
-            before_install:
-                # for building a tag release we don't need to collect code coverage
-                - if [ $TRAVIS_TAG ]; then travis_terminate 0; fi
-
-                ## regular `before_install`
-                # turn off XDebug
-                - phpenv config-rm xdebug.ini || return 0
-
-                # Require PHPUnit 8
-                - composer require --dev --no-update phpunit/phpunit:^8
-
-                # Install PCOV
-                - pecl install pcov
-            install:
-                - travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
-                - composer info -D | sort
-            before_script:
-                # Make code compatible with PHPUnit 8
-                - PHP_CS_FIXER_FUTURE_MODE=1 php php-cs-fixer fix --rules=void_return -q tests || return 0
-            script:
-                - vendor/bin/phpunit --testsuite coverage --exclude-group covers-nothing --coverage-clover build/logs/clover.xml || travis_terminate 1
-                - php vendor/bin/php-coveralls -v
-
         -
             stage: Deployment
             php: 7.4

+ 1 - 1
composer.json

@@ -36,7 +36,7 @@
         "justinrainbow/json-schema": "^5.0",
         "keradus/cli-executor": "^1.4",
         "mikey179/vfsstream": "^1.6",
-        "php-coveralls/php-coveralls": "^2.4.1",
+        "php-coveralls/php-coveralls": "^2.4.2",
         "php-cs-fixer/accessible-object": "^1.0",
         "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2",
         "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1",