-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (133 loc) · 5.49 KB
/
bdn-apicompat.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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