highbyte / sonarscan-dotnet

GitHub Action SonarCloud/SonarQube scanner for .NET 8/7/6/5 and .NET Core applications with pull request decoration support
https://github.com/marketplace/actions/sonarscan-dotnet
MIT License
36 stars 24 forks source link

allow users to specify whether they want to add sonar pull request params #13

Closed kuamanet closed 2 years ago

kuamanet commented 2 years ago

This would let the sonar community users to add this action to their github CI.

highbyte commented 2 years ago

Hi,

I appreciate you took time to make a pull request.

I've done some tests with the Community edition, and this is what I found out:

Solution that worked for me when running against the Community edition:

Example workflow on statement

name: Sonarscan DotNet

# Controls when the action will run. 
on:
  # Triggers the workflow only on push to main
  push:
    branches: [ main ]      #<--- ONLY TRIGGER ON PUSH TO main/master WHEN RUNNING AGAINST COMMUNITY EDITION
  #pull_request:            #<--- COMMENTED OUT. SKIP TRIGGER ON ALL PR WHEN RUNNING AGAINST COMMUNITY EDITION
  #  branches: [ main ]     #<--- COMMENTED OUT. SKIP TRIGGER ON ALL PR WHEN RUNNING AGAINST COMMUNITY EDITION

As I see it there should not be any need for a code change.

In fact, the suggested code change seems to introduce risk of inconsistency. The scan result of the pull request will be appear in main/master branch in SonarQube (because Community edition doesn't support any other branches or PRs), when the code from the PR does not exist there (yet, or maybe never).

Please verify if the solution above works for you.

kuamanet commented 2 years ago

You are right sir, thanks for the example!