From 9593620ac92970f9aa5b4bf72ed275ab430288b1 Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Sun, 17 Sep 2023 11:53:31 +0200 Subject: [PATCH] ci: replace Codecov with SonarCloud scan Synchronize our projects and move AntiVirus to SonarCloud, too. Use a dedicated CI step here to process code coverage. --- .distignore | 5 +++-- .gitattributes | 1 + .github/workflows/test.yml | 16 ++++++++++++---- .gitignore | 2 +- composer.json | 2 +- phpunit.xml | 7 +++++++ sonar-project.properties | 9 +++++++++ 7 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 sonar-project.properties diff --git a/.distignore b/.distignore index ed8d3b5..b54c04c 100644 --- a/.distignore +++ b/.distignore @@ -15,11 +15,12 @@ /.gitignore /.stylelintrc.json /.travis.yml -/clover.xml /composer.json /package.json /package-lock.json /composer.lock /phpcs.xml /phpunit.xml - +/sonar-project.properties +/tests-clover.xml +/tests-junit.xml diff --git a/.gitattributes b/.gitattributes index cb1170f..36c7b35 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,3 +18,4 @@ /package-lock.json export-ignore /phpcs.xml export-ignore /phpunit.xml export-ignore +/sonar-project.properties export-ignore diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c2fbf9b..5a48cfb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ name: Test -on: push +on: [ push, pull_request ] jobs: unit: runs-on: ubuntu-latest @@ -9,6 +9,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -17,10 +19,16 @@ jobs: - name: Install run: composer install --no-interaction - name: Unit tests - run: composer test - - name: Coverage Report + run: | + composer test + sed -i 's#'$GITHUB_WORKSPACE'#/github/workspace#g' tests-*.xml + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master if: matrix.php == '8.1' - uses: codecov/codecov-action@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + quality: runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index e67662c..c9fe77b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ js/*.min.js vendor/ node_modules/ .phpunit.result.cache -clover.xml +tests-*.xml diff --git a/composer.json b/composer.json index b55d501..8abb73c 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "minifyjs js/script.js > js/script.min.js" ], "test": [ - "phpunit --coverage-clover clover.xml" + "phpunit" ] }, "config": { diff --git a/phpunit.xml b/phpunit.xml index 1dd1854..81babc8 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -13,8 +13,15 @@ ./antivirus.php ./inc/ + + + + + + + tests/ diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..709cb28 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,9 @@ +sonar.organization=pluginkollektiv +sonar.projectKey=pluginkollektiv_antivirus + +sonar.sources=inc,js,css,antivirus.php + +sonar.tests=tests + +sonar.php.tests.reportPath=tests-junit.xml +sonar.php.coverage.reportPaths=tests-clover.xml