on:
  push:
    branches:
      - master
  pull_request:
      types: [opened, synchronize, reopened]
name: Sonar
jobs:
  sonarcloud:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        # Disabling shallow clone is recommended for improving relevancy of reporting
        fetch-depth: 0
    - name: Setup node
      uses: actions/setup-node@v3
      with:
        node-version: 18
        cache: 'npm'
    - run: npm install
    - run : npm run test:coverage
    - name: SonarCloud Scan
      uses: sonarsource/sonarcloud-github-action@master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
