Skip to content

Scheduled SonarCloud #55

Scheduled SonarCloud

Scheduled SonarCloud #55

name: "Scheduled SonarCloud"
on:
schedule:
- cron: '0 06 */7 * *'
jobs:
build-test:
name: "Build and Test"
runs-on: ubuntu-latest
steps:
###
# Checkout repository
###
- name: Checkout repository
uses: actions/checkout@v3
with:
lfs: true
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
###
# 🧰 Install .Net SDKs
#
# Configure the pipeline to use the correct .Net sdk versions
###
- name: 🧰 Install .Net SDKs
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
###
# 🧰 Setup .Net tools
#
# Register tools necessary to run the `test` pipeline-job
###
- name: 🧰 Setup .NET tools
run: |-
dotnet tool install --global dotnet-reportgenerator-globaltool
###
# 🧰 Setup SonarCloud scanner
#
# Installs and initializes the SonarCloud scanner
###
- name: 🧰 Setup SonarCloud scanner
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >-
[System.IO.Directory]::CreateDirectory('${{github.workspace}}/.sonar/scanner')
dotnet tool install dotnet-sonarscanner --tool-path '${{github.workspace}}/.sonar/scanner'
./.sonar/scanner/dotnet-sonarscanner begin
/k:"Marvin-Brouwer_FluentSerializer"
/o:"marvin-brouwer"
/d:sonar.login="${{ secrets.SONAR_TOKEN }}"
/d:sonar.host.url="https://sonarcloud.io"
/s:"${{github.workspace}}/SonarQube.Analysis.xml"
###
# πŸ—ƒ Restore dependencies
#
# Fill the NuGet store with necessary libraries
###
- name: πŸ—ƒ Restore dependencies
run: dotnet restore
###
# πŸ›  Build
#
# Build the library code for later use
###
- name: πŸ›  Build
run: dotnet build --no-restore --nologo --configuration "Release"
###
# πŸ§ͺ Run unit tests
#
# Run the unit tests of category `UnitTest` and generate a code coverage report.
###
- name: πŸ§ͺ Run unit tests
run: >-
dotnet test --verbosity:normal
--no-build --no-restore --nologo
--configuration="Release"
--logger:"console;verbosity=detailed"
--logger:"GitHubActions"
--logger "trx;LogFileName=test-results.trx"
--collect "DotnetCodeCoverage"
--collect "XPlat Code coverage"
--results-directory:"${{github.workspace}}/test-results"
--filter:"Category=UnitTest"
/p:CollectCoverage="true"
/p:CoverletOutputFormat="opencover"
/p:CoverletOutput="${{github.workspace}}/test-results/coverage/"
/p:MergeWith="${{github.workspace}}/test-results/coverage/"
/p:Exclude="[*Tests]*%2c[*TestUtils]*%2c[*UseCase*]*"
/clp:forceconsolecolor
"${{github.workspace}}/FluentSerializer.sln";
reportgenerator
-reports:"${{github.workspace}}/test-results/*/coverage.cobertura.xml"
-targetdir:"${{github.workspace}}/test-results/coverage"
-reporttypes:SonarQube;
working-directory: ${{github.workspace}}
###
# πŸ§ͺ Run integration tests
#
# Run the unit tests of category `IntegrationTest` to verify the integration of various unit-tests.
###
- name: πŸ§ͺ Run integration tests
run: >-
dotnet test --verbosity:normal
--no-build --no-restore --nologo
--configuration="Release"
--logger:"console;verbosity=detailed"
--logger:"GitHubActions"
--filter:"Category=IntegrationTest"
/clp:forceconsolecolor
"${{github.workspace}}/FluentSerializer.sln";
working-directory: ${{github.workspace}}
###
# πŸ§ͺ Run use-case tests
#
# Run the unit tests of category `UseCase` to illustrate the library still works as intended.
# This is basically a kind of integration test.
###
- name: πŸ§ͺ Run use-case tests
run: >-
dotnet test --verbosity:normal
--no-build --no-restore --nologo
--configuration="Release"
--logger:"console;verbosity=detailed"
--logger:"GitHubActions"
--filter:"Category=UseCase"
/clp:forceconsolecolor
"${{github.workspace}}/FluentSerializer.sln";
working-directory: ${{github.workspace}}
###
# πŸ”¬ Perform SonarCloud Analysis
###
- name: πŸ”¬ Perform SonarCloud Analysis
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >-
./.sonar/scanner/dotnet-sonarscanner end
/d:sonar.login="${{ secrets.SONAR_TOKEN }}"