diff --git a/.github/workflows/sonarscan.yml b/.github/workflows/sonarscan.yml index c8ebe7435..b772760cc 100644 --- a/.github/workflows/sonarscan.yml +++ b/.github/workflows/sonarscan.yml @@ -2,23 +2,24 @@ name: Sonar Scanner on: workflow_dispatch: jobs: - build: - name: Build + sonarcloud: + name: SonarCloud runs-on: windows-latest steps: - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 1.11 - uses: actions/checkout@v2 with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Cache SonarCloud packages + # Shallow clones should be disabled for a better relevancy of analysis + fetch-depth: 0 + + # Speed-up analysis by caching the scanner workspace + - name: Cache SonarCloud workspace uses: actions/cache@v1 with: - path: ~\sonar\cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar + path: ~\.sonar\cache + key: ${{ runner.os }}-sonar-cache + restore-keys: ${{ runner.os }}-sonar-cache + + # Speed-up analysis by caching the scanner installation - name: Cache SonarCloud scanner id: cache-sonar-scanner uses: actions/cache@v1 @@ -26,19 +27,24 @@ jobs: 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 + # The --version argument is optional. If it is omitted the latest version will be installed. run: | New-Item -Path .\.sonar\scanner -ItemType Directory - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner --version 4.8.0 + - name: Build shell: powershell + env: + # Needed to get some information about the pull request, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # The secret referenced in the command-line by SONAR_TOKEN should be generated + # from https://sonarcloud.io/account/security/ + # The organization and project arguments (see /o and /k) are displayed + # on the project dashboard in SonarCloud. run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"Ombi-app_Ombi" /o:"ombi-app" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" - cd src - dotnet build -c NonUiBuild + .\.sonar\scanner\dotnet-sonarscanner begin /k:"SonarSource_sonarcloud-github-action-samples" /o:"sonarsource" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + dotnet build src/Ombi.sln .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"