forked from virtuallynathan/qpep
-
Notifications
You must be signed in to change notification settings - Fork 2
558 lines (490 loc) · 17.2 KB
/
integration.yml
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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
name: CodeIntegration
on:
workflow_dispatch:
inputs:
skip_docs:
description: 'skips generation of the documentation'
type: boolean
default: false
required: true
skip_windows:
description: 'skips the Windows job'
type: boolean
default: false
required: true
skip_linux:
description: 'skips the Linux job'
type: boolean
default: false
required: true
skip_macos:
description: 'skips the MacOS job'
type: boolean
default: false
required: true
push:
branches: [ "main", "dev-*" ]
run-name: Code Integration [${{ github.event_name }}][${{ github.head_ref || github.ref_name }}] rev.${{ github.sha }}
jobs:
check-diff-files:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
SRC_PATTERN: '\.go|\.c|\.cpp|\.html|\.js|\.h'
outputs:
source_changed: ${{ steps.check_file_changed.outputs.source_changed }}
steps:
- uses: actions/checkout@v4
with:
clean: true
submodules: true
- name: Check files difference
id: check_file_changed
run: |
SRC_DIFF=$(git diff --name-only | grep -E "$SRC_DIFF" | wc -l)
echo ">> Differing source files list <<"
echo $(git diff --name-only | grep -E "$SRC_DIFF")
echo "---------------------------------"
if [[ "$SRC_DIFF" -gt "0" ]]; then
echo ">> Found differing source files, executing integration workflow"
echo "source_changed=true" >> $GITHUB_OUTPUT
exit 0
fi
echo ">> No differing source files, skipping integration workflow"
echo "source_changed=false" >> $GITHUB_OUTPUT
exit 0
docs:
needs: [ check-diff-files ]
if: ${{ needs.check-diff-files.outputs.source_changed && !inputs.skip_docs }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
GO_VERSION: 1.20.14
PANDOC_VERSION: 3.3
steps:
- uses: actions/checkout@v4
with:
clean: true
submodules: false
- name: Install Pandoc
uses: pandoc/actions/[email protected]
with:
version: ${{ env.PANDOC_VERSION }}
- name: Install TeXlive
run: sudo apt-get update && sudo apt-get install texlive-full
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Generate PDF
run: |
cd docs/
CURDATE=$(date '+%x %T')
SHORT_SHA=$(echo "${{ github.sha }}" | cut -b -8)
sed -i -E -e "s|subtitle:.+|subtitle: \"User Manual - rev. $SHORT_SHA\"|" -e "s|date:.+|date: \"$CURDATE\"|" user-manual.md
go generate
- uses: actions/upload-artifact@v4
with:
name: qpep_user_manual
path: "docs/*.pdf"
build-mac-os:
needs: [ check-diff-files ]
if: ${{ needs.check-diff-files.outputs.source_changed && !inputs.skip_macos }}
runs-on: macos-latest
env:
GO_VERSION: 1.20.14
CMAKE_VERSION: '3.22.x'
GOARCH: arm64
GOOS: darwin
CGO_ENABLED: 1
GOPATH: ${{ github.workspace }}/.go
CMAKE_BUILD_PARALLEL_LEVEL: 4
IGNORE_PACKAGES: 'tray|docker|docs|version|webgui|workers$'
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
clean: true
submodules: true
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up CMake
uses: jwlawson/[email protected]
with:
cmake-version: ${{ env.CMAKE_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Prepare
run: |
go clean -cache -x
mkdir -p cover
mkdir -p report
mkdir -p unit
mkdir -p $GOPATH/bin
pip install dmgbuild
- name: Build Backends
run: |
export CPP=${CXX}
export PATH=$GOPATH/bin:$GOPATH/bin/${GOOS}_${GOARCH}:$PATH
cd backend/
go generate
- name: Build Executable
run: |
go build -v -o build/qpep
- name: Build QPep Tray 64bits
run: |
pushd qpep-tray
go build -v -o ../build/qpep-tray
popd
- name: Build MacOS installer
run: |
bash ./installer_osx.sh "0.0.0-dev${{github.run_id}}"
- uses: actions/upload-artifact@v4
with:
name: qpep_macos_b${{ github.run_id }}
path: installer-osx/QPep*.pkg
- name: Prepare Tests
run: |
mkdir -p unit/
mkdir -p cover/
mkdir -p report/
go install github.com/jstemmer/go-junit-report/[email protected]
go install github.com/axw/gocov/[email protected]
go install github.com/matm/gocov-html/cmd/[email protected]
go install github.com/AlekSi/[email protected]
- name: Test
run: |
set -x
go list ./... | grep -E -v "${IGNORE_PACKAGES}"
for i in $(go list ./... | grep -E -v "${IGNORE_PACKAGES}" | sed -n -e 's|github.com\/Project-Faster\/qpep\/||p')
do
pushd $i
export WORKSPACE="${{ github.workspace }}"
go test -v -gcflags=-l -cover -c -o qpep.$(basename $PWD).test > unit_tests.out 2>&1 || true
./qpep.$(basename $PWD).test -test.v -test.timeout 5m -test.coverprofile=$WORKSPACE/cover/$(basename $PWD).out >> unit_tests.out 2>&1 || true
grep -E "PASS|FAIL|SKIP" unit_tests.out || true
cat unit_tests.out | go-junit-report > $WORKSPACE/unit/$(basename $PWD).xml
popd
done
continue-on-error: true
- name: Publish Coverage Results
if: always()
run: |
for i in $(go list ./... | grep -E -v "${IGNORE_PACKAGES}" | sed -n -e 's|github.com\/Project-Faster\/qpep\/||p')
do
pushd $i
echo "=== Package $i ===" >> $GITHUB_STEP_SUMMARY
gocov convert ${{ github.workspace }}/cover/$(basename $PWD).out | gocov report | grep "Coverage" >> $GITHUB_STEP_SUMMARY || true
echo >> $GITHUB_STEP_SUMMARY
gocov convert ${{ github.workspace }}/cover/$(basename $PWD).out | gocov-html > ${{ github.workspace }}/report/$(basename $PWD).html || true
popd
done
continue-on-error: true
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/macos@v2
if: always()
with:
check_name: "Unit Tests - MacOS Platform"
junit_files: "unit/*.xml"
- uses: actions/upload-artifact@v4
if: always()
with:
name: macos_cover_output
path: "cover/*.out"
- uses: actions/upload-artifact@v4
if: always()
with:
name: macos_coverage_report
path: "report/*.html"
- name: Fail build on test error
run: |
set +e
for i in $(go list ./... | grep -E -v "${IGNORE_PACKAGES}" | sed -n -e 's|github.com\/Project-Faster\/qpep\/||p')
do
pushd $i
if [ ! -f unit_tests.out ]; then
exit 1
fi
grep -E "FAIL:" unit_tests.out
if [ $? -eq 0 ]; then
exit 1
fi
popd
done
build-linux:
needs: [ check-diff-files ]
if: ${{ needs.check-diff-files.outputs.source_changed && !inputs.skip_linux }}
runs-on: ubuntu-latest
env:
GO_VERSION: 1.20.14
CMAKE_VERSION: '3.22.x'
GOARCH: amd64
GOOS: linux
CGO_ENABLED: 1
CMAKE_BUILD_PARALLEL_LEVEL: 4
IGNORE_PACKAGES: 'tray|docker|docs|version|webgui|workers$'
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
clean: true
submodules: true
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up CMake
uses: jwlawson/[email protected]
with:
cmake-version: ${{ env.CMAKE_VERSION }}
- name: Prepare
run: |
sudo apt-get install -y pkg-config libgtk-3-dev libayatana-appindicator-dev
go clean -cache -x
mkdir -p cover
mkdir -p report
mkdir -p unit
go install github.com/jstemmer/go-junit-report/[email protected]
go install github.com/axw/gocov/[email protected]
go install github.com/matm/gocov-html/cmd/[email protected]
go install github.com/AlekSi/[email protected]
- name: Build Backends
run: |
cd backend/
go generate
- name: Build QPep
run: |
go build -v -o build/qpep
- name: Build QPep Tray
run: |
pushd qpep-tray
go build -o ../build/qpep-tray
popd
- uses: actions/upload-artifact@v4
with:
name: qpep_linux_b${{ github.run_id }}
path: build/
- name: Test
run: |
set -x
for i in $(go list ./... | grep -E -v "${IGNORE_PACKAGES}" | sed -n -e 's|github.com\/Project-Faster\/qpep\/||p')
do
pushd $i
export WORKSPACE="${{ github.workspace }}"
go test -v -gcflags=-l -cover -c -o qpep.$(basename $PWD).test &> /dev/null || true
./qpep.$(basename $PWD).test -test.v -test.timeout 5m -test.coverprofile=$WORKSPACE/cover/$(basename $PWD).out &> unit_tests.out || true
grep -E "PASS|FAIL|SKIP" unit_tests.out || true
cat unit_tests.out | go-junit-report > $WORKSPACE/unit/$(basename $PWD).xml
popd
done
continue-on-error: true
- name: Publish Coverage Results
if: always()
run: |
for i in $(go list ./... | grep -E -v "${IGNORE_PACKAGES}" | sed -n -e 's|github.com\/Project-Faster\/qpep\/||p')
do
pushd $i
echo "=== Package $i ===" >> $GITHUB_STEP_SUMMARY
gocov convert ${{ github.workspace }}/cover/$(basename $PWD).out | gocov report | grep "Coverage" >> $GITHUB_STEP_SUMMARY || true
echo >> $GITHUB_STEP_SUMMARY
gocov convert ${{ github.workspace }}/cover/$(basename $PWD).out | gocov-html > ${{ github.workspace }}/report/$(basename $PWD).html || true
popd
done
continue-on-error: true
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: always()
with:
check_name: "Unit Tests - Linux Platform"
junit_files: "unit/*.xml"
- uses: actions/upload-artifact@v4
if: always()
with:
name: linux_cover_output
path: "cover/*.out"
- uses: actions/upload-artifact@v4
if: always()
with:
name: linux_coverage_report
path: "report/*.html"
- name: Fail build on test error
run: |
set +e
for i in $(go list ./... | grep -E -v "${IGNORE_PACKAGES}" | sed -n -e 's|github.com\/Project-Faster\/qpep\/||p')
do
pushd $i
if [ ! -f unit_tests.out ]; then
exit 1
fi
cat unit_tests.out
grep -E "FAIL:" unit_tests.out
if [ $? -eq 0 ]; then
exit 1
fi
popd
done
build-windows:
needs: [ check-diff-files ]
if: ${{ needs.check-diff-files.outputs.source_changed && !inputs.skip_windows }}
runs-on: windows-latest
env:
GO_VERSION: 1.20.14
CMAKE_VERSION: '3.22.x'
GOARCH: amd64
GOOS: windows
CGO_ENABLED: 1
QPEP_CI_ENV: 1
CMAKE_BUILD_PARALLEL_LEVEL: 4
IGNORE_PACKAGES: 'tray|docker|docs|version|webgui|workers$'
MINGW_BASEDIR: 'C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin'
defaults:
run:
shell: cmd
steps:
- uses: actions/checkout@v4
with:
clean: true
submodules: true
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Wix
uses: actions/checkout@v2
with:
repository: fbarresi/wix
path: wix
- name: Install MSBuild
uses: microsoft/[email protected]
- name: Set up MinGW
uses: egor-tensin/setup-mingw@v2
with:
platform: x64
static: true
version: 11.1.0
- name: Set up CMake
uses: jwlawson/[email protected]
with:
cmake-version: ${{ env.CMAKE_VERSION }}
- name: Prepare
run: |
@echo on
MKDIR build
MKDIR build\64bits
MKDIR build\32bits
COPY /Y windivert\LICENSE build\LICENSE.windivert
COPY /Y LICENSE build\LICENSE
go clean -cache -x
COPY /Y windivert\x64\* build\64bits
COPY /y "%MINGW_BASEDIR%\libgcc_s_seh-1.dll" build\64bits
COPY /y "%MINGW_BASEDIR%\libwinpthread-1.dll" build\64bits
COPY /y "%MINGW_BASEDIR%\libstdc++-6.dll" build\64bits
- name: Build Backends
run: |
cd backend/
go generate
- name: Build QPep
run: |
go build -o build\64bits\qpep.exe
- name: Build QPep Tray
run: |
pushd qpep-tray
set CGO_ENABLED=0
go build -ldflags -H=windowsgui -o ..\build\64bits\qpep-tray.exe
popd
- name: Build QPep Installer
run: |
sed -E 's/Version="[^"]+"/Version="1.0.0.0-dev${{github.run_id}}"/' installer/installer.wxs > installer/installer.wxs
sed -E 's/FileVersion:\s*"[^"]+"/FileVersion:\s*"0.0.0-dev${{github.run_id}}"/' shared/version/versioninfo.json > shared/version/versioninfo.json
sed -E 's/ProductVersion:\s*"[^"]+"/ProductVersion:\s*"0.0.0-dev${{github.run_id}}"/' shared/version/versioninfo.json > shared/version/versioninfo.json
set PATH=${{ github.workspace }}\wix\tools;%PATH%
msbuild installer\installer.sln
- uses: actions/upload-artifact@v4
with:
name: qpep_windows_b${{ github.run_id }}
path: build/installer.msi
- name: Prepare Tests
run: |
MKDIR unit
MKDIR cover
MKDIR report
go install github.com/jstemmer/go-junit-report/[email protected]
go install github.com/axw/gocov/[email protected]
go install github.com/matm/gocov-html/cmd/[email protected]
go install github.com/AlekSi/[email protected]
- name: Test
shell: bash
run: |
export WORKSPACE=$( echo "${{ github.workspace }}" | sed -e 's|\\|/|g' )
go generate github.com/Project-Faster/qpep/windivert
for i in $(go list ./... | grep -E -v "${IGNORE_PACKAGES}" | sed -n -e 's|github.com\/Project-Faster\/qpep\/||p')
do
pushd $i
cp -r $WORKSPACE/windivert/x64/* .
go test -v -gcflags=-l -cover -c -o qpep.$(basename $PWD).test > unit_tests.out 2>&1 || true
./qpep.$(basename $PWD).test -test.v -test.timeout 5m -test.coverprofile=$WORKSPACE/cover/$(basename $PWD).out >> unit_tests.out 2>&1 || true
grep -E "PASS|FAIL|SKIP" unit_tests.out || true
cat unit_tests.out | go-junit-report > $WORKSPACE/unit/$(basename $PWD).xml
popd
done
continue-on-error: true
- name: Publish Coverage Results
shell: bash
if: always()
run: |
export WORKSPACE=$( echo "${{ github.workspace }}" | sed -e 's|\\|/|g' )
for i in $(go list ./... | grep -E -v "${IGNORE_PACKAGES}" | sed -n -e 's|github.com\/Project-Faster\/qpep\/||p')
do
pushd $i
echo "=== Package $i ===" >> $GITHUB_STEP_SUMMARY
gocov convert $WORKSPACE/cover/$(basename $PWD).out | gocov report | grep "Coverage" >> $GITHUB_STEP_SUMMARY || true
echo >> $GITHUB_STEP_SUMMARY
gocov convert $WORKSPACE/cover/$(basename $PWD).out | gocov-html > $WORKSPACE/report/$(basename $PWD).html || true
popd
done
continue-on-error: true
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
check_name: "Unit Tests - Windows Platform"
junit_files: "unit/*.xml"
- uses: actions/upload-artifact@v4
if: always()
with:
name: windows_coverage_output
path: cover/*.out
- uses: actions/upload-artifact@v4
if: always()
with:
name: windows_coverage_report
path: report/*.html
- name: Fail build on test error
shell: bash
run: |
set +e
for i in $(go list ./... | grep -E -v "${IGNORE_PACKAGES}" | sed -n -e 's|github.com\/Project-Faster\/qpep\/||p')
do
pushd $i
if [ ! -f unit_tests.out ]; then
exit 1
fi
cat unit_tests.out
grep -E "FAIL:" unit_tests.out
if [ $? -eq 0 ]; then
exit 1
fi
popd
done