Repository navigation
147 lines (129 loc) · 6.12 KB
/
Copy pathCPPTest.yml
File metadata and controls
147 lines (129 loc) · 6.12 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
name: 'C++ Test'
# Coverage for this leg is https://github.com/asc-community/AngouriMath/issues/746 item 35 and
# https://github.com/asc-community/AngouriMath/issues/397, and it is not the same measurement the
# other three legs make. C#, F# and Interactive each run `dotnet test` and collect coverage of
# managed assemblies with the VSTest XPlat collector. Nothing in this job can: the library reaches
# the tests as a Native AOT shared object, the published artefact contains no managed assembly at
# all, and ctest runs a native executable rather than a test host the collector can attach to.
#
# What this leg does have, and what nothing measured until now, is the C++ of the wrapper itself:
# Sources/Wrappers/AngouriMath.CPP.Importing holds the handle cache, the error-code translation
# and the exception boundary that every C++ caller goes through. That is ordinary C++, and gcov
# covers it, so the Linux job builds with --coverage and uploads Cobertura under the `cpp` flag.
# The number is coverage of the C++ wrapper, not of AngouriMath through it; see
# Sources/AngouriMath/Docs/Contributing/Coverage.md.
on:
push:
branches:
- master
pull_request:
branches:
- '*'
env:
tests_path: Sources/Tests/CPPWrapperUnitTests/tests
jobs:
Testing:
strategy:
matrix:
include:
- os: windows-latest
flag: win-x64
- os: ubuntu-latest
flag: linux-x64
- os: macos-latest
flag: osx-arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.x'
dotnet-quality: 'preview'
- name: 'Install some libs for Linux'
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y zlib1g-dev libkrb5-dev gcovr
- name: 'Building the library into native for Windows'
if: ${{ matrix.os == 'windows-latest' }}
shell: cmd
run: |
cd Sources/Wrappers/AngouriMath.CPP.Exporting
mkdir ../AngouriMath.CPP.Importing/out-x64
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
dotnet publish -p:NativeLib=Shared -p:SelfContained=true -r ${{ matrix.flag }} -c release
- name: 'Building the library into native for Linux & MacOS'
if: ${{ matrix.os != 'windows-latest' }}
run: |
cd Sources/Wrappers/AngouriMath.CPP.Exporting
mkdir ../AngouriMath.CPP.Importing/out-x64
dotnet publish -p:NativeLib=Shared -p:SelfContained=true -r ${{ matrix.flag }} -c release
- name: 'Preparing tests'
if: ${{ matrix.os != 'ubuntu-latest' }}
run: |
cd ${{ env.tests_path }}
cmake -S . -B build
mkdir "build/Debug"
# Same configure, plus gcov instrumentation. -O0 so that a line in the report is a line in the
# source; the tests take under a second either way.
- name: 'Preparing tests, instrumented for coverage'
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cd ${{ env.tests_path }}
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="--coverage -O0 -g" -DCMAKE_EXE_LINKER_FLAGS="--coverage"
mkdir "build/Debug"
- name: 'Copying the library for Windows'
if: ${{ matrix.os == 'windows-latest' }}
run: |
cd ${{ env.tests_path }}
copy "..\..\..\Wrappers\AngouriMath.CPP.Importing\out-x64\AngouriMath.CPP.Exporting.dll" "build\Debug\AngouriMath.CPP.Exporting.dll" # needed for run time
copy "..\..\..\Wrappers\AngouriMath.CPP.Importing\out-x64\AngouriMath.CPP.Exporting.lib" "build\Debug\AngouriMath.CPP.Exporting.lib" # needed for link time
- name: 'Copying the library for Linux'
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cd ${{ env.tests_path }}
cp -a "../../../Wrappers/AngouriMath.CPP.Importing/out-x64/AngouriMath.CPP.Exporting.so" "build/Debug/libAngouriMath.CPP.Exporting.so"
- name: 'Copying the library for OS X'
if: ${{ matrix.os == 'macos-latest' }}
run: |
cd ${{ env.tests_path }}
cp -r "../../../Wrappers/AngouriMath.CPP.Importing/out-x64/AngouriMath.CPP.Exporting.dylib" "build/Debug/libAngouriMath.CPP.Exporting.dylib"
- name: 'Building and running tests'
run: |
cd ${{ env.tests_path }}
cmake --build build
cd build
ctest
# The filter is what keeps this honest: without it the report is dominated by the vendored
# googletest sources, which nobody here maintains, and by RunTests.cpp, which is 100% covered
# by construction because it is the thing being run.
- name: 'Coverage of the C++ wrapper'
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cd ${{ env.tests_path }}/build
gcovr --root ../../../../.. --filter '.*AngouriMath\.CPP\.Importing.*' \
--print-summary --cobertura coverage-cpp.xml
# gcovr writes a well-formed report with nothing in it when the filter matches no file, and
# codecov accepts it. Fail here instead, so that a flag claiming this leg is covered cannot
# go green on an empty report.
grep -q 'lines-valid="[1-9]' coverage-cpp.xml
# `files`, not `file`: v5 of the action does not take `file`, and given it, it warns about an
# unexpected input and then searches the workspace itself. Measured here, that search found 96
# reports -- the whole of googletest and of /usr/include/c++/13 -- so the flag would have
# carried everything the filter above exists to exclude. `disable_search` and `plugins: noop`
# keep it to the one report gcovr wrote.
- name: 'Send to codecov'
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v5
with:
files: ./Sources/Tests/CPPWrapperUnitTests/tests/build/coverage-cpp.xml
disable_search: true
plugins: noop
flags: cpp
- name: 'Upload logs'
if: failure()
uses: actions/upload-artifact@v6
with:
name: Logs
path: ./Sources/Tests/CPPWrapperUnitTests/tests/build/Testing/Temporary