Skip to content

Adding static analysis to all projects in the solution. #15

Adding static analysis to all projects in the solution.

Adding static analysis to all projects in the solution. #15

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Run Unit Test and Get Code Coverage
on:
push:
branches: [ "**" ]
pull_request:
branches: [ "main", "develop" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
run: dotnet tool install --global dotnet-sonarscanner
- name: Install project dependencies
run: dotnet restore
working-directory: ./API
- name: Test and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin /k:"taorodrigueswork_rest-api" /o:"taorodrigueswork" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build ./API --configuration Debug
dotnet test --environment 'Development' /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*]Persistence.Migrations.*" -l trx ./API
dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"