diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 6673f3f00..52585bed1 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -36,68 +36,68 @@ jobs: name: csproj path: Kavita.Common/Kavita.Common.csproj -# test: -# name: Install Sonar & Test -# needs: build -# runs-on: windows-latest -# steps: -# - name: Checkout Repo -# uses: actions/checkout@v2 -# with: -# fetch-depth: 0 -# -# - name: Setup .NET Core -# uses: actions/setup-dotnet@v1 -# with: -# include-prerelease: True -# dotnet-version: '6.0' -# -# - name: Install dependencies -# run: dotnet restore -# -# - name: Set up JDK 11 -# uses: actions/setup-java@v1 -# with: -# java-version: 1.11 -# -# - name: Cache SonarCloud packages -# uses: actions/cache@v1 -# with: -# path: ~\sonar\cache -# key: ${{ runner.os }}-sonar -# restore-keys: ${{ runner.os }}-sonar -# -# - name: Cache SonarCloud scanner -# id: cache-sonar-scanner -# uses: actions/cache@v1 -# with: -# path: .\.sonar\scanner -# key: ${{ runner.os }}-sonar-scanner -# restore-keys: ${{ runner.os }}-sonar-scanner -# -# - name: Install SonarCloud scanner -# if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' -# shell: powershell -# run: | -# New-Item -Path .\.sonar\scanner -ItemType Directory -# dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner -# -# - name: Sonar Scan -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any -# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# shell: powershell -# run: | -# .\.sonar\scanner\dotnet-sonarscanner begin /k:"Kareadita_Kavita" /o:"kareadita" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" -# dotnet build --configuration Release -# .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" -# -# - name: Test -# run: dotnet test --no-restore --verbosity normal + test: + name: Install Sonar & Test + needs: build + runs-on: windows-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + include-prerelease: True + dotnet-version: '6.0' + + - name: Install dependencies + run: dotnet restore + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 1.11 + + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache SonarCloud scanner + id: cache-sonar-scanner + uses: actions/cache@v1 + with: + path: .\.sonar\scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + + - name: Install SonarCloud scanner + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' + shell: powershell + run: | + New-Item -Path .\.sonar\scanner -ItemType Directory + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner + + - name: Sonar Scan + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + shell: powershell + run: | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"Kareadita_Kavita" /o:"kareadita" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + dotnet build --configuration Release + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" + + - name: Test + run: dotnet test --no-restore --verbosity normal version: name: Bump version on Develop push - needs: [ build ] + needs: [ build, test ] runs-on: ubuntu-latest if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} steps: @@ -125,7 +125,7 @@ jobs: develop: name: Build Nightly Docker if Develop push - needs: [ build, version ] + needs: [ build, test, version ] runs-on: ubuntu-latest if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} steps: @@ -229,7 +229,7 @@ jobs: stable: name: Build Stable Docker if Main push - needs: [ build ] + needs: [ build, test ] runs-on: ubuntu-latest if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} steps: