Skip to content

Add comprehensive unit tests for timesheet domain & app #177

Add comprehensive unit tests for timesheet domain & app

Add comprehensive unit tests for timesheet domain & app #177

Workflow file for this run

# 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: Build And Test
permissions:
contents: read
actions: read
statuses: write
on:
push:
branches: [ "master", "main" ]
pull_request:
branches: [ "master", "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Restore Dependencies
run: dotnet restore
- name: Build Project
run: dotnet build --no-restore
# with:
# dotnet-version: 10.0.x
- name: Run Tests
run: dotnet test ./tests/Azure.Local.Tests/Azure.Local.Tests.csproj --verbosity detailed --logger trx --results-directory ${{ github.workspace }}/unittests
- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: unittestresults
path: ${{ github.workspace }}/unittests
- name: Upload Feature Results
uses: actions/upload-artifact@v4
with:
name: featureresults
path: ${{ github.workspace }}/**/Reports/FeaturesReport.html
- name: Run Tests For Coverage
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ${{ github.workspace }}/coverage --settings:./codecoverage.runsettings
- name: Combine Coverage Reports as Cobertura # This is because one report is produced per project, and we want one result for all of them.
uses: danielpalme/[email protected]
with:
reports: "**/*.cobertura.xml" # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
targetdir: "${{ github.workspace }}" # REQUIRED # The directory where the generated report should be saved.
reporttypes: "Cobertura" # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, Html_Dark, Html_Light, Html_BlueRed, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlInline_AzurePipelines_Light, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MarkdownSummaryGithub, MarkdownDeltaSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, TextDeltaSummary, Xml, XmlSummary
verbosity: "Info" # The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off
title: "Code Coverage Xml" # Optional title.
tag: "${{ github.run_number }}_${{ github.run_id }}" # Optional tag or build version.
customSettings: "" # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings.
toolpath: "reportgeneratortool" # Default directory for installing the dotnet tool.
- name: Combine Coverage Reports as Html # This is because one report is produced per project, and we want one result for all of them.
uses: danielpalme/[email protected]
with:
reports: "**/*.cobertura.xml" # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
targetdir: "${{ github.workspace }}/codecoverage" # REQUIRED # The directory where the generated report should be saved.
reporttypes: "Html" # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, Html_Dark, Html_Light, Html_BlueRed, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlInline_AzurePipelines_Light, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MarkdownSummaryGithub, MarkdownDeltaSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, TextDeltaSummary, Xml, XmlSummary
verbosity: "Verbose" # The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off
title: "Code Coverage Html" # Optional title.
tag: "${{ github.run_number }}_${{ github.run_id }}" # Optional tag or build version.
customSettings: "" # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings.
toolpath: "reportgeneratortool" # Default directory for installing the dotnet tool.
classfilters: "-System.Runtime.CompilerServices;-Microsoft.AspNetCore.OpenApi.Generated;-AutoGeneratedProgram;-Azure.Local.ApiService.Tests.Component.*;-*.TestHelper;-*.ApplicationUnitTests"
- name: Upload Combined Artifact Of Xml Code Coverage Report
uses: actions/upload-artifact@v4
with:
name: code-coverage-report-cobertura
path: ${{ github.workspace }}/Cobertura.xml
- name: Upload Combined Artifact Of Cobutura Code Coverage Report
uses: actions/upload-artifact@v4
with:
name: code-coverage-report-html
path: ${{ github.workspace }}/codecoverage
- name: Generate Code Coverage Report
uses: irongut/[email protected]
with:
filename: cobertura.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'
# - name: Add Coverage PR Comment
# uses: marocchino/sticky-pull-request-comment@v2
# with:
# recreate: true
# path: code-coverage-results.md
- name: Write Code Coverage To Job Summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY