-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (123 loc) · 4.39 KB
/
Copy pathci.yml
File metadata and controls
141 lines (123 loc) · 4.39 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
name: CI
on:
push:
branches: [main, 'feature/**']
paths-ignore:
- 'Documentations/**'
- '*.md'
- '.github/dependabot.yml'
pull_request:
branches: [main]
paths-ignore:
- 'Documentations/**'
- '*.md'
# Cancel in-progress runs on the same branch/PR to avoid wasting runner minutes.
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
pull-requests: write # for sticky coverage comment
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
jobs:
build-and-test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET from global.json
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Display .NET SDK info
run: dotnet --info
- name: Cache NuGet packages
uses: actions/cache@v6
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('global.json', '**/*.csproj', '**/*.slnx') }}
restore-keys: nuget-${{ runner.os }}-
- name: Restore dependencies
run: dotnet restore CaeriusNet.slnx
- name: Build (Release)
run: |
dotnet build CaeriusNet.slnx \
--configuration Release \
--no-restore \
-p:TreatWarningsAsErrors=true
- name: Validate NuGet package
shell: pwsh
run: ./.github/scripts/ValidatePackage.ps1 -Configuration Release -OutputDirectory "${{ runner.temp }}/caerius-package-validation"
- name: Run tests with coverage
run: |
dotnet test CaeriusNet.slnx \
--configuration Release \
--no-restore \
--no-build \
--filter "FullyQualifiedName!~IntegrationTests" \
--collect:"XPlat Code Coverage" \
--results-directory ./coverage \
--logger "trx;LogFileName=test-results.trx" \
--logger "console;verbosity=normal" \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
- name: Upload coverage reports
uses: actions/upload-artifact@v5
if: always()
with:
name: coverage-reports
path: ./coverage/**/coverage.cobertura.xml
retention-days: 14
- name: Upload test results
uses: actions/upload-artifact@v5
if: always()
with:
name: test-results
path: ./coverage/**/*.trx
retention-days: 14
- name: Generate coverage summary (markdown)
if: always()
run: |
dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.* >/dev/null 2>&1 || \
dotnet tool update --global dotnet-reportgenerator-globaltool --version 5.* >/dev/null 2>&1 || true
export PATH="$PATH:$HOME/.dotnet/tools"
reportgenerator \
-reports:"./coverage/**/coverage.cobertura.xml" \
-targetdir:./coverage/report \
-reporttypes:"MarkdownSummaryGithub;HtmlInline_AzurePipelines;Cobertura" \
-filefilters:"-**/obj/**;-**/bin/**" \
-classfilters:"-CaeriusNet.Generator*;-*Tests*"
if [ -f ./coverage/report/SummaryGithub.md ]; then
{
echo "## 📊 Coverage summary"
echo
cat ./coverage/report/SummaryGithub.md
} >> "$GITHUB_STEP_SUMMARY"
fi
- name: Upload HTML coverage report
if: always()
uses: actions/upload-artifact@v5
with:
name: coverage-html
path: ./coverage/report/**
retention-days: 14
- name: Sticky PR coverage comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v3
with:
header: caeriusnet-coverage
path: ./coverage/report/SummaryGithub.md
recreate: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v6
if: success()
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/**/coverage.cobertura.xml
flags: unittests
name: caeriusnet-coverage
fail_ci_if_error: false