This action is responsible for running tests and publish the test resport to SonarQube.
Before using this action, please be sure that all tests projects have the following dependencies installed and updated to at least the latest stable version
xunit
xunit.runner.visualstudio
Microsoft.NET.Test.Sdk
coverlet.collector
coverlet.msbuild
GitHubActionsTestLogger
Required: SonarQube token
Required: SonarQube URL
Required: SonarQube project key
To get the SonarQube project key go to SonarQube
, find or setup your project, then click on Project Information
at the top right corner. The Project Key
will be found at drawer window that should be opened on you right.
Required: SonarQube organization name
Required: Boolean to change behavior of dotnet-sonarscanner for pull requests
Required: when pull-request
input parameter is set to false
Optional: when pull-request
input parameter is set to true
Branch name to be displayed on SonarQube.
Required: when pull-request
input parameter is set to true
Optional: when pull-request
input parameter is set to false
The number of the pull request
Required: when pull-request
input parameter is set to true
Optional: when pull-request
input parameter is set to false
The target branch name from the pull request
Required: when pull-request
input parameter is set to true
Optional: when pull-request
input parameter is set to false
The target source name from the pull request
Optional: Solution file name without the .sln extension (do not use with project input parameter)
Optional: The path of test project to be tested (do not use with solution input parameter)
solution and project are optional for you to choose one to use, but you MUST choose one |
---|
Optional: The matching path for code that should be excluded from coverage (absolute, relative and pattern paths are acceptable)
Optional: Poll to SonarQube instance until the Quality Gate status is available (default is true
)
Optional: Verbosity level for dotnet test
command (default is m
)
Allowed values are q[uiet]
, m[inimal]
, n[ormal]
, d[etailed]
, and diag[nostic]
Optional: Runs dotnet restore
before runs dotnet test
. (default is true
)
Optional: Add flags to dotnet restore
command. (defaults is no flags)
Full flags list is available here
Optional: Runs dotnet build --no-restore
before runs dotnet test
. (default is true
)
Optional: Add flags to dotnet build
command. (default is --no-restore
)
Full flags list is available here
Optional: Add flags for dotnet test
command. (default is --no-build --no-restore
).
Full flags list is available here.
Using for push on long-lived branches:
- name: Warren - Run Tests and SonarQube Analysis
uses: warrenbrasil/sonar-qube@v2
with:
sonar-token: ${{ secrets.SONAR_TOKEN }}
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}
sonar-project-key: warrenbrasil_my-repo-sonar-key
sonar-organization: myorg
solution: Warren.Core.MyRepo
pull-request: false
branch-name: ${{ github.head_ref || github.ref_name }}
Using for pull requests:
- name: Warren - Run Tests and SonarQube Analysis
uses: warrenbrasil/sonar-qube@v3
with:
sonar-token: ${{ secrets.SONAR_TOKEN }}
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}
sonar-project-key: warrenbrasil_my-repo-sonar-key
sonar-organization: myorg
solution: Warren.Core.MyRepo
pull-request: true
pull-request-number: ${{ github.event.pull_request.number }}
pull-request-base: ${{ github.event.pull_request.base.ref }}
pull-request-head: ${{ github.event.pull_request.head.ref }}
Using with file code exclusions:
- name: Warren - Run Tests and SonarQube Analysis
uses: warrenbrasil/sonar-qube@v3
with:
sonar-token: ${{ secrets.SONAR_TOKEN }}
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}
sonar-project-key: myorg_my-project-key
sonar-organization: myorg
solution: Warren.Core.MyRepo
code-exclusions: "tests/Warren.Core.MyRepo.Fixtures/**/*.cs"
pull-request: false
branch-name: ${{ github.head_ref || github.ref_name }}
Using with multiline file code exclusions:
- name: Warren - Run Tests and SonarQube Analysis
uses: warrenbrasil/sonar-qube@v3
with:
sonar-token: ${{ secrets.SONAR_TOKEN }}
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}
sonar-project-key: myorg_my-project-key
sonar-organization: myorg
solution: Warren.Core.MyRepo
code-exclusions: >-
tests/Warren.Core.MyRepo.Fixtures/**/*.cs,
src/Warren.Core.MyRepo.Services/**/*.cs
pull-request: false
branch-name: ${{ github.head_ref || github.ref_name }}
Using with dotnet restore, dotnet build and dotnet test flags:
- name: Warren - Run Tests and SonarQube Analysis
uses: warrenbrasil/sonar-qube@v3
with:
sonar-token: ${{ secrets.SONAR_TOKEN }}
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}
sonar-project-key: myorg_my-project-key
sonar-organization: myorg
solution: Warren.Core.MyRepo
pull-request: false
branch-name: ${{ github.head_ref || github.ref_name }}
dotnet-restore-flags: --no-cache
dotnet-build-flags: --configuration Release
dotnet-test-flags: --configuration Release