Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 76 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Test

on:
push:
branches: [main, dev]
branches: [main]
paths:
- 'src/**'
- 'tests/**'
Expand All @@ -13,7 +13,7 @@ on:
- 'global.json'
- '.github/workflows/build-and-test.yml'
pull_request:
branches: [main, dev]
branches: [main]
paths:
- 'src/**'
- 'tests/**'
Expand All @@ -24,11 +24,18 @@ on:
- 'global.json'
- '.github/workflows/build-and-test.yml'

permissions:
contents: read

jobs:
build-and-test:
name: Build and test

runs-on: ubuntu-latest

permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Setup .NET
Expand All @@ -39,5 +46,71 @@ jobs:
run: dotnet restore ./Light.GuardClauses.slnx
- name: Build
run: dotnet build ./Light.GuardClauses.slnx -c Release --no-restore
- name: Install ReportGenerator
run: dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.5.10
- name: Test
run: dotnet test ./Light.GuardClauses.slnx -c Release --no-build --verbosity normal
run: >
dotnet test
--solution ./Light.GuardClauses.slnx
-c Release
--no-build
--no-restore
--results-directory artifacts/test-results
--coverage
--coverage-output-format cobertura
- name: Merge coverage
if: always()
run: >
reportgenerator
"-reports:artifacts/test-results/**/*.cobertura.xml"
"-targetdir:artifacts/coverage"
"-reporttypes:Cobertura;MarkdownSummaryGithub"
- name: Create coverage summary
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: artifacts/coverage/Cobertura.xml
format: markdown
output: both
badge: true
thresholds: '60 85'
- name: Store coverage summary
run: mv code-coverage-results.md artifacts/coverage/code-coverage-results.md
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: artifacts/test-results
if-no-files-found: warn
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: artifacts/coverage
if-no-files-found: warn

coverage-comment:
name: Coverage comment
runs-on: ubuntu-latest
needs: build-and-test
if: >
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository

permissions:
contents: read
issues: write
pull-requests: write

steps:
- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverage-report
path: artifacts/coverage
- name: Update pull request comment
uses: marocchino/sticky-pull-request-comment@v3.0.4
with:
header: code-coverage
path: artifacts/coverage/code-coverage-results.md
11 changes: 6 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
Keep Microsoft.CodeAnalysis.* aligned so analyzers, code fixes, and source-export tooling use one Roslyn line.
-->
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.15.6" />
<PackageVersion Include="FluentAssertions" Version="[7.2.0]" />
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
<PackageVersion Include="FluentAssertions" Version="[7.2.2]" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.6.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.9" />
<PackageVersion Include="Microsoft.Extensions.Configuration.CommandLine" Version="10.0.9" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.9" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.9.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="2.3.2" />
<PackageVersion Include="Microsoft.Testing.Platform" Version="2.3.2" />
<PackageVersion Include="Nullable" Version="1.3.1" />
<PackageVersion Include="System.Collections.Immutable" Version="10.0.9" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.2" />
</ItemGroup>
</Project>
Loading
Loading