Skip to content

BDN API Compatibility Check #816

BDN API Compatibility Check

BDN API Compatibility Check #816

Workflow file for this run

name: BDN API Compatibility Check
on:
workflow_dispatch:
inputs:
previous-version:
description: 'Previous Version Override'
type: string
issue-type:
description: 'Issue Type'
type: choice
default: ReportAndSummary
options:
- Report
- ReportAndSummary
- Summary
- None
schedule:
- cron: '0 0 * * 0'
defaults:
run:
shell: pwsh
env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
ApiCompat:
outputs:
LastCheckedVersion: ${{ steps.apicompat.outputs.LastCheckedVersion }}
IssueNumber: ${{ steps.apicompat.outputs.IssueNumber }}
IsBreaking: ${{ steps.apicompat.outputs.IsBreaking }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
show-progress: false
fetch-depth: 1
# The APICompat check involves dotnet restore and dotnet msbuild with custom target.
# This doesn't require a specific dotnet sdk version.
- name: Remove global.json
run: Remove-Item ./global.json
- name: Check BDN API Compatibility
id: apicompat
run: |
$token = ConvertTo-SecureString ${{ secrets.GITHUB_TOKEN }} -AsPlainText
$issueType = '${{ github.event.inputs.issue-type }}'
if (-not $issueType) { $issueType = 'ReportAndSummary' }
./build/checkBdnApiCompatibility.ps1 -Token $token -IssueType $issueType -PreviousVersionOverride '${{ github.event.inputs.previous-version }}'
- name: Upload Status
uses: actions/upload-artifact@v4
with:
name: ${{ steps.apicompat.outputs.StatusArtifactName }}
path: ${{ steps.apicompat.outputs.StatusArtifactPath }}
retention-days: 14
- name: Upload Logs
if: ${{ steps.apicompat.outputs.LogArtifactName != '' }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.apicompat.outputs.LogArtifactName }}
path: ${{ steps.apicompat.outputs.LogArtifactPath }}
Test:
needs: ApiCompat
if: ${{ needs.ApiCompat.outputs.IsBreaking == 'true' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest]
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
show-progress: false
fetch-depth: 1
- name: Setup dotnet (pinned)
uses: actions/setup-dotnet@v4
with:
global-json-file: ./global.json
- name: Build
env:
MSBuildDebugEngine: 1 # Auto-creates binlogs in ./MSBuild_Logs
# Fix incomplete binlogs in MSBuild <=17.3.x. See https://github.com/mawosoft/Mawosoft.Extensions.BenchmarkDotNet/issues/146
MSBUILDLOGTASKINPUTS: 1
MSBUILDTARGETOUTPUTLOGGING: true
MSBUILDLOGIMPORTS: 1
run: |
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
$BdnNightlyVersion = '${{ needs.ApiCompat.outputs.LastCheckedVersion }}'
dotnet restore "-p:BDNNightlyVersion=$BdnNightlyVersion"
dotnet build ./src/Mawosoft.Extensions.BenchmarkDotNet/Mawosoft.Extensions.BenchmarkDotNet.csproj -c Debug --no-restore
dotnet build ./src/Mawosoft.Extensions.BenchmarkDotNet/Mawosoft.Extensions.BenchmarkDotNet.csproj -c Release --no-restore
dotnet build ./tests/Mawosoft.Extensions.BenchmarkDotNet.Tests/NightlyBDN/Mawosoft.Extensions.BenchmarkDotNet.Tests.NightlyBDN.csproj -c Debug --no-restore
dotnet build ./tests/Mawosoft.Extensions.BenchmarkDotNet.Tests/NightlyBDN/Mawosoft.Extensions.BenchmarkDotNet.Tests.NightlyBDN.csproj -c Release --no-restore
- name: Upload Binlogs
if: ${{ failure() || github.event_name == 'workflow_dispatch' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-Binlogs
path: '**/MSBuild_Logs/*'
- name: Test
id: test
run: |
$tfms = @("net8.0")
if ($IsWindows) { $tfms += "net462" }
./build/invokeDotnetTest.ps1 -p ./tests/Mawosoft.Extensions.BenchmarkDotNet.Tests/NightlyBDN/Mawosoft.Extensions.BenchmarkDotNet.Tests.NightlyBDN.csproj -c Debug, Release -f $tfms -v detailed -r ./TestResults -ff:$${{ strategy.fail-fast }}
- name: Upload Test results
if: ${{ (failure() || github.event_name == 'workflow_dispatch') && steps.test.outcome != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-Testresults
path: ./TestResults/
Feedback:
needs: [ApiCompat, Test]
if: ${{ always() && needs.ApiCompat.outputs.IssueNumber != '' }}
runs-on: ubuntu-latest
steps:
- name: Update Issue with Test Status
run: |
$uri = 'https://api.github.com/repos/${{ github.repository }}/issues/${{ needs.ApiCompat.outputs.IssueNumber }}'
$auth = @{
Authentication = 'Bearer'
Token = (ConvertTo-SecureString ${{ secrets.GITHUB_TOKEN }} -AsPlainText)
}
$response = Invoke-RestMethod -Uri $uri @auth
$find = 'Test%20Run-pending-lightgrey'
$replace = '${{ needs.Test.result }}' -eq 'success' ? 'Test%20Run-succeeded-4FCA5D' : 'Test%20Run-failed-CC1A4B'
$body = $response.body
$pos = $body.IndexOf($find)
$body = $body.Substring(0, $pos) + $replace + $body.Substring($pos + $find.Length)
$param = @{ body = $body }
$response = $param | ConvertTo-Json -EscapeHandling EscapeNonAscii | Invoke-RestMethod -Uri $uri -Method Patch -ContentType 'application/json' @auth