Skip to content

Commit

Permalink
ci: fix coverage (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Oct 10, 2023
1 parent 1d1f417 commit 7155106
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ on:
workflow_dispatch:

env:
default-php-version: '8.1'
default-laravel-version: '9.*'
semantic-node-version: 16
default-php-version: '8.2'
default-laravel-version: '10.*'
semantic-node-version: 18

jobs:
tests:
Expand Down Expand Up @@ -56,6 +56,7 @@ jobs:
php-version: ${{ matrix.php-version }}
coverage: pcov
extensions: sqlite3, gmp
ini-values: pcov.directory=., pcov.exclude="~vendor~"
- name: Check PHP Version
run: php -v
- name: Check Composer Version
Expand Down Expand Up @@ -114,9 +115,10 @@ jobs:
- name: Fix results files
run: sed -i -e "s%$GITHUB_WORKSPACE/%%g" *.xml
working-directory: results
if: success() || failure()

- name: Store results
if: matrix.php-version == env.default-php-version && matrix.laravel-version == env.default-laravel-version
if: matrix.php-version == env.default-php-version && matrix.laravel-version == env.default-laravel-version && (success() || failure())
uses: actions/upload-artifact@v3
with:
name: results
Expand All @@ -129,9 +131,7 @@ jobs:
reporting:
needs: tests
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2']
if: success() || failure()

steps:
- name: Checkout repository
Expand All @@ -145,6 +145,12 @@ jobs:
name: results
path: results

- name: Merge junit files
run: |
npm init -y
yarn set version berry
yarn dlx junit-report-merger ./results/results.xml "./results/results*.xml"
- name: Set coverage list
id: coverage
run: |
Expand All @@ -159,7 +165,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: |
-Dsonar.php.tests.reportPath=./results/results_guzzle.xml
-Dsonar.php.tests.reportPath=./results/results.xml
-Dsonar.php.coverage.reportPaths=${{ steps.coverage.outputs.list }}
Expand Down
10 changes: 7 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="true" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage/>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="LaravelSabre Tests Suite">
<testsuite name="Tests Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage/>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="base64:uA/XEme0vpegJz/rKSk3ys2uzEfXZA0Ca2P0e1M8vRU="/>
Expand Down
7 changes: 2 additions & 5 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ sonar.organization=asbiin-github

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=src
#sonar.exclusions=
sonar.sources=src,config,database,routes
sonar.coverage.exclusions=config/*.php,database/**/*.php,routes/*.php
sonar.tests=tests

# Encoding of the source code. Default is default system encoding
Expand All @@ -17,6 +17,3 @@ sonar.sourceEncoding=UTF-8
sonar.links.ci=https://github.com/asbiin/laravel-webauthn/actions
sonar.links.scm=https://github.com/asbiin/laravel-webauthn
sonar.links.issue=https://github.com/asbiin/laravel-webauthn/issues

sonar.php.tests.reportPath=./results/results.xml
sonar.php.coverage.reportPaths=./results/coverage.xml

0 comments on commit 7155106

Please sign in to comment.