-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (63 loc) · 3.29 KB
/
Copy pathci.yml
File metadata and controls
79 lines (63 loc) · 3.29 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
# Source: verified against docs.github.com/actions/tutorials/build-and-test-code/net
# and github.com/actions/runner-images/issues/13789 (MSBuild pinning)
name: CI
on:
push:
branches: [ main ]
pull_request:
jobs:
build:
runs-on: windows-latest
timeout-minutes: 30
permissions:
contents: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup .NET 10
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
with:
dotnet-version: '10.0.1xx'
- name: Restore dependencies
run: dotnet restore src/GsdOrchestrator/GsdOrchestrator.csproj
- name: Build
run: dotnet build src/GsdOrchestrator/GsdOrchestrator.csproj --no-restore --configuration Release
- name: Restore test dependencies
run: dotnet restore src/GsdOrchestrator.Tests/GsdOrchestrator.Tests.csproj
- name: Build tests
run: dotnet build src/GsdOrchestrator.Tests/GsdOrchestrator.Tests.csproj --no-restore --configuration Release
- name: Contract compatibility (pinned cas-contracts v1.1)
# Consumer-side gate: fails red if SdlcProfile.CasSdlcV1 or the vendored v1.1
# schema release drifts from the pinned cas-contracts contract. See
# src/GsdOrchestrator.Tests/ContractCompatibilityTests.cs.
run: dotnet test src/GsdOrchestrator.Tests/GsdOrchestrator.Tests.csproj --configuration Release --no-build --filter "FullyQualifiedName~ContractCompatibilityTests"
- name: Test
run: dotnet test src/GsdOrchestrator.Tests/GsdOrchestrator.Tests.csproj --configuration Release --logger trx --no-build --settings coverlet.runsettings --collect:"XPlat Code Coverage" --results-directory ./TestResults
- name: Upload coverage
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: coverage-results
path: TestResults/
- name: Enforce branch coverage (ratchet)
shell: pwsh
run: |
# Ratcheted branch-coverage gate (Phase 26-01). Reads branch-rate (NOT
# line-rate) from the cobertura report produced by coverlet's "XPlat
# Code Coverage" collector and fails if it regresses below the last
# measured baseline. Baseline is raised only when new tests push
# coverage strictly higher (see 26-01-SUMMARY.md for history).
$Baseline = 0.7314
$coverageFile = Get-ChildItem -Path TestResults -Recurse -Filter "coverage.cobertura.xml" | Select-Object -First 1
if (-not $coverageFile) {
Write-Output '{"event":"ci_failure","error":"Coverage file not found"}'
exit 1
}
[xml]$xml = Get-Content $coverageFile.FullName
$rate = [double]$xml.coverage.'branch-rate'
$percent = [math]::Round($rate * 100, 2)
$requiredPercent = [math]::Round($Baseline * 100, 2)
if ($rate -lt $Baseline) {
Write-Output "{`"event`":`"ci_failure`",`"metric`":`"branch-rate`",`"coverage_percent`":$percent,`"required`":$requiredPercent}"
exit 1
}
Write-Output "{`"event`":`"ci_success`",`"metric`":`"branch-rate`",`"coverage_percent`":$percent,`"required`":$requiredPercent}"