Repository navigation
156 lines (129 loc) · 4.27 KB
/
Copy pathci.yml
File metadata and controls
156 lines (129 loc) · 4.27 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
147
148
149
150
151
152
153
154
155
156
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
SOLUTION: CSharp_FindRomCover.sln
jobs:
build-and-test:
name: Build and test (Windows)
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'
cache: true
cache-dependency-path: '**/*.csproj'
- name: Restore
run: dotnet restore ${{ env.SOLUTION }}
- name: Build
run: dotnet build ${{ env.SOLUTION }} --configuration Release --no-restore -warnaserror
- name: Test
run: >
dotnet test ${{ env.SOLUTION }} --configuration Release --no-build
--collect:"XPlat Code Coverage"
--results-directory TestResults
--logger "trx;LogFileName=test-results.trx"
--verbosity normal
- name: Write coverage summary
if: always()
shell: pwsh
run: |
$coverageFile = Get-ChildItem -Path 'TestResults' -Filter 'coverage.cobertura.xml' -Recurse -ErrorAction SilentlyContinue |
Select-Object -First 1
if (-not $coverageFile) {
Write-Host 'No coverage report was produced, skipping the summary.'
exit 0
}
[xml]$coverage = Get-Content -LiteralPath $coverageFile.FullName
$root = $coverage.coverage
$lineRate = [math]::Round([double]$root.'line-rate' * 100, 2)
$branchRate = [math]::Round([double]$root.'branch-rate' * 100, 2)
@(
'## Code coverage'
''
'| Metric | Covered | Total | Rate |'
'|--------|---------|-------|------|'
"| Lines | $($root.'lines-covered') | $($root.'lines-valid') | $lineRate% |"
"| Branches | $($root.'branches-covered') | $($root.'branches-valid') | $branchRate% |"
''
'The full Cobertura report is attached to this run as the `test-results` artifact.'
) | Add-Content -Path $env:GITHUB_STEP_SUMMARY
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results
path: |
TestResults/**/*.trx
TestResults/**/coverage.cobertura.xml
if-no-files-found: warn
retention-days: 14
build-cross-platform:
name: Build app (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'
cache: true
cache-dependency-path: '**/*.csproj'
- name: Restore application
run: dotnet restore FindRomCover/FindRomCover.csproj
- name: Build application
run: dotnet build FindRomCover/FindRomCover.csproj --configuration Release --no-restore -warnaserror
format:
name: Formatting and analyzers
runs-on: windows-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'
cache: true
cache-dependency-path: '**/*.csproj'
- name: Restore
run: dotnet restore ${{ env.SOLUTION }}
- name: Verify formatting, style, and analyzers
run: dotnet format ${{ env.SOLUTION }} --verify-no-changes --no-restore --verbosity minimal
dependency-review:
name: Dependency review
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Review dependency changes
uses: actions/dependency-review-action@v5.0.0
with:
fail-on-severity: high
comment-summary-in-pr: on-failure