Skip to content

[Version] Prepare for the next version to 5.2.0 #8651

[Version] Prepare for the next version to 5.2.0

[Version] Prepare for the next version to 5.2.0 #8651

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 Core Lib
on:
# Allow manually running the workflow
workflow_dispatch:
push:
branches:
- dev
paths-ignore:
- '**/*.gitignore'
- '**/*.gitattributes'
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- dev
paths-ignore:
- '**/*.gitignore'
- '**/*.gitattributes'
env:
PROJECTS: >
./src/Core/Microsoft.FluentUI.AspNetCore.Components.csproj
./src/Charts/Microsoft.FluentUI.AspNetCore.Components.Charts.csproj
./src/Tools/McpServer/Microsoft.FluentUI.AspNetCore.McpServer.csproj
./src/Extensions/DataGrid.ODataAdapter/Microsoft.FluentUI.AspNetCore.Components.DataGrid.ODataAdapter.csproj
./src/Extensions/DataGrid.EntityFrameworkAdapter/Microsoft.FluentUI.AspNetCore.Components.DataGrid.EntityFrameworkAdapter.csproj
./src/Templates/Microsoft.FluentUI.AspNetCore.Templates.csproj
TESTS: >
./tests/Core/Components.Tests.csproj
./tests/Charts/Components.Charts.Tests.csproj
./tests/McpServer/McpServer.Tests.csproj
INTEGRATION_TEST: "" # DISABLING: ./tests/Integration/Components.IntegrationTests.csproj
MIN_COVERAGE: "98"
jobs:
Build:
name: Build and Test Core Lib
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
pull-requests: write
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET 9.0
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 9.0.321
dotnet-quality: ga
- name: Setup .NET 10.0
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 10.0.x
dotnet-quality: ga
- name: Setup .NET 11.0
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 11.0.100
dotnet-quality: ga
# Build
- name: Restore
run: dotnet restore Microsoft.FluentUI-v5.slnx
- name: Build
run: |
PROJECTS="${{ env.PROJECTS }}"
for project in $PROJECTS; do
dotnet build "$project" --configuration Release -warnaserror
done
working-directory: ${{ github.workspace }}
# Unit Tests
- name: Tests
run: |
TESTS="${{ env.TESTS }}"
for test in $TESTS; do
runsettings="$(dirname "$test")/coverage.runsettings"
if [ -f "$runsettings" ]; then
dotnet test "$test" --report-trx --results-directory ./TestResults --configuration Release --coverage --coverage-output-format cobertura --coverage-settings "$runsettings"
else
dotnet test "$test" --report-trx --results-directory ./TestResults --configuration Release --coverage --coverage-output-format cobertura
fi
done
working-directory: ${{ github.workspace }}
- name: Tests .NET 11.0
run: dotnet test ./tests/Core/Components.Tests.csproj --report-trx --results-directory ./TestResults --verbosity normal --configuration Release /p:ExampleNetVersion=net11.0
working-directory: ${{ github.workspace }}
- name: Publish Unit Tests
if: success() || failure()
continue-on-error: true
uses: dorny/test-reporter@d1b5dff021aa968b288b02285a8bf47471c5928a # v3.2.0
with:
name: Core Tests
path: '**/*.trx'
reporter: dotnet-trx
list-tests: failed
fail-on-error: false
- name: Extract Failed Tests
if: success() || failure()
shell: pwsh
run: |
$trxFilePath = Get-ChildItem -Path .\TestResults -Filter *.trx | Sort-Object LastWriteTime | Select-Object -Last 1
$testResults = Get-Content -Path $trxFilePath
# Initialize an empty array to store failed test names
$failedTests = "# Unit Tests"
$failedTestsCount = 0
# Search for failed test names in the TRX file
foreach ($line in $testResults) {
if ($line.Contains(" outcome=`"Failed`" "))
{
$matches = [regex]::Match($line, '(?<=testName=")([^"]+)')
if ($matches.Success) {
$failedTestsCount++
$testName = $matches.Groups[1].Value
$failedTests += "`n- ❌[FAILED] $testName"
}
}
}
if ($failedTestsCount -eq 0) {
$failedTests = "✅ All tests passed successfully"
}
$failedTests += "`n`n Details on [your Workflow / Core Tests](/microsoft/fluentui-blazor/actions/workflows/build-core-lib.yml) page."
Write-Host "$failedTests"
Set-Content -Path ./TestResults/ExtractedTests.md -Value $failedTests
working-directory: ${{ github.workspace }}
- name: Publish unit tests summary
if: success() || failure()
continue-on-error: true
uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5
with:
header: Test Results
path: ./TestResults/ExtractedTests.md
# Test Coverage
- name: Report Generator
uses: danielpalme/ReportGenerator-GitHub-Action@5f3701a41d14548c9b8e575a5c235230e515cbc0 # v5.6.0
with:
reports: '**/*.cobertura.xml'
targetdir: 'CoverageReports'
title: 'Unit Tests Code Coverage'
assemblyfilters: '-Microsoft.FluentUI.AspNetCore.Components.Tests.Tools;-McpServer.Tests'
classfilters: '-Microsoft.FluentUI.AspNetCore.Components.DesignTokens.*'
filefilters: '-*.g.cs'
customSettings: 'minimumCoverageThresholds:lineCoverage=${{ env.MIN_COVERAGE }};riskHotspotsAnalysisThresholds:metricThresholdForCrapScore=30;riskHotspotsAnalysisThresholds:metricThresholdForCyclomaticComplexity=30'
reporttypes: 'HtmlInline;MarkdownSummaryGithub'
- name: Upload coverage report
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: CoverageReports
path: CoverageReports
- name: Publish coverage summary
uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5
continue-on-error: true
with:
path: CoverageReports/SummaryGithub.md
# Integration Tests
- name: Build Integration Tests
if: env.INTEGRATION_TEST != ''
run: dotnet build ${{ env.INTEGRATION_TEST }} --verbosity normal --configuration Release
working-directory: ${{ github.workspace }}
- name: Install Playwright
if: env.INTEGRATION_TEST != ''
shell: pwsh
working-directory: ${{ github.workspace }}
run: |
# Use the ExampleNetVersion from Directory.Build.props (currently net10.0)
./tests/Integration/bin/Release/net10.0/playwright.ps1 install
- name: Run Integration Tests
if: env.INTEGRATION_TEST != ''
run: dotnet test ${{ env.INTEGRATION_TEST }} --logger:trx --results-directory ./TestResults --verbosity normal --configuration Release
working-directory: ${{ github.workspace }}
- name: Handle Test Failure
if: env.INTEGRATION_TEST != '' && failure()
run: echo "Integration tests failed. Taking necessary actions..."
working-directory: ${{ github.workspace }}
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
if: github.event_name != 'pull_request' # Not analyzing PRs
strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup .NET 9.0
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 9.0.321
dotnet-quality: ga
- name: Setup .NET 10.0
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 10.0.x
dotnet-quality: ga
- name: Setup .NET 11.0
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 11.0.100
dotnet-quality: ga
- name: Initialize CodeQL
uses: github/codeql-action/init@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
with:
languages: ${{ matrix.language }}
- if: matrix.language == 'csharp'
name: Manually build CSharp on .NET
run: |
PROJECTS="${{ env.PROJECTS }}"
for project in $PROJECTS; do
dotnet build "$project"
done
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4