Skip to content

Updated workflow configuration #3

Updated workflow configuration

Updated workflow configuration #3

Workflow file for this run

name: tests
on: [ push, pull_request ]
jobs:
tests:
strategy:
matrix:
php-versions: [ '8.2', '8.3' ]
runs-on: ubuntu-latest
name: Test on PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: pdo_mysql
coverage: xdebug
- 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 --no-progress --no-interaction
- name: Start MySQL
run: sudo /etc/init.d/mysql start
- name: Test
if: matrix.php-versions != '8.2'
run: composer test
continue-on-error: true
- name: Test with Coverage
if: matrix.php-versions == '8.2'
working-directory: ./
run: |
composer test-coverage
sed -i 's/\/home\/runner\/work\/session\/session\//\/github\/workspace\//g' report.xml
sed -i 's/\/home\/runner\/work\/session\/session\//\/github\/workspace\//g' clover.xml
- name: Scan code with SonarCloud
if: matrix.php-versions == '8.2'
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.organization=mobicms
-Dsonar.projectName=session
-Dsonar.projectKey=mobicms_session
-Dsonar.sources=./src
-Dsonar.tests=./tests
-Dsonar.sourceEncoding=UTF-8
-Dsonar.php.tests.reportPath=report.xml
-Dsonar.php.coverage.reportPaths=clover.xml
- name: Test with latest dependencies
if: matrix.php-versions == '8.2'
run: |
composer update
composer test