Skip to content

Merge pull request #1 from feature23/feature/unit-tests #14

Merge pull request #1 from feature23/feature/unit-tests

Merge pull request #1 from feature23/feature/unit-tests #14

Workflow file for this run

name: build
on:
workflow_dispatch:
push:
branches:
- main
- 'releases/**'
pull_request:
branches: [ main ]
paths:
- '**/*.cs'
- '**/*.csproj'
jobs:
build:
name: build-${{matrix.os}}-${{matrix.dotnet}}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: src
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
dotnet: ['8.x'] # Just a single target for now
steps:
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal --logger trx --collect:"XPlat Code Coverage"
- name: Combine Coverage Reports # This is because one report is produced per project, and we want one result for all of them.
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.4
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' # Skip if running locally with act
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" # 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: Upload Combined Coverage XML
uses: actions/upload-artifact@v4
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' # Skip if running locally with act
with:
name: coverage
path: ${{ github.workspace }}/Cobertura.xml
retention-days: 5
- name: Publish Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' # Skip if running locally with act
with:
filename: "Cobertura.xml"
badge: true
fail_below_min: false # just informative for now
format: markdown
hide_branch_rate: false
hide_complexity: false
indicators: true
output: both
thresholds: "10 30" # Red, Yellow
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request' # Skip if running locally with act, or if not a pull request
with:
recreate: true
path: code-coverage-results.md
- name: Upload Test Result Files
uses: actions/upload-artifact@v4
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' # Skip if running locally with act
with:
name: test-results
path: ${{ github.workspace }}/**/TestResults/**/*
retention-days: 5
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2.16.1
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' && always() # Skip if running locally with act
with:
trx_files: "${{ github.workspace }}/**/*.trx"