.NET build with GitHub actions very slow

We’re trying to hook up sonarcloud to our github pull request process via GitHub Actions and notice the overall build time takes really long time. When I run the build commands on my local via Sonarqube, the whole process takes around 3mins. However, vis sonarcloud it takes 20-30 mins.

  • ALM used
    GitHub
  • CI system used
    Azure DevOps but we don’t use Sonarcloud for this
  • Scanner command used when applicable (private details masked)
name: Sonarcloud
on:
  pull_request:   
    paths-ignore:
      - 'BTS/Database/**'
jobs:
  build:
    name: Sonarcloud
    runs-on: ubuntu-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: Install SonarCloud scanner        
        run: |          
          dotnet tool install --global dotnet-sonarscanner
      - name: Build and analyze
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}        
        run: |
          dotnet-sonarscanner begin /k:"***********" /o:"********" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
          dotnet build
          dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
  • Languages of the repository
    .NET 6.0/ c#

We also tried applying SONAR_DOTNET_ENABLE_CONCURRENT_EXECUTION: true but did not see any difference.

Ran the analyzer command based on this blog post I read - The SonarSource guide for investigating the performance of .NET analysis

Here is the analyzer.txt output
analyzer_times.txt (189 KB)

Hello @Ray_Park and welcome to the community!

How many CPUs do the build machines have? Can you increase the processing resources?

I see most projects are ok, except one:

Time (s)
1041.102

And here there are some rules that indeed take a lot. I’ll take this info internally.

All of this really helps us, thanks a lot for the data. I believe that if you will increase the number of CPUs it will get better (and we need to continue looking into improving our perf, too).

Hi Andrei,

Thanks for responding!
We are using the GitHub host runners, specifically ubuntu-latest. According to their documentation the hardware specs for these are:

  • 2-core CPU (x86_64)
  • 7 GB of RAM
  • 14 GB of SSD space

Unfortunately, GitHub does not give us the option to change the spec for these boxes.

If you can think of other options or suggestions do let me know.