-
Notifications
You must be signed in to change notification settings - Fork 15
239 lines (216 loc) · 8.72 KB
/
unittests.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
name: unittests
on:
push:
branches:
- main
pull_request:
jobs:
run-tests:
name: Test on ${{ matrix.os }} with ${{ matrix.toolchain.compiler }} ${{ matrix.toolchain.version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
toolchain:
- {compiler: gcc, version: 13}
include:
- os: windows-2022
toolchain: {compiler: intel-classic, version: '2021.12'}
steps:
- uses: actions/checkout@v4
- name: checkout submodules
run: git submodule update --init --recursive
# - name: Setup Visual Studio 2022
# if: matrix.os == 'windows-2022'
# uses: microsoft/[email protected]
- name: Install ninja-build tool
if: matrix.os == 'windows-2022'
uses: seanmiddleditch/gha-setup-ninja@16b940825621068d98711680b6c3ff92201f8fc0
- name: Install ninja Linux
if: matrix.os == 'ubuntu-latest'
uses: seanmiddleditch/gha-setup-ninja@master
- name: Install lapack Linux
if: matrix.os == 'ubuntu-latest'
run: sudo apt install -y liblapack-dev libblas-dev
- uses: fortran-lang/setup-fortran@v1
id: setup-fortran
if: matrix.os != 'macos-12'
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
- name: Setup gfortran macos-12
if: matrix.os == 'macos-12'
run: |
export FC=$(which gfortran-13)
echo FC=$FC >> $GITHUB_ENV
- name: Build ThermoPack
if: matrix.os != 'windows-2022'
run: |
mkdir build
cd build
cmake -Dtest=ON -DCMAKE_BUILD_TYPE=Debug ..
make -j4 install
# - name: Build LAPACK Windows
# if: matrix.os == 'windows-2022'
# run: |
# cd external
# cd lapack
# cmake -B build -G Ninja -DCMAKE_Fortran_COMPILER=${{ env.FC }} -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icx
# cmake --build build --target install
- name: Build ThermoPack Windows
if: ${{ runner.os == 'Windows' }}
run: |
echo "Building on ${{ matrix.os }}"
$FC = ${{ env.FC }}
$FC_PATH = $((Get-Command ${{ env.FC }} | Select-Object -ExpandProperty Path) -replace '\\', '/')
echo "Using compiler $env:FC / ${{ env.FC }}"
echo "Fortran compiler at: $(Get-Command ${{ env.FC }} | Select-Object -ExpandProperty Path) / $FC_PATH"
cmake -B build -G Ninja -DCMAKE_Fortran_COMPILER=${{ env.FC }} -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --target install --verbose
# cmake -B build -G "Visual Studio 17 2022" -DCMAKE_Fortran_COMPILER=${{ env.FC }}
- name: Inspect thermopack Linux
if: ${{ runner.os == 'Linux' }}
run: |
echo "--- Inspecting libthermopack ---"
ldd installed/libthermopack.so
nm installed/libthermopack.so | grep " T "
echo "--- Inspecting run_unittests ---"
ldd installed/unittests
- name: Inspect thermopack MacOS
if: ${{ runner.os == 'macOS' }}
run: |
echo "--- Inspecting libthermopack ---"
otool -L installed/libthermopack.dylib
nm installed/libthermopack.dylib | grep " T "
echo "--- Inspecting run_unittests ---"
otool -L installed/unittests
- name: Inspect thermopack Windows
if: ${{ runner.os == 'Windows' }}
run: |
echo "--- Inspecting libthermopack.dll ---"
dumpbin /DEPENDENTS installed/libthermopack.dll
dumpbin /EXPORTS installed/libthermopack.dll
- name: Upload
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.os }}-${{ matrix.toolchain.compiler }}
path: ./installed/*
- id: fortran_test
name: Run unittests
if: matrix.os != 'windows-2022'
continue-on-error: true
run: |
result=$(./installed/unittests)
if echo "$result" | grep -q "OK"; then
statuscode=0
else
statuscode=1
fi
echo "$result"
echo "statuscode=$statuscode" >> $GITHUB_OUTPUT
exit $statuscode
- uses: actions/setup-python@v5
- id: python_test
name: Run python tests for Linux/MacOS
if: matrix.os != 'windows-2022'
continue-on-error: true
run: |
python addon/pycThermopack/map_platform_specifics.py
pip install addon/pycThermopack/[test]
pytest addon/pyTests
result=$(pytest addon/pyTests)
echo "Test Result:"
echo "$result"
echo "result=$result" >> $GITHUB_OUTPUT
if echo "$result" | grep -q "FAILED"; then
statuscode=1
else
statuscode=0
fi
echo "Status code : ${statuscode}"
echo "statuscode=$statuscode" >> $GITHUB_OUTPUT
exit $statuscode
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- id: python_test_windows
name: Run python tests for Windows
if: matrix.os == 'windows-2022'
continue-on-error: true
run: |
python -m pip install --upgrade pip
pip install pytest numpy
python -c "import sys; sys.path.insert(0, './addon/pycThermopack'); import makescript; makescript.windows_make('v3')"
pip install ./addon/pycThermopack/[test]
$result = python -m pytest ./addon/pyTests
if ($result -match "FAILED") {
$statuscode = 1
} else {
$statuscode = 0
}
Write-Output $result
Add-Content -Path $env:GITHUB_OUTPUT -Value "statuscode=$statuscode"
exit $statuscode
- name: Run cppExamples on Linux/macOS
id: cpp_test
if: matrix.os != 'windows-2022'
run: |
cd addon/cppExamples
mkdir build
cd build
cmake ..
make
examples=("basic" "flashes" "saturation" "tp_properties" "tv_properties" "tvp_properties")
nfailed=0
for exmp in "${examples[@]}"; do echo "Running $exmp"; ./"$exmp" > /dev/null; if [[ $? -ne 0 ]]; then echo "$exmp exited with code $? (failure)."; ((nfailed++)); else echo "$exmp exit 0 (success)"; fi; done
echo "statuscode=$nfailed" >> $GITHUB_OUTPUT
exit $nfailed
- name: Run cppExamples on Windows
id: cpp_test_windows
if: matrix.os == 'windows-2022'
run: |
cd addon/cppExamples
mkdir build
cd build
cmake ..
cmake --build . --config Release
cd Release
cp ../../../../installed/libthermopack.dll .
$examples = @("basic.exe", "flashes.exe", "saturation.exe", "tp_properties.exe", "tv_properties.exe", "tvp_properties.exe")
$nfailed = 0
foreach ($exmp in $examples) {
Write-Host "Running $exmp"
# Run the example and suppress output
& "./$exmp" > $null
if ($LASTEXITCODE -ne 0) {
Write-Host "$exmp exited with code $LASTEXITCODE (failure)."
$nfailed++
} else {
Write-Host "$exmp exit 0 (success)"
}
}
Add-Content -Path $env:GITHUB_OUTPUT -Value "statuscode=$nfailed"
exit $nfailed
- name: Check success
if: matrix.os != 'windows-2022'
run: |
echo "Fortran test result : ${{ steps.fortran_test.outputs.statuscode }}"
echo "Python test result : ${{ steps.python_test.outputs.statuscode }}"
echo "C++ test result : " ${{ steps.cpp_test.outputs.statuscode }}
if [[ ${{ steps.fortran_test.outputs.statuscode }} -eq 0 ]] && [[ ${{ steps.python_test.outputs.statuscode }} -eq 0 ]] && [[ ${{ steps.cpp_test.outputs.statuscode }} -eq 0 ]]; then
exit 0
else
exit 1
fi
- name: Check success Windows
if: matrix.os == 'windows-2022'
run: |
$statusCodePython = ${{ steps.python_test_windows.outputs.statuscode }}
$statusCodeCpp = ${{ steps.cpp_test_windows.outputs.statuscode }}
Write-Host "Python test result : $statusCodePython"
Write-Host "C++ test result : $statusCodeCpp"
[int]$statusCodePython = $statusCodePython
[int]$statusCodeCpp = $statusCodeCpp
$statusCode = if ($statusCodePython -ne 0 -or $statusCodeCpp -ne 0) { 1 } else { 0 }
exit $statusCode