Skip to content

Commit d862172

Browse files
committed
Fix ci
1 parent f69dab4 commit d862172

4 files changed

Lines changed: 201 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
path: '**/test-results.trx'
5757

5858
pack:
59-
name: Pack NuGet Package
59+
name: Pack NuGet Packages
6060
runs-on: ubuntu-latest
6161
needs: build
6262

@@ -74,13 +74,19 @@ jobs:
7474
- name: Restore dependencies
7575
run: dotnet restore
7676

77-
- name: Pack
77+
- name: Pack Analyzer
7878
run: dotnet pack src/ThrowsAnalyzer/ThrowsAnalyzer.csproj --configuration Release --no-restore --output ./artifacts
7979

80+
- name: Pack CLI Tool
81+
run: dotnet pack src/ThrowsAnalyzer.Cli/ThrowsAnalyzer.Cli.csproj --configuration Release --no-restore --output ./artifacts
82+
83+
- name: List artifacts
84+
run: ls -lh ./artifacts
85+
8086
- name: Upload artifacts
8187
uses: actions/upload-artifact@v4
8288
with:
83-
name: nuget-package
89+
name: nuget-packages
8490
path: ./artifacts/*.nupkg
8591
retention-days: 7
8692

@@ -111,4 +117,5 @@ jobs:
111117
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
112118
echo "✅ Build completed successfully" >> $GITHUB_STEP_SUMMARY
113119
echo "✅ All tests passed" >> $GITHUB_STEP_SUMMARY
114-
echo "✅ NuGet package created" >> $GITHUB_STEP_SUMMARY
120+
echo "✅ Analyzer package created" >> $GITHUB_STEP_SUMMARY
121+
echo "✅ CLI tool package created" >> $GITHUB_STEP_SUMMARY

.github/workflows/release.yml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,39 @@ jobs:
6161
- name: Test
6262
run: dotnet test --configuration Release --no-build --verbosity normal
6363

64-
- name: Pack
64+
- name: Pack Analyzer
6565
run: dotnet pack src/ThrowsAnalyzer/ThrowsAnalyzer.csproj --configuration Release --no-build --output ./artifacts
6666

67+
- name: Pack CLI Tool
68+
run: dotnet pack src/ThrowsAnalyzer.Cli/ThrowsAnalyzer.Cli.csproj --configuration Release --no-build --output ./artifacts
69+
6770
- name: List artifacts
6871
run: ls -la ./artifacts
6972

70-
- name: Push to NuGet
73+
- name: Push Analyzer to NuGet
74+
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-')
75+
run: |
76+
for file in ./artifacts/ThrowsAnalyzer.*.nupkg; do
77+
[[ $file != *"Cli"* ]] && dotnet nuget push "$file" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate || true
78+
done
79+
continue-on-error: false
80+
81+
- name: Push CLI Tool to NuGet
7182
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-')
72-
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
83+
run: dotnet nuget push ./artifacts/ThrowsAnalyzer.Cli.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
84+
continue-on-error: false
85+
86+
- name: Push Analyzer to NuGet (Pre-release)
87+
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-')
88+
run: |
89+
for file in ./artifacts/ThrowsAnalyzer.*.nupkg; do
90+
[[ $file != *"Cli"* ]] && dotnet nuget push "$file" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate || true
91+
done
7392
continue-on-error: false
7493

75-
- name: Push to NuGet (Pre-release)
94+
- name: Push CLI Tool to NuGet (Pre-release)
7695
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-')
77-
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
96+
run: dotnet nuget push ./artifacts/ThrowsAnalyzer.Cli.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
7897
continue-on-error: false
7998

8099
- name: Create GitHub Release
@@ -93,5 +112,15 @@ jobs:
93112
echo "📦 Version: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
94113
echo "✅ Build completed successfully" >> $GITHUB_STEP_SUMMARY
95114
echo "✅ All tests passed" >> $GITHUB_STEP_SUMMARY
96-
echo "✅ NuGet package published" >> $GITHUB_STEP_SUMMARY
115+
echo "✅ Analyzer package published to NuGet" >> $GITHUB_STEP_SUMMARY
116+
echo "✅ CLI tool package published to NuGet" >> $GITHUB_STEP_SUMMARY
97117
echo "✅ GitHub release created" >> $GITHUB_STEP_SUMMARY
118+
echo "" >> $GITHUB_STEP_SUMMARY
119+
echo "### Installation" >> $GITHUB_STEP_SUMMARY
120+
echo '```bash' >> $GITHUB_STEP_SUMMARY
121+
echo "# Analyzer" >> $GITHUB_STEP_SUMMARY
122+
echo "dotnet add package ThrowsAnalyzer" >> $GITHUB_STEP_SUMMARY
123+
echo "" >> $GITHUB_STEP_SUMMARY
124+
echo "# CLI Tool" >> $GITHUB_STEP_SUMMARY
125+
echo "dotnet tool install --global ThrowsAnalyzer.Cli" >> $GITHUB_STEP_SUMMARY
126+
echo '```' >> $GITHUB_STEP_SUMMARY
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# ThrowsAnalyzer CLI Tool
2+
3+
Command-line tool for analyzing C# projects and solutions for exception handling diagnostics using ThrowsAnalyzer.
4+
5+
## Installation
6+
7+
```bash
8+
dotnet tool install --global ThrowsAnalyzer.Cli
9+
```
10+
11+
## Quick Start
12+
13+
```bash
14+
# Analyze a project
15+
throws-analyzer analyze MyProject.csproj
16+
17+
# Analyze a solution
18+
throws-analyzer analyze MySolution.sln
19+
20+
# Generate reports with verbose output
21+
throws-analyzer analyze MyProject.csproj --verbose --open
22+
```
23+
24+
## Features
25+
26+
- **Comprehensive Analysis**: Runs all 30 ThrowsAnalyzer diagnostics on your codebase
27+
- **Dual Report Format**: Generates both HTML and Markdown reports
28+
- **Interactive HTML Reports**: Sortable tables, color-coded severity, code snippets
29+
- **Markdown Reports**: GitHub-compatible documentation format
30+
- **Statistics Dashboard**: Diagnostics by ID, project, severity, and file
31+
- **Flexible Filtering**: Filter by diagnostic IDs, projects, severity levels
32+
- **CI/CD Ready**: Exit codes and report formats suitable for automation
33+
34+
## Usage
35+
36+
```bash
37+
throws-analyzer analyze <path> [options]
38+
```
39+
40+
### Common Options
41+
42+
| Option | Description | Default |
43+
|--------|-------------|---------|
44+
| `-c, --configuration` | Build configuration (Debug/Release) | `Debug` |
45+
| `-s, --min-severity` | Minimum severity (Error/Warning/Info) | `Info` |
46+
| `-o, --output` | Output directory for reports | `./reports` |
47+
| `-f, --format` | Report format (html/markdown/both) | `both` |
48+
| `-v, --verbose` | Show verbose output | `false` |
49+
| `--open` | Open report after generation | `false` |
50+
51+
### Examples
52+
53+
```bash
54+
# Analyze with Release configuration
55+
throws-analyzer analyze MySolution.sln -c Release
56+
57+
# Only show warnings and errors
58+
throws-analyzer analyze MyProject.csproj -s Warning
59+
60+
# Custom output directory
61+
throws-analyzer analyze MySolution.sln -o ./build/reports
62+
63+
# HTML report only
64+
throws-analyzer analyze MyProject.csproj -f html --open
65+
66+
# Filter specific diagnostics
67+
throws-analyzer analyze MySolution.sln -d THROWS004 THROWS021 THROWS026
68+
69+
# Analyze specific projects
70+
throws-analyzer analyze MySolution.sln -p MyProject.Core MyProject.Api
71+
```
72+
73+
## Report Output
74+
75+
The tool generates comprehensive reports in `./reports/` by default:
76+
77+
- **`analysis-report.html`** - Interactive HTML report with sortable tables
78+
- **`analysis-report.md`** - Markdown report for documentation
79+
80+
### Report Contents
81+
82+
- Summary statistics (total diagnostics, by severity)
83+
- Diagnostics breakdown by ID, project, file
84+
- Top files with most diagnostics
85+
- Detailed diagnostics with code snippets
86+
- Color-coded severity indicators
87+
88+
## CI/CD Integration
89+
90+
### GitHub Actions
91+
92+
```yaml
93+
- name: Install ThrowsAnalyzer CLI
94+
run: dotnet tool install --global ThrowsAnalyzer.Cli
95+
96+
- name: Run Analysis
97+
run: throws-analyzer analyze MySolution.sln -c Release -o ./reports
98+
99+
- name: Upload Reports
100+
uses: actions/upload-artifact@v3
101+
with:
102+
name: throws-analyzer-reports
103+
path: ./reports/
104+
```
105+
106+
### Exit Codes
107+
108+
- `0` - Analysis completed successfully
109+
- `1` - Analysis failed
110+
- `2` - Invalid arguments
111+
112+
## Documentation
113+
114+
For complete documentation, see:
115+
- [CLI Tool Guide](https://github.com/wieslawsoltes/ThrowsAnalyzer/blob/main/docs/CLI_TOOL.md)
116+
- [Configuration Guide](https://github.com/wieslawsoltes/ThrowsAnalyzer/blob/main/docs/CONFIGURATION_GUIDE.md)
117+
- [Main Repository](https://github.com/wieslawsoltes/ThrowsAnalyzer)
118+
119+
## ThrowsAnalyzer
120+
121+
The CLI tool uses [ThrowsAnalyzer](https://www.nuget.org/packages/ThrowsAnalyzer), a Roslyn analyzer with **30 diagnostic rules** for exception handling:
122+
123+
- Basic Exception Handling (8 rules)
124+
- Exception Flow Analysis (3 rules)
125+
- Async Exception Patterns (3 rules)
126+
- Iterator Exception Patterns (2 rules)
127+
- Lambda Exception Patterns (2 rules)
128+
- Best Practices (4 rules)
129+
130+
Install the analyzer directly in your projects:
131+
132+
```bash
133+
dotnet add package ThrowsAnalyzer
134+
```
135+
136+
## License
137+
138+
MIT License - Copyright © 2025 Wiesław Šoltés
139+
140+
## Support
141+
142+
- GitHub Issues: https://github.com/wieslawsoltes/ThrowsAnalyzer/issues
143+
- Documentation: https://github.com/wieslawsoltes/ThrowsAnalyzer/tree/main/docs

src/ThrowsAnalyzer.Cli/ThrowsAnalyzer.Cli.csproj

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,25 @@
1111
<!-- CLI Tool Configuration -->
1212
<PackAsTool>true</PackAsTool>
1313
<ToolCommandName>throws-analyzer</ToolCommandName>
14+
<PackageId>ThrowsAnalyzer.Cli</PackageId>
1415
<PackageOutputPath>./nupkg</PackageOutputPath>
15-
<Description>Command-line tool to run ThrowsAnalyzer and generate reports</Description>
16+
<Title>ThrowsAnalyzer CLI - Exception Analysis Tool</Title>
17+
<Description>Command-line tool for running ThrowsAnalyzer on projects and solutions, generating comprehensive HTML and Markdown reports with exception handling diagnostics, statistics, and code snippets.</Description>
18+
<PackageTags>roslyn;analyzer;cli;tool;exceptions;throw;try-catch;diagnostic;reports;code-quality;static-analysis</PackageTags>
1619
<Authors>Wiesław Šoltés</Authors>
20+
<Copyright>Copyright © 2025 Wiesław Šoltés</Copyright>
1721
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1822
<PackageProjectUrl>https://github.com/wieslawsoltes/ThrowsAnalyzer</PackageProjectUrl>
1923
<RepositoryUrl>https://github.com/wieslawsoltes/ThrowsAnalyzer</RepositoryUrl>
24+
<RepositoryType>git</RepositoryType>
25+
<PackageReadmeFile>CLI_README.md</PackageReadmeFile>
26+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
2027
</PropertyGroup>
2128

29+
<ItemGroup>
30+
<None Include="CLI_README.md" Pack="true" PackagePath="\" />
31+
</ItemGroup>
32+
2233
<ItemGroup>
2334
<!-- Roslyn Workspaces for loading solutions/projects -->
2435
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.12.0" />

0 commit comments

Comments
 (0)