Skip to content

Commit

Permalink
Update sonar-project.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
videshpande06 authored Jan 25, 2024
1 parent 00d4221 commit 7050cc8
Showing 1 changed file with 12 additions and 125 deletions.
137 changes: 12 additions & 125 deletions .github/workflows/sonar-project.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: CI
name: SonarQube Analysis

on:
push:
branches:
- DE-55463-SonarQubeIntegration
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

jobs:
phpstan:
name: CI PHPStan
sonarqube:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
strategy:
fail-fast: false
matrix:
php-version:
- 7.4
- 8.1

steps:
- name: Checkout
Expand All @@ -28,63 +28,13 @@ jobs:
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, sockets

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: |
composer config github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }}
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run phpstan
run: composer phpstan

ecs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version:
- 7.4
- 8.1

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, sockets

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist

- name: Run code-sniffer
run: composer check-cs
- name: Run phpstan
run: composer phpstan

phpunit:
name: CI PHPUnit
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -94,52 +44,6 @@ jobs:
- "update --prefer-lowest"
php-version:
- 7.4
- 8.1
# Covered by phpunit-with-sonar
exclude:
- php-version: 7.4
composer-arg: "install"

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, sockets

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: |
composer config github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }}
composer ${{ matrix.composer-arg }} --no-progress --prefer-dist --optimize-autoloader
- name: Run phpunit
run: composer phpunit

phpunit-with-sonar:
name: CI PHPUnit + Sonar Cube
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
composer-arg:
- "install"
php-version:
- 7.4

steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -149,29 +53,12 @@ jobs:
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, sockets
coverage: xdebug

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: |
composer config github-oauth.github.com ${{ secrets.COMPOSER_TOKEN }}
composer ${{ matrix.composer-arg }} --no-progress --prefer-dist --optimize-autoloader
- name: Run phpunit
run: composer phpunit-cc

- uses: sonarsource/sonarqube-scan-action@master
run: composer ${{ matrix.composer-arg }} --prefer-dist
- name: Run tests with phpunit/phpunit
run: vendor/bin/phpunit --coverage-clover=coverage.xml
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: "https://sonar.nice.com"
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 comments on commit 7050cc8

Please sign in to comment.