Skip to content

Update code_cover.yml #101

Update code_cover.yml

Update code_cover.yml #101

Workflow file for this run

name: Code coverage
on:
push:
branches: [ develop, main ]
pull_request:
branches: [ develop, main ]
jobs:
code_cover:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start MSSQL in Docker
run: |
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=MyStr@ngPassw0rd" -e "MSSQL_PID=Developer" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest
- name: Wait for SqlServer Container
uses: whatnick/wait-action@master
with:
time: '10s'
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- uses: actions/setup-java@v4
name: Setup Java 17 for Sonar
with:
distribution: 'temurin'
java-version: '17'
- name: Install Project Dependencies
run: dotnet restore
- name: Service Project coverage report
run: |
dotnet test ./MyRestaurant.Services.Tests/MyRestaurant.Services.Tests.csproj /p:CollectCoverage=true /p:CoverletOutput=${{ github.workspace }}/coverage/Service.xml /p:CoverletOutputFormat=opencover
- name: Seed Data Project coverage report
run: |
dotnet test ./MyRestaurant.SeedData.Tests/MyRestaurant.SeedData.Tests.csproj /p:CollectCoverage=true /p:CoverletOutput=${{ github.workspace }}/coverage/SeedData.xml /p:CoverletOutputFormat=opencover
- name: Business Project coverage report
run: |
dotnet test ./MyRestaurant.Business.Tests/MyRestaurant.Business.Tests.csproj /p:CollectCoverage=true /p:CoverletOutput=${{ github.workspace }}/coverage/Business.xml /p:CoverletOutputFormat=opencover
- name: API Project coverage report
run: |
dotnet test ./MyRestaurant.Api.Tests/MyRestaurant.Api.Tests.csproj /p:CollectCoverage=true /p:CoverletOutput=${{ github.workspace }}/coverage/Api.xml /p:CoverletOutputFormat=opencover
- name: Publish Project coverage report to codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ github.workspace }}/coverage/*.xml
directory: ${{ github.workspace }}/coverage/
- name: Install SonarCloud scanner
run: dotnet tool install --global dotnet-sonarscanner
- name: Begin Sonar scan
run: |
dotnet-sonarscanner begin /k:"MathavanN_my_restaurant" \
/o:"mathavana-github" \
/d:sonar.login="${{ secrets.SONAR_TOKEN }}" \
/d:sonar.coverage.exclusions="**Test*.cs" \
/d:sonar.cs.opencover.reportsPaths=${{ github.workspace }}/coverage/*.xml \
/d:sonar.host.url="https://sonarcloud.io"
- name: Build For Sonar Scan
run: |
dotnet build --configuration Release --no-restore
- name: End Sonar scan
run: dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"