Skip to content

Commit

Permalink
Merged phpunit & sonar workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Aug 3, 2024
1 parent 4242f3a commit aa26cca
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 96 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/check-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ on:
phpunit:
description: "Count changed PhpUnit files"
value: ${{ jobs.check.outputs.phpunit }}
sonar:
description: "Count changed Sonar files"
value: ${{ jobs.check.outputs.sonar }}
# Allow manually triggering the workflow.
workflow_dispatch:

Expand All @@ -54,7 +51,6 @@ jobs:
phpstan: ${{ steps.changes-phpstan.outputs.phpstan }}
phpunit-test: ${{ steps.changes-phpunit-test.outputs.phpunit-test }}
phpunit: ${{ steps.changes-phpunit.outputs.phpunit }}
sonar: ${{ steps.changes-sonar.outputs.sonar }}

steps:
- name: Checkout code
Expand Down Expand Up @@ -172,11 +168,3 @@ jobs:
count="$(grep -oE "dev/phpunit*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHPUnit file(s) changed"
echo "phpunit=$count" >> $GITHUB_OUTPUT
- name: Check if Sonar files changed
id: changes-sonar
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "dev/sonar*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count Sonar file(s) changed"
echo "sonar=$count" >> $GITHUB_OUTPUT
26 changes: 26 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: pcov #optional, setup coverage driver
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v4

Expand Down Expand Up @@ -93,3 +96,26 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: output/*.xml

- name: prepare SonarCloud Scan Data
continue-on-error: true
if: ${{ matrix.php-versions == '8.1' }}
run: |
echo $PWD
ls -la
head ./dev/tests/clover.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' ./dev/tests/junit.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' ./dev/tests/clover.xml
head ./dev/tests/clover.xml
ls -la
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
continue-on-error: true
if: ${{ matrix.php-versions == '8.1' }} && SONAR_TOKEN
with:
args: >
-Dproject.settings=dev/sonar-project.properties
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
71 changes: 0 additions & 71 deletions .github/workflows/sonar.yml

This file was deleted.

14 changes: 1 addition & 13 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,11 @@ jobs:
if: needs.check.outputs.xml > 0
uses: ./.github/workflows/syntax-xml.yml

# DOES NOT run by default
# runs on schedule or when worklfow or unit tests changed
sonar:
name: Unit Tests (Sonar)
needs: [check, phpcs, php-cs-fixer]
if: |
needs.check.outputs.phpunit-test > 0 ||
needs.check.outputs.phpunit > 0 ||
needs.check.outputs.sonar > 0 ||
needs.check.outputs.workflow > 0
uses: ./.github/workflows/sonar.yml

# DOES NOT run by default
# runs on schedule or when worklfow or unit tests changed
unit_tests:
name: Unit Tests (OpenMage)
needs: [check, sonar]
needs: [check, phpcs, php-cs-fixer]
if: |
needs.check.outputs.phpunit-test > 0 ||
needs.check.outputs.phpunit > 0 ||
Expand Down

0 comments on commit aa26cca

Please sign in to comment.