forked from mkaring/ConfuserEx
-
Notifications
You must be signed in to change notification settings - Fork 4
145 lines (123 loc) · 5.1 KB
/
Copy pathlint.yml
File metadata and controls
145 lines (123 loc) · 5.1 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
name: lint
on:
push:
paths-ignore: ['**.md', 'docs/**', 'LICENSE*']
pull_request:
branches: [main, develop]
paths-ignore: ['**.md', 'docs/**', 'LICENSE*']
concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: windows-2025
timeout-minutes: 5
permissions:
contents: read
pull-requests: write
issues: write
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- uses: actions/checkout@v5
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.vcxproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore
run: dotnet restore Confuser2.sln
- name: Check whitespace
id: whitespace
run: dotnet format whitespace Confuser2.sln --verify-no-changes --verbosity minimal 2>&1 | Tee-Object -Variable wsOutput
shell: pwsh
continue-on-error: true
- name: Check style
id: style
run: dotnet format style Confuser2.sln --verify-no-changes --severity warn 2>&1 | Tee-Object -Variable styleOutput
shell: pwsh
continue-on-error: true
- name: Check analyzers
id: analyzers
run: dotnet format analyzers Confuser2.sln --verify-no-changes --severity warn 2>&1 | Tee-Object -Variable analyzerOutput
shell: pwsh
continue-on-error: true
- name: Build lint report
if: always()
id: report
shell: pwsh
run: |
$ws = '${{ steps.whitespace.outcome }}'
$st = '${{ steps.style.outcome }}'
$an = '${{ steps.analyzers.outcome }}'
$anyFailed = ($ws -eq 'failure') -or ($st -eq 'failure') -or ($an -eq 'failure')
$md = @()
$md += '## Lint Results'
$md += ''
if (-not $anyFailed) {
$md += '> :white_check_mark: **All checks passed**'
} else {
$md += '> :warning: **Issues found** — run `dotnet format Confuser2.sln` locally to fix'
}
$md += ''
$md += '| Check | Result |'
$md += '|-------|--------|'
$icon = if ($ws -eq 'success') { ':white_check_mark:' } else { ':x:' }
$md += "| Whitespace (indentation, line endings) | $icon |"
$icon = if ($st -eq 'success') { ':white_check_mark:' } else { ':x:' }
$md += "| Style (IDE rules, naming, var usage) | $icon |"
$icon = if ($an -eq 'success') { ':white_check_mark:' } else { ':x:' }
$md += "| Analyzers (CA*, RCS* rules) | $icon |"
# Get specific violations if any failed
if ($anyFailed) {
$md += ''
$md += '<details><summary><strong>Details (click to expand)</strong></summary>'
$md += ''
$md += '```'
# Re-run to capture output
$violations = dotnet format Confuser2.sln --verify-no-changes --verbosity diagnostic 2>&1 | Select-String 'error|warning' | Select-Object -First 30
foreach ($v in $violations) { $md += $v.ToString().Trim() }
if ($violations.Count -ge 30) { $md += '... (truncated, run dotnet format locally for full list)' }
$md += '```'
$md += ''
$md += '</details>'
}
$md -join "`n" | Set-Content -Path 'lint-report.md' -Encoding utf8
$md -join "`n" >> $env:GITHUB_STEP_SUMMARY
echo "any_failed=$anyFailed" >> $env:GITHUB_OUTPUT
- name: Post PR comment
if: always() && github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: lint-report
path: lint-report.md
- name: Post issue comment
if: always() && github.event_name == 'push' && github.event.pull_request == null
shell: pwsh
run: |
# Extract issue number from branch name (e.g. 54-nuget-packages → 54)
$branch = "${{ github.ref_name }}"
if ($branch -match '^(\d+)-') {
$issueNumber = $Matches[1]
$marker = '<!-- lint-bot -->'
$body = $marker + "`n" + (Get-Content 'lint-report.md' -Raw)
# Find existing lint comment
$comments = gh api "repos/${{ github.repository }}/issues/$issueNumber/comments" --jq '.[] | select(.body | startswith("<!-- lint-bot -->")) | .id' 2>$null
if ($comments) {
# Update existing
gh api "repos/${{ github.repository }}/issues/comments/$comments" -X PATCH -f body="$body" 2>$null
} else {
# Create new
gh issue comment $issueNumber --repo ${{ github.repository }} --body "$body" 2>$null
}
}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fail if issues found
if: always() && steps.report.outputs.any_failed == 'True'
shell: pwsh
run: |
Write-Host "::warning::Lint issues found. Run 'dotnet format Confuser2.sln' locally to fix."
exit 1