-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
234 lines (200 loc) · 7.02 KB
/
Taskfile.yml
File metadata and controls
234 lines (200 loc) · 7.02 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
version: "3"
# Taskfile for DotNetApiDiff project
# https://taskfile.dev
vars:
SOLUTION: DotNetApiDiff.sln
PROJECT: src/DotNetApiDiff/DotNetApiDiff.csproj
TEST_PROJECT: tests/DotNetApiDiff.Tests/DotNetApiDiff.Tests.csproj
TEST_ASSEMBLIES_DIR: tests/TestAssemblies
COVERAGE_DIR: coverage-report
TEST_REPORT_DIR: test-report
tasks:
default:
desc: Lists all available tasks
cmds:
- task --list
build:
desc: Build the solution
cmds:
- dotnet build {{.SOLUTION}} --configuration Release
build:test-assemblies:
desc: Build test assemblies and copy to TestData
cmds:
- cd {{.TEST_ASSEMBLIES_DIR}} && ./build-test-assemblies.sh
clean:test-assemblies:
desc: Clean test assemblies build outputs
cmds:
- dotnet clean {{.TEST_ASSEMBLIES_DIR}}/TestAssemblyV1.csproj
- dotnet clean {{.TEST_ASSEMBLIES_DIR}}/TestAssemblyV2.csproj
- rm -f tests/DotNetApiDiff.Tests/TestData/TestAssemblyV1.dll
- rm -f tests/DotNetApiDiff.Tests/TestData/TestAssemblyV2.dll
clean:
desc: Clean build outputs
cmds:
- dotnet clean {{.SOLUTION}}
- task: clean:coverage
- task: clean:test-assemblies
clean:coverage:
desc: Clean coverage reports
cmds:
- npx rimraf {{.COVERAGE_DIR}}
restore:
desc: Restore NuGet packages
cmds:
- dotnet restore {{.SOLUTION}}
test:
desc: Run all tests
cmds:
- dotnet test {{.SOLUTION}} --configuration Release
test:unit:
desc: Run unit tests only
cmds:
- dotnet test {{.TEST_PROJECT}} --filter "Category=Unit" --configuration Release
test:integration:
desc: Run integration tests only
deps: [build:test-assemblies]
cmds:
- dotnet test {{.TEST_PROJECT}} --filter "Category=Integration" --configuration Release
test:report:
desc: Run tests with detailed HTML report
cmds:
- mkdir -p {{.TEST_REPORT_DIR}}
- dotnet test {{.TEST_PROJECT}} --results-directory {{.TEST_REPORT_DIR}} --logger "html;LogFileName=test-results.html"
- echo "Test report generated in {{.TEST_REPORT_DIR}}/test-results.html"
ensure-test-report:
desc: Ensure test report exists
internal: true
cmds:
- |
if [ ! -f "{{.TEST_REPORT_DIR}}/test-results.html" ]; then
echo "Test report not found. Generating it now..."
task test:report
fi
test:report:view:
desc: Open test report in default browser (generates report if it doesn't exist)
cmds:
- task: ensure-test-report
- |
{{if eq OS "windows"}}
cmd.exe /c start {{.TEST_REPORT_DIR}}/test-results.html
{{else if eq OS "darwin"}}
open {{.TEST_REPORT_DIR}}/test-results.html
{{else}}
xdg-open {{.TEST_REPORT_DIR}}/test-results.html
{{end}}
test:watch:
desc: Run tests in watch mode (rerun on file changes)
cmds:
- dotnet watch test --project {{.TEST_PROJECT}}
coverage:
desc: Generate code coverage report
cmds:
- dotnet test {{.TEST_PROJECT}} /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./coverage.info
- mkdir -p {{.COVERAGE_DIR}}
- task: coverage:report
coverage:report:
desc: Generate HTML report from coverage data
cmds:
- dotnet tool restore
- dotnet reportgenerator -reports:tests/DotNetApiDiff.Tests/coverage.info -targetdir:{{.COVERAGE_DIR}} -reporttypes:Html
coverage:report:detailed:
desc: Generate detailed HTML report with multiple formats
cmds:
- dotnet tool restore
- dotnet reportgenerator -reports:tests/DotNetApiDiff.Tests/coverage.info -targetdir:{{.COVERAGE_DIR}} -reporttypes:"Html;HtmlSummary;Cobertura;TextSummary"
- echo "Coverage report generated in {{.COVERAGE_DIR}}"
- cat {{.COVERAGE_DIR}}/Summary.txt
ensure-coverage-report:
desc: Ensure coverage report exists
internal: true
cmds:
- |
if [ ! -f "{{.COVERAGE_DIR}}/index.html" ]; then
echo "Coverage report not found. Generating it now..."
task coverage
fi
coverage:view:
desc: Open coverage report in default browser (generates report if it doesn't exist)
cmds:
- task: ensure-coverage-report
- |
{{if eq OS "windows"}}
cmd.exe /c start {{.COVERAGE_DIR}}/index.html
{{else if eq OS "darwin"}}
open {{.COVERAGE_DIR}}/index.html
{{else}}
xdg-open {{.COVERAGE_DIR}}/index.html
{{end}}
tools:install:
desc: Install required dotnet tools
cmds:
- dotnet new tool-manifest --force || true
- dotnet tool install dotnet-reportgenerator-globaltool --ignore-failed-sources --version 5.2.0
- dotnet tool install dotnet-format --ignore-failed-sources
- dotnet tool install dotnet-outdated-tool --ignore-failed-sources
tools:restore:
desc: Restore dotnet tools
cmds:
- dotnet tool restore
deps:install:
desc: Install npm dependencies
cmds:
- npm install
run:
desc: Run the application
cmds:
- dotnet run --project {{.PROJECT}} -- {{.CLI_ARGS}}
publish:
desc: Publish the application
cmds:
- dotnet publish {{.PROJECT}} -c Release -o ./publish
code:format:
desc: Format code using dotnet-format
cmds:
- dotnet tool restore
- dotnet format
code:format:verify:
desc: Verify code formatting without making changes
cmds:
- dotnet tool restore
- dotnet format --verify-no-changes
code:analyze:
desc: Run code analysis with analyzers
cmds:
- dotnet build {{.SOLUTION}} --no-restore /p:EnforceCodeStyleInBuild=true /p:EnableNETAnalyzers=true /p:AnalysisLevel=latest /p:TreatWarningsAsErrors=true
code:outdated:
desc: Check for outdated NuGet packages
cmds:
- dotnet tool restore
- dotnet outdated --version-lock Major
code:analyzers:install:
desc: Install code analyzers to projects
cmds:
- dotnet add src/DotNetApiDiff/DotNetApiDiff.csproj package Microsoft.CodeAnalysis.NetAnalyzers
- dotnet add src/DotNetApiDiff/DotNetApiDiff.csproj package StyleCop.Analyzers
- dotnet add tests/DotNetApiDiff.Tests/DotNetApiDiff.Tests.csproj package Microsoft.CodeAnalysis.NetAnalyzers
code:quality:
desc: Run all code quality checks
cmds:
- task: code:format:verify
- task: code:analyze
- task: code:outdated
code:fix:stylecop:
desc: Run StyleCop fix scripts
cmds:
- powershell -ExecutionPolicy Bypass -File ./scripts/Fix-SA1513.ps1
- powershell -ExecutionPolicy Bypass -File ./scripts/Fix-ConstructorInitializers.ps1
- powershell -ExecutionPolicy Bypass -File ./scripts/Fix-ParameterFormatting.ps1
- powershell -ExecutionPolicy Bypass -File ./scripts/Fix-TrailingCommas.ps1
- powershell -ExecutionPolicy Bypass -File ./scripts/Add-FinalNewlines.ps1
ci:
desc: Run CI build and test sequence
cmds:
- task: deps:install
- task: clean
- task: restore
- task: code:quality
- task: build
- task: build:test-assemblies
- task: test
- task: coverage