.github/workflows/sonar.yml #2429
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sonar | |
on: | |
# Run automatically every Monday on midnight. | |
schedule: | |
- cron: '0 0 * * 1' | |
workflow_call: | |
# Allow manually triggering the workflow. | |
workflow_dispatch: | |
jobs: | |
unit: | |
name: Unit Tests on ${{ matrix.php }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
max-parallel: 5 | |
matrix: | |
os: [ubuntu-latest] | |
php: ['7.4', '8.1'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: mbstring | |
tools: composer, pecl, phpcs, phpstan, phpunit:9.5 | |
ini-values: pcov.directory=api, post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration | |
coverage: pcov #optional, setup coverage driver | |
env: | |
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Install dependencies | |
run: composer install --dev -n --prefer-source --ignore-platform-req=php+ | |
- name: Run Unit Tests | |
run: phpunit --configuration ./dev/phpunit.xml.dist --testsuite=Unit; | |
- name: prepare SonarCloud Scan Data | |
continue-on-error: true | |
if: ${{ matrix.php == '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 == '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 }} |