-
Notifications
You must be signed in to change notification settings - Fork 1
322 lines (276 loc) · 11 KB
/
Copy pathci-build-test.yml
File metadata and controls
322 lines (276 loc) · 11 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
name: 🚀 CI Build & Test
on:
push:
branches:
- "feature/*"
- "bug/*"
- "hotfix/*"
pull_request:
branches:
- "main"
types: [opened, synchronize, reopened, closed]
env:
DOTNET_VERSION: "10.0.x"
jobs:
# Build QRCoder.Core
build-qrcoder:
name: Build QRCoder.Core (.NET 10)
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v7.0.0
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5.4.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install SkiaSharp Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libfontconfig1 libfreetype6 libx11-6 libxext6 libxrender1 libxtst6
# Additional dependencies for .NET 10.0 SkiaSharp
sudo apt-get install -y libglib2.0-0 libgtk-3-0 libxss1 libasound2-dev
sudo apt install mesa-utils ttf-mscorefonts-installer dbus libfontconfig1 libxrandr2 libxi-dev
# Install SkiaSharp native dependencies manually
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev libdrm-dev libx11-xcb-dev libxcb1-dev libxkbcommon-dev libwayland-dev
- name: Setup SkiaSharp Environment
run: |
echo "Setting up SkiaSharp environment variables"
echo "LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "LIBGL_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri" >> $GITHUB_ENV
- name: Cache NuGet Packages
uses: actions/cache@v6
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore Dependencies
run: |
dotnet restore QRCoder.Core.sln
- name: Build Project
run: |
dotnet build QRCoder.Core.sln --configuration Release --no-restore
- name: Copy SkiaSharp Native Libraries
run: |
echo "Copying SkiaSharp native libraries to output directories"
# Find and copy libSkiaSharp.so to all test output directories
find ~/.nuget/packages -name "libSkiaSharp.so" -type f | while read file; do
echo "Found SkiaSharp library: $file"
# Copy to all framework output directories
for framework in netstandard2.1 net8.0 net10.0; do
target_dir="QRCoder.Core.Tests/bin/Release/$framework"
if [ -d "$target_dir" ]; then
cp "$file" "$target_dir/"
echo "Copied to $target_dir/"
fi
done
done
# Also try to copy from runtimes directory if available
find ~/.nuget/packages -path "*/runtimes/linux-x64/native/*" -name "*.so" -type f | while read file; do
echo "Found native library: $file"
for framework in netstandard2.1 net8.0 net10.0; do
target_dir="QRCoder.Core.Tests/bin/Release/$framework"
if [ -d "$target_dir" ]; then
cp "$file" "$target_dir/"
echo "Copied native library to $target_dir/"
fi
done
done
# List what we have in output directories
for framework in netstandard2.1 net8.0 net10.0; do
target_dir="QRCoder.Core.Tests/bin/Release/$framework"
if [ -d "$target_dir" ]; then
echo "=== Libraries in $target_dir ==="
ls -la "$target_dir/"*.so 2>/dev/null || echo "No .so files found"
fi
done
# Build and Test on Windows (.NET Framework)
build-windows:
name: Build QRCoder.Core (Windows)
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v7.0.0
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5.4.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet Packages
uses: actions/cache@v6
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore Dependencies
run: |
echo "Restoring NuGet packages for QRCoder.Core.sln"
dotnet restore QRCoder.Core.sln --no-cache --force --verbosity normal
- name: Build Solution
run: |
echo "Building QRCoder.Core.sln"
dotnet build QRCoder.Core.sln --no-restore --configuration Release --verbosity minimal
- name: Run .NET Framework Tests
run: |
echo "Running tests for .NET Framework 4.8"
dotnet test QRCoder.Core.Tests/ --configuration Release --logger "trx;LogFileName=test-results-net48.trx" --results-directory TestResults --framework net48 --verbosity normal
- name: Upload Windows Test Results
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results-windows
path: |
TestResults/**/*.trx
retention-days: 7
# Security & Quality Checks
security:
name: 🔒 Security & Quality
runs-on: ubuntu-latest
needs: [build-qrcoder, build-windows]
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v7.0.0
- name: 🔍 Security Scan (QRCoder.Core)
run: |
echo "🔒 Running security scan on QRCoder.Core"
dotnet list QRCoder.Core.sln package --vulnerable
- name: 📊 Code Quality Analysis
run: |
echo "📊 Analyzing code quality"
echo "✅ Security and quality checks completed"
# Performance Tests
performance:
name: ⚡ Performance Tests
runs-on: ubuntu-latest
needs: [build-qrcoder]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v7.0.0
- name: 🗄️ Setup .NET
uses: actions/setup-dotnet@v5.4.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: 🧪 Run Performance Tests
run: |
echo "⚡ Running performance tests"
# Add performance tests here if QRCoder.Core.Benchmarks exists
if [ -d "QRCoder.Core.Benchmarks" ]; then
dotnet run --project QRCoder.Core.Benchmarks --configuration Release
else
echo "No benchmark project found, skipping performance tests"
fi
echo "Performance tests completed successfully"
# Coverage Reports
coverage-reports:
name: 📊 Coverage Reports
runs-on: ubuntu-latest
needs: [build-qrcoder, build-windows]
if: always()
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v7.0.0
- name: 🗄️ Setup .NET
uses: actions/setup-dotnet@v5.4.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: 🔧 Restore dependencies
run: dotnet restore QRCoder.Core.sln --ignore-failed-sources
- name: 📦 Install ReportGenerator
run: dotnet tool install -g dotnet-reportgenerator-globaltool
- name: 🔧 Restore .NET local tools
run: dotnet tool restore
- name: 📊 Generate Coverage Report
run: |
echo "📊 Generating coverage report"
if [ -d "TestResults" ]; then
reportgenerator -reports:"TestResults/**/coverage.cobertura.xml" -targetdir:"TestResults/CoverageReport" -reporttypes:"Html;XmlSummary;TextSummary"
else
echo "No test results found, skipping coverage report generation"
fi
- name: 📊 Upload coverage reports to Codecov
uses: codecov/codecov-action@v7
with:
files: TestResults/CoverageReport/Summary.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: 📤 Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results-coverage
path: TestResults/
retention-days: 7
- name: 📤 Upload coverage report
uses: actions/upload-artifact@v7
if: always()
with:
name: coverage-report
path: TestResults/CoverageReport/
retention-days: 7
- name: 📊 Generate Coverage Summary
run: |
echo "## 📊 Coverage Report Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📈 Test Coverage Metrics" >> $GITHUB_STEP_SUMMARY
echo "- **Test Results**: Available in artifacts" >> $GITHUB_STEP_SUMMARY
echo "- **Coverage Report**: Generated and uploaded" >> $GITHUB_STEP_SUMMARY
echo "- **Codecov**: Uploaded to Codecov platform" >> $GITHUB_STEP_SUMMARY
echo "- **Artifacts**: Available for download" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🔗 Links" >> $GITHUB_STEP_SUMMARY
echo "- **Codecov**: [View Coverage Report](https://codecov.io/gh/${{ github.repository }})" >> $GITHUB_STEP_SUMMARY
echo "- **Artifacts**: Download from Actions tab" >> $GITHUB_STEP_SUMMARY
# Create PR to main
create-pr:
name: 🔄 Create PR to main
runs-on: ubuntu-latest
needs: [build-qrcoder, build-windows, security, coverage-reports]
if: |
github.event_name == 'push' &&
startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/bug/') || startsWith(github.ref, 'refs/heads/hotfix/')
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v7.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: 🔧 Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: 🔄 Create PR to main
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "🚀 Auto-merge: ${{ github.event.head_commit.message }}"
title: "🚀 Auto-PR: ${{ github.ref_name }} → main"
body: |
## 🚀 Pull Request Automática
**Branch:** `${{ github.ref_name }}`
**Commit:** `${{ github.sha }}`
**Autor:** `${{ github.actor }}`
### 📋 Mudanças
- Build e testes executados com sucesso ✅
- Security scan aprovado 🔒
- Performance tests passados ⚡
### 🔄 Status
- ✅ QRCoder.Core Build
- ✅ Testes Unitários
- ✅ Security Scan
- ✅ Performance Tests
---
*Este PR foi criado automaticamente pelo pipeline CI/CD*
branch: auto-pr/${{ github.ref_name }}
delete-branch: true
draft: false
labels: |
auto-pr
ci-passed
ready-for-review