-
Notifications
You must be signed in to change notification settings - Fork 8
196 lines (158 loc) · 6.62 KB
/
Copy pathpr-validation.yml
File metadata and controls
196 lines (158 loc) · 6.62 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
name: Pull Request Validation
on:
pull_request:
branches: [ main, develop ]
types: [opened, synchronize, reopened]
env:
DOTNET_VERSION: '10.0.x'
SOLUTION_PATH: 'Source/Current/Windows API CodePack/Windows API CodePack.sln'
jobs:
validate-changes:
name: Validate Changes
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.3
- name: Restore dependencies
run: |
dotnet restore "${{ env.SOLUTION_PATH }}" --verbosity normal
working-directory: .
- name: Build solution
run: |
dotnet build "${{ env.SOLUTION_PATH }}" --configuration Release --no-restore --verbosity normal
working-directory: .
- name: Build C++ DirectX project
run: |
msbuild "Source/Current/Windows API CodePack/Components/DirectX/DirectX.vcxproj" /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v143 /verbosity:normal
working-directory: .
- name: Run code analysis
run: |
dotnet build "${{ env.SOLUTION_PATH }}" --configuration Release --no-restore --verbosity normal --property:RunAnalyzersDuringBuild=true
working-directory: .
continue-on-error: true
- name: Check for breaking changes
run: |
Write-Host "Checking for potential breaking changes..."
$changedFiles = git diff --name-only origin/${{ github.base_ref }}...HEAD
$breakingChangeFiles = $changedFiles | Where-Object { $_ -match '\.cs$' -and ($_ -match 'public|protected' -or $_ -match 'interface|class') }
if ($breakingChangeFiles) {
Write-Host "⚠️ Potential breaking changes detected in:"
$breakingChangeFiles | ForEach-Object { Write-Host " - $_" }
Write-Host "Please review these changes carefully."
} else {
Write-Host "✅ No obvious breaking changes detected."
}
shell: pwsh
continue-on-error: true
security-check:
name: Security Check
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Check for vulnerable packages
run: |
dotnet list "${{ env.SOLUTION_PATH }}" package --vulnerable --include-transitive
working-directory: .
continue-on-error: true
- name: Check for outdated packages
run: |
dotnet list "${{ env.SOLUTION_PATH }}" package --outdated
working-directory: .
continue-on-error: true
package-validation:
name: Package Validation
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: |
dotnet restore "${{ env.SOLUTION_PATH }}" --verbosity normal
working-directory: .
- name: Build solution
run: |
dotnet build "${{ env.SOLUTION_PATH }}" --configuration Release --no-restore --verbosity normal
working-directory: .
- name: Pack packages
run: |
dotnet pack "${{ env.SOLUTION_PATH }}" --configuration Release --no-build --verbosity normal --output ./packages
working-directory: .
- name: Validate package metadata
run: |
$packages = Get-ChildItem -Path "./packages" -Filter "*.nupkg" | Where-Object { $_.Name -notlike "*symbols*" }
foreach ($package in $packages) {
Write-Host "Validating package: $($package.Name)"
# Extract package info
$packageInfo = dotnet nuget locals temp --list | Select-String "temp"
if ($packageInfo) {
$tempPath = $packageInfo.ToString().Split(':')[1].Trim()
$extractPath = Join-Path $tempPath "extract_$($package.BaseName)"
# Create extraction directory
New-Item -ItemType Directory -Path $extractPath -Force | Out-Null
# Extract package
Expand-Archive -Path $package.FullName -DestinationPath $extractPath -Force
# Check for required files
$nuspecFile = Get-ChildItem -Path $extractPath -Filter "*.nuspec" -Recurse
if ($nuspecFile) {
Write-Host "✅ Package $($package.Name) has valid nuspec file"
# Read nuspec content
[xml]$nuspec = Get-Content $nuspecFile.FullName
$metadata = $nuspec.package.metadata
# Validate required metadata
$requiredFields = @('id', 'version', 'description', 'authors')
foreach ($field in $requiredFields) {
if ($metadata.$field) {
Write-Host "✅ $field: $($metadata.$field)"
} else {
Write-Warning "⚠️ Missing required field: $field"
}
}
} else {
Write-Error "❌ Package $($package.Name) is missing nuspec file"
}
# Cleanup
Remove-Item -Path $extractPath -Recurse -Force
}
}
shell: pwsh
continue-on-error: true
pr-summary:
name: PR Summary
runs-on: windows-latest
needs: [validate-changes, security-check, package-validation]
if: always()
steps:
- name: Generate PR Summary
run: |
$summary = @"
## Pull Request Validation Summary
### Build Status
- **Build Validation**: ${{ needs.validate-changes.result == 'success' && '✅ Passed' || '❌ Failed' }}
- **Security Check**: ${{ needs.security-check.result == 'success' && '✅ Passed' || '⚠️ Warnings' }}
- **Package Validation**: ${{ needs.package-validation.result == 'success' && '✅ Passed' || '⚠️ Warnings' }}
### Next Steps
"@
if (${{ needs.validate-changes.result }} -eq 'success' -and ${{ needs.security-check.result }} -eq 'success' -and ${{ needs.package-validation.result }} -eq 'success') {
$summary += "✅ All validations passed! This PR is ready for review."
} else {
$summary += "⚠️ Some validations had issues. Please review the logs and address any problems."
}
Write-Host $summary
shell: pwsh