-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (65 loc) · 2.37 KB
/
test_unit_cpp.yml
File metadata and controls
76 lines (65 loc) · 2.37 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
name: 'Test Unit C++'
description: |
This workflow builds the library and runs the unit tests.
Integration tests that require a serial port are skipped on Windows (no virtual device).
on:
workflow_call:
inputs:
artifact-name:
description: 'Name of the artifact'
required: true
type: string
jobs:
test-unit-cpp:
name: 'Test Unit C++'
runs-on: windows-latest
env:
TEST_REPORT_NAME: 'test_report.xml'
steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
- name: 'Download artifact'
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: artifacts
- name: 'Setup CMake'
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.31.x'
- name: 'Configure CMake'
run: |
cmake --preset windows-vs-release
- name: 'Build tests'
run: |
cmake --build --preset windows-vs-release --config Release
- name: 'Copy library artifact next to test exe'
shell: pwsh
run: |
$testDir = Get-ChildItem -Recurse -Path build -Filter cpp_bindings_windows_tests.exe -File | Select-Object -First 1
if ($testDir) { Copy-Item -Force artifacts/cpp_bindings_windows.dll $testDir.DirectoryName }
- name: 'Run tests'
shell: pwsh
run: |
$testExe = Get-ChildItem -Recurse -Path build -Filter cpp_bindings_windows_tests.exe -File | Select-Object -First 1
if (-not $testExe) { throw "cpp_bindings_windows_tests.exe not found" }
Push-Location $testExe.DirectoryName
& $testExe.FullName --gtest_color=yes --gtest_output=xml:$env:TEST_REPORT_NAME
Pop-Location
Copy-Item (Join-Path $testExe.DirectoryName $env:TEST_REPORT_NAME) build/
- name: 'Upload test report'
if: always()
uses: actions/upload-artifact@v4
with:
name: test_reports
path: build/${{ env.TEST_REPORT_NAME }}
- name: 'Publish test report'
if: always()
uses: mikepenz/action-junit-report@v5
with:
report_paths: 'build/${{ env.TEST_REPORT_NAME }}'
detailed_summary: true
group_suite: true
include_passed: true
annotate_notice: true
check_title_template: '{{FILE_NAME}} | {{TEST_NAME}}'