-
Notifications
You must be signed in to change notification settings - Fork 277
146 lines (122 loc) · 4.8 KB
/
ci-cd.yml
File metadata and controls
146 lines (122 loc) · 4.8 KB
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
141
142
143
144
145
146
name: CI/CD Pipeline
on: [push, pull_request, workflow_dispatch]
permissions:
contents: read
jobs:
ci:
name: Continuous Integration
runs-on: ubuntu-latest
permissions:
contents: read
code-quality: write
pull-requests: read
env:
ARTIFACTS_FOLDER: ${{ github.workspace }}/Artifacts
GITHUB_RUN_NUMBER: ${{ github.run_number }}
steps:
- name: Setup .NET 8
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.x
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
- name: Checkout repository
id: checkout_repo
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Build projects
id: build_projects
shell: pwsh
run: |
dotnet build Microsoft.OpenApi.slnx -c Release
- name: Run unit tests
id: run_unit_tests
shell: pwsh
run: |
dotnet test Microsoft.OpenApi.slnx -c Release --no-build -v n --collect:"XPlat Code Coverage"
- name: Install report generator
shell: pwsh
run: |
dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Generate coverage report
shell: pwsh
run: |
reportgenerator -reports:**/coverage.cobertura.xml -targetdir:./reports/coverage -reporttypes:"Html;MarkdownSummaryGithub;Cobertura"
- name: Add coverage to job summary
shell: bash
run: |
cat ./reports/coverage/SummaryGithub.md >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage report
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') || (github.event_name != 'pull_request' && github.ref_name == github.event.repository.default_branch)
uses: actions/upload-code-coverage@v1
with:
file: ./reports/coverage/Cobertura.xml
language: CSharp
label: code-coverage/dotnet
- name: Upload coverage artifact
uses: actions/upload-artifact@v7
with:
name: coverage
path: reports/coverage
validate-trimming:
name: Validate Project for Trimming
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Setup .NET 8
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.x
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
- name: Validate Trimming warnings
run: dotnet publish -c Release -r win-x64 /p:TreatWarningsAsErrors=true /warnaserror -f net10.0
working-directory: ./test/Microsoft.OpenApi.Trimming.Tests
validate-performance:
name: Validate performance of the library
runs-on: ubuntu-latest
needs: [ci]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup .NET 8
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.x
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
- name: Copy committed results
run: |
mkdir -p ./performanceResults
cp -r ./performance/benchmark/BenchmarkDotNet.Artifacts/results/* ./performanceResults
- name: Run performance tests
run: |
dotnet run -c Release
working-directory: ./performance/benchmark
- name: Publish benchmark results
uses: actions/upload-artifact@v7
with:
if-no-files-found: error
name: benchmark-results
path: "${{ github.workspace }}/performance/benchmark/BenchmarkDotNet.Artifacts/results"
- name: Run comparison tool for empty models
run: dotnet run -c Release --project ./performance/resultsComparer/resultsComparer.csproj -- compare $OLD_REPORT $NEW_REPORT -p IdenticalMemoryUsage
shell: bash
env:
NEW_REPORT: "${{ github.workspace }}/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.EmptyModels-report.json"
OLD_REPORT: "${{ github.workspace }}/performanceResults/performance.EmptyModels-report.json"
- name: Run comparison tool for descriptions
run: dotnet run -c Release --project ./performance/resultsComparer/resultsComparer.csproj -- compare $OLD_REPORT $NEW_REPORT -p ZeroPointTwoPercentDifferenceMemoryUsage
shell: bash
env:
NEW_REPORT: "${{ github.workspace }}/performance/benchmark/BenchmarkDotNet.Artifacts/results/performance.Descriptions-report.json"
OLD_REPORT: "${{ github.workspace }}/performanceResults/performance.Descriptions-report.json"