You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2022/10/20 12:34:26 UTC

[GitHub] [lucenenet] nikcio commented on pull request #709: ci: Added sonar workflow

nikcio commented on PR #709:
URL: https://github.com/apache/lucenenet/pull/709#issuecomment-1285468067

   @NightOwl888 
   
   It's totally possible to do without the plugin. SonarClouds own example uses a workflow like this one:
   
   ```yml
   name: Build
   on:
     push:
       branches:
         - sonarcloud
     pull_request:
       types: [opened, synchronize, reopened]
   jobs:
     build:
       name: Build
       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
           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: Build and analyze
           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:"nikcio_lucenenet" /o:"nikcio" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
             <insert_your_build_command>
             .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
   ```
   
   The reason I use the action instead is because I wanted to use an `Ubuntu` runner because in my experience they are faster. And when I tried doing it with a template like this one I had some errors and then it was just easier using this action plugin. But using something like this example might also make the runner more stable which might make us able to run coverage tests with something like `coverlet.collector`.
   
   I also found a repository of the same'ish size from Apache using SonarCloud in the link you found and here it runs un `Ubuntu` so it's possible: https://github.com/apache/cloudstack/blob/main/.github/workflows/coverage-check.yml


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org