Skip to content

Commit

Permalink
Added tests report to Codecov (#205)
Browse files Browse the repository at this point in the history
* Added Codecov
  • Loading branch information
shishir-intelli authored Sep 26, 2022
1 parent 4d2ed41 commit b8ebb13
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 32 deletions.
34 changes: 18 additions & 16 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
BROWSERTEST_OUTPUT_DIRECTORY: "sites/simpletest/browser_output"
BROWSERTEST_OUTPUT_BASE_URL: ""
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", { "chromeOptions": { "w3c": false } }, "http://127.0.0.1:9515/wd/hub"]'

on:
push:
pull_request_target:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
coverage: "xdebug"
php-version: "${{ matrix.php-version }}"
tools: composer:v2
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, gd, exif, iconv, opcache, imagick
Expand Down Expand Up @@ -104,36 +104,38 @@ jobs:
name: composer-${{ matrix.php-version }}-${{ matrix.drupal-core }}-artifact
path: drupal/composer.*

- name: "PHPUnit unit"
run: |
cd drupal
vendor/bin/phpunit -c core --verbose --color --group apigee_api_catalog --testsuite unit
- name: "PHPUnit kernel"
run: |
cd drupal
vendor/bin/phpunit -c core --verbose --color --group apigee_api_catalog --testsuite kernel
- uses: nanasess/setup-chromedriver@v1

- run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
- name: "PHPUnit functional javascript"
- name: "Run PHPUnit Tests"
if: ${{ matrix.drupal-core != '9.4.x' || matrix.php-version != '8.1' }}
run: |
cd drupal
vendor/bin/phpunit -c core --verbose --color --group apigee_api_catalog --testsuite functional-javascript
vendor/bin/phpunit -c core --verbose --color --group apigee_api_catalog --testsuite unit,kernel,functional,functional-javascript modules/contrib/apigee_api_catalog
- name: "PHPUnit functional"
- name: "Run PHPUnit Tests with Code Coverage"
if: ${{ matrix.drupal-core == '9.4.x' && matrix.php-version == '8.1' }}
run: |
cd drupal
vendor/bin/phpunit -c core --verbose --color --group apigee_api_catalog --testsuite functional
cp modules/contrib/apigee_api_catalog/phpunit.core.xml.dist core/phpunit.xml
vendor/bin/phpunit -c core --verbose --color --group apigee_api_catalog --testsuite unit,kernel,functional,functional-javascript --coverage-clover /tmp/coverage.xml modules/contrib/apigee_api_catalog
- name: Artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: browser-output-${{ matrix.php-version }}-${{ matrix.drupal-core }}-artifact
path: drupal/sites/simpletest/browser_output/*

- name: Upload Coverage to Codecov
if: ${{ matrix.drupal-core == '9.4.x' && matrix.php-version == '8.1' }}
uses: codecov/codecov-action@v3
with:
files: /tmp/coverage.xml
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
32 changes: 32 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "70...100"
status:
project: no
patch: no
changes: no
default_rules:
flag_coverage_not_uploaded_behavior: include

github_checks:
annotations: yes
parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach,diff,flags,tree"
behavior: default
require_changes: no
show_carryforward_flags: no

fixes:
- "drupal/modules/contrib/apigee_api_catalog::/"
22 changes: 6 additions & 16 deletions phpunit.core.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,13 @@
</listeners>
<!-- Filter for coverage reports. -->
<filter>
<whitelist>
<directory>./includes</directory>
<directory>./lib</directory>
<!-- Extensions can have their own test directories, so exclude those. -->
<directory>./modules</directory>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory>../modules/contrib/apigee_api_catalog</directory>
<!-- By definition test classes have no tests. -->
<exclude>
<directory>./modules/*/src/Tests</directory>
<directory>./modules/*/tests</directory>
<directory>../modules/contrib/apigee_api_catalog/tests</directory>
<directory>../modules/contrib/apigee_api_catalog/test_modules</directory>
</exclude>
<directory>../modules</directory>
<exclude>
<directory>../modules/*/src/Tests</directory>
<directory>../modules/*/tests</directory>
<directory>../modules/*/*/src/Tests</directory>
<directory>../modules/*/*/tests</directory>
</exclude>
<directory>../sites</directory>
</whitelist>
</whitelist>
</filter>
</phpunit>

0 comments on commit b8ebb13

Please sign in to comment.