Merge pull request #42 from RaaLabs/dockerfile #171
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'sonarcloud' | |
on: | |
push: | |
branches: | |
- '**' | |
jobs: | |
ci: | |
name: Sonarcloud | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.x' | |
- name: Add private Nuget feed | |
run: dotnet nuget add source --username ${{ secrets.NUGET_GITHUB_PACKAGES_USERNAME }} --password ${{ secrets.NUGET_GITHUB_PACKAGES_TOKEN }} --store-password-in-clear-text --name "githubpackagesnuget" "https://nuget.pkg.github.com/RaaLabs/index.json" | |
- name: Check that Coverlet is installed | |
run: | | |
if ! dotnet sln list | tail -n+3 | grep -qE '(Test|Specs)' ; then | |
echo "No test projects found in the solution." | |
exit 0 | |
fi | |
dotnet restore ${{ inputs.target }} | |
DEPENDENCIES=$(dotnet list package --include-transitive --format=json | jq -r '.projects[].frameworks[] | .topLevelPackages + .transitivePackages | select(.) | map(.id) | .[]') | |
if ! grep -q "coverlet.collector" <<<$DEPENDENCIES ; then | |
echo "The 'coverlet.collector' package is required to make code coverage work." | |
echo "Please add it by running 'dotnet add package coverlet.collector' in your test project." | |
exit 1 | |
fi | |
- name: Run tests using SonarScanner and report results | |
uses: highbyte/[email protected] | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
sonarOrganization: raalabs | |
sonarProjectName: ${{ github.event.repository.name }} | |
sonarProjectKey: RaaLabs_${{ github.event.repository.name }} | |
dotnetPreBuildCmd: dotnet nuget add source --username ${{ secrets.NUGET_GITHUB_PACKAGES_USERNAME }} --password ${{ secrets.NUGET_GITHUB_PACKAGES_TOKEN }} --store-password-in-clear-text --name "githubpackagesnuget" "https://nuget.pkg.github.com/RaaLabs/index.json" | |
sonarBeginArguments: /d:sonar.cs.opencover.reportsPaths="**/TestResults/**/coverage.opencover.xml" -d:sonar.cs.vstest.reportsPaths="**/TestResults/*.trx" | |
dotnetBuildArguments: ${{ inputs.target }} | |
dotnetTestArguments: ${{ inputs.target }} --logger trx --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover || true |