Skip to content

Upgrade xunit3 (#709) #2352

Upgrade xunit3 (#709)

Upgrade xunit3 (#709) #2352

Workflow file for this run

name: publish
on:
workflow_dispatch:
push:
branches:
- 'main'
pull_request:
branches:
- '*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace}}/nuget
NuGetSource: "https://api.nuget.org/v3/index.json"
defaults:
run:
shell: pwsh
jobs:
validate_readme:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- name: Validate Readme
run: .\eng\update-readme.ps1
- name: Validate Tool Readme
run: .\eng\update-tool-readme.ps1
validate_test_projects:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- name: Validate
run: .\eng\validate-testprojects-configuration.ps1
create_nuget:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- run: dotnet build eng/packages.proj --configuration Release /p:IsOfficialBuild=true /bl:build.binlog -warnaserror
- run: dotnet publish src/Meziantou.Framework.InlineSnapshotTesting.Prompt.TaskDialog --configuration Release --os win /p:IsOfficialBuild=true "--output:${{runner.temp}}/prompt" /bl:publish-taskdialog.binlog
- run: dotnet publish src/Meziantou.Framework.InlineSnapshotTesting.Prompt.NotificationTray --configuration Release --os win /p:IsOfficialBuild=true "--output:${{runner.temp}}/prompt" /bl:publish-notificationtray.binlog
- run: dotnet pack eng/packages.proj --configuration Release /p:IsOfficialBuild=true --output ${{ env.NuGetDirectory }} /p:RepositoryBranch="${{github.ref}}" "/p:PromptFolder=${{runner.temp}}/prompt" /bl:pack.binlog
- uses: actions/upload-artifact@v4
if: always()
with:
name: nuget
if-no-files-found: error
retention-days: 3
path: ${{ env.NuGetDirectory }}/**/*
- uses: actions/upload-artifact@v4
if: always()
with:
name: binlog
if-no-files-found: error
retention-days: 3
path: '**/*.binlog'
validate_nuget:
runs-on: ubuntu-24.04
needs: [ create_nuget ]
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Validate NuGet packages
run: .\eng\validate-nuget.ps1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build_and_test_x64:
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 60
env:
TestResultsDirectory: ${{ github.workspace}}/TestResults
strategy:
matrix:
runs-on: [ windows-2022, ubuntu-22.04, macos-14 ]
configuration: [ Debug, Release ]
additionalArguments: [ "", "/p:InvariantGlobalization=true" ]
fail-fast: false
steps:
- id: compute-artifact-name
name: Compute artifact name
run: |
$Name = "test-results-${{ matrix.runs-on }}-${{ matrix.configuration }}-x64-${{matrix.additionalArguments}}".Replace(":", "_").Replace("/", "_")
"artifact-name=$Name" >> $env:GITHUB_OUTPUT
- uses: actions/checkout@v4
- run: git config --global protocol.file.allow always
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- name: Setup .NET Core (additional versions)
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Build
run: dotnet build eng/build.proj --configuration ${{ matrix.configuration }} /bl ${{ matrix.additionalArguments }}
- name: Run tests
run: dotnet test eng/build.proj --configuration ${{ matrix.configuration }} --no-build --logger trx --results-directory "${{ env.TestResultsDirectory }}" --collect:"Code Coverage" --blame-hang --blame-hang-timeout 5min ${{ matrix.additionalArguments }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ steps.compute-artifact-name.outputs.artifact-name }}
if-no-files-found: error
retention-days: 3
path: |
**/*.binlog
${{ env.TestResultsDirectory }}/**/*
build_and_test_windows_x86:
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 60
env:
TestResultsDirectory: ${{github.workspace}}/TestResults
Architecture: ${{ matrix.architecture }}
TestTfmsInParallel: false # Attempt to reduce flakiness
strategy:
matrix:
configuration: [ Debug, Release ]
additionalArguments: [ "", "/p:InvariantGlobalization=true" ]
include:
- runs-on: windows-2022
architecture: x86
fail-fast: false
steps:
- id: compute-artifact-name
name: Compute artifact name
run: |
$Name = "test-results-${{ matrix.runs-on }}-${{ matrix.configuration }}-${{ matrix.architecture }}-${{matrix.additionalArguments}}".Replace(":", "_").Replace("/", "_")
"artifact-name=$Name" >> $env:GITHUB_OUTPUT
- uses: actions/checkout@v4
- run: git config --global protocol.file.allow always
- name: Build and Run Tests
run: |
echo "::group::Install .NET"
echo "Downloading dotnet-install.ps1 script"
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1'
echo "Installing .NET 8.0"
./dotnet-install.ps1 -Channel 8.0 -Architecture ${{ matrix.architecture }} -InstallDir ~/dotnet -NoPath
echo "Installing .NET (global.json)"
./dotnet-install.ps1 -JSonFile ${{github.workspace}}/global.json -Architecture ${{ matrix.architecture }} -InstallDir ~/dotnet
Get-Command dotnet
dotnet --info
echo "::endgroup::"
echo "::group::Build"
dotnet build eng/build.proj --configuration ${{ matrix.configuration }} /p:BuildInParallel=false /bl ${{ matrix.additionalArguments }}
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
echo "::endgroup::"
echo "::group::Run tests"
dotnet test eng/build.proj --configuration "${{ matrix.configuration }}" --no-build --logger trx --results-directory "${{ env.TestResultsDirectory }}" --collect:"Code Coverage" --blame-hang --blame-hang-timeout 5min ${{ matrix.additionalArguments }}
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
echo "::endgroup::"
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ steps.compute-artifact-name.outputs.artifact-name }}
if-no-files-found: error
retention-days: 3
path: |
**/*.binlog
${{ env.TestResultsDirectory }}/**/*
test_trimming:
runs-on: ubuntu-24.04
timeout-minutes: 60
strategy:
matrix:
# https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
runtime: [ "win-x64", "win-x86", "linux-x64", "osx-x64" ]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- run: dotnet publish --configuration Release --runtime ${{ matrix.runtime }} --self-contained Samples/Trimmable/Trimmable.csproj
test_trimming_wpf:
runs-on: windows-2022
timeout-minutes: 60
strategy:
matrix:
runtime: [ "win-x64", "win-x86" ]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- run: dotnet publish --configuration Release --runtime ${{ matrix.runtime }} --self-contained Samples/Trimmable.Wpf/Trimmable.Wpf.csproj
merge_coverage:
runs-on: ubuntu-24.04
needs: [build_and_test_x64, build_and_test_windows_x86]
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- name: Install dotnet-coverage
run: dotnet tool update --global dotnet-coverage
- name: Download test results
uses: actions/download-artifact@v4
with:
pattern: test-results-*
path: test-results
- name: Merge coverage files (format coverage)
run: dotnet-coverage merge --output test-result.coverage --output-format coverage (Get-ChildItem test-results -Recurse -Filter "*.coverage")
- name: Merge coverage files (format cobertura)
run: dotnet-coverage merge --output test-result.cobertura.xml --output-format cobertura (Get-ChildItem test-results -Recurse -Filter "*.coverage")
- uses: actions/upload-artifact@v4
with:
name: code-coverage
if-no-files-found: error
retention-days: 3
path: |
test-result.coverage
test-result.cobertura.xml
deploy:
runs-on: ubuntu-24.04
needs: [ validate_readme, validate_test_projects, validate_nuget, build_and_test_x64, build_and_test_windows_x86, test_trimming, test_trimming_wpf ]
steps:
- uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4
- run: |
Write-Host "Current ref: $env:GITHUB_REF"
Write-Host "Searching nupkg in folder: ${{ env.NuGetDirectory }}"
$files = Get-ChildItem "${{ env.NuGetDirectory }}/*" -Include *.nupkg
foreach($file in $files) {
Write-Host "Pushing NuGet package: $($file.FullName)"
if ($env:GITHUB_REF -eq 'refs/heads/main')
{
& dotnet nuget push "$($file.FullName)" --api-key "$env:NUGETAPIKEY" --source ${{ env.NuGetSource }} --force-english-output --skip-duplicate
}
else
{
& dotnet nuget push "$($file.FullName)" --api-key "$env:FEEDZ_APIKEY" --source "https://f.feedz.io/meziantou/meziantou-framework/nuget/index.json" --force-english-output --skip-duplicate
}
}
name: Publish NuGet packages
if: always()
env:
NUGETAPIKEY: ${{ secrets.NUGETAPIKEY }}
FEEDZ_APIKEY: ${{ secrets.FEEDZ_APIKEY }}