-
Notifications
You must be signed in to change notification settings - Fork 13
221 lines (195 loc) · 8.66 KB
/
windows.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
name: Windows
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -e -l {0}
jobs:
build:
runs-on: ${{ matrix.runs-on }}
name: ${{ matrix.toolchain.compiler }} / ${{ matrix.build-system.name }} / ${{ matrix.config.name }} / targets ${{ matrix.target-arch.name }} / date-polyfill ${{ matrix.toolchain.date-polyfill}}
strategy:
fail-fast: false
matrix:
runs-on: [windows-latest]
toolchain:
- {compiler: msvc, date-polyfill: 'ON', use-large-int-placeholders: 'ON'}
- {compiler: msvc, date-polyfill: 'OFF', use-large-int-placeholders: 'ON'}
- {compiler: clang, date-polyfill: 'ON', version: 18, use-large-int-placeholders: 'ON'}
- {compiler: clang, date-polyfill: 'OFF', version: 18, use-large-int-placeholders: 'ON'}
target-arch:
- {
name: "Win64",
vs-flags: "-A x64", # only used by VS generator
cl-flags: "/arch (x64)",
gnu-flags: "-m64",
msvc-dev-cmd: "win64"
}
- {
name: "Win32",
vs-flags: "-A Win32", # only used by VS generator
cl-flags: "/arch (x86)",
gnu-flags: "-m32",
msvc-dev-cmd: "win32"
}
config:
- {name: Debug}
- {name: Release}
build-system:
- {name: "Visual Studio 17 2022"}
- {name: "Ninja"}
steps:
- name: Setup MSVC (only for non-VS buildsystems)
if: matrix.toolchain.compiler == 'msvc' && !startsWith(matrix.build-system.name, 'Visual Studio')
uses: ilammy/msvc-dev-cmd@v1
with:
# Ninja will take cues of which target architecture to use from the (powershell)
# msvc environment so we need to setup everything at this level.
arch: ${{matrix.target-arch.msvc-dev-cmd}}
- name: Install LLVM and Clang
if: matrix.toolchain.compiler == 'clang'
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{matrix.toolchain.version}}
arch: x64
- name: Setup clang
if: matrix.toolchain.compiler == 'clang'
run: |
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
- name: Setup gnu compilers
if: matrix.toolchain.compiler != 'msvc'
run: |
echo "CMAKE_CXX_FLAGS=${{matrix.target-arch.gnu-flags}}" >> $GITHUB_ENV
echo "CMAKE_CXX_LINK_FLAGS=${{matrix.target-arch.gnu-flags}}" >> $GITHUB_ENV
- name: Setup Ninja + msvc
if: matrix.toolchain.compiler == 'msvc' && matrix.build-system.name == 'Ninja'
run: |
echo "CMAKE_CXX_FLAGS=${{matrix.target-arch.cl-flags}}" >> $GITHUB_ENV
echo "CMAKE_CXX_LINK_FLAGS=${{matrix.target-arch.cl-flags}}" >> $GITHUB_ENV
- name: Setup Visual Studio
if: startsWith(matrix.build-system.name, 'Visual Studio')
run: |
echo "GENERATOR_EXTRA_FLAGS=${{matrix.target-arch.vs-flags}}" >> $GITHUB_ENV
- name: Setup toolset if we use Visual Studio Build System and Clang
if: startsWith(matrix.build-system.name, 'Visual Studio') && matrix.toolchain.compiler == 'clang'
run: |
echo "GENERATOR_EXTRA_FLAGS=${GENERATOR_EXTRA_FLAGS} -T ClangCL" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.toolchain.compiler }}_${{ matrix.build-system.name }}_${{ matrix.config.name }}_targets_${{ matrix.target-arch.name }}_date-polyfill_${{ matrix.toolchain.date-polyfill}}_ccache
- name: Setup vcpkg environment
if: matrix.target-arch.name == 'Win32'
run: |
vcpkg install --triplet=x86-windows
- name: Set conda environment
if: matrix.target-arch.name == 'Win64'
uses: mamba-org/setup-micromamba@main
with:
environment-name: myenv
environment-file: environment-dev.yml
init-shell: bash
cache-downloads: true
create-args: |
ninja
- name: Set dependencies install prefix dir for 64bit
if: matrix.target-arch.name == 'Win64'
run: |
echo "SPARROW_DEPS_PREFIX=$CONDA_PREFIX" >> $GITHUB_ENV
echo "SPARROW_INSTALL_PREFIX=$CONDA_PREFIX" >> $GITHUB_ENV
echo "SPARROW_ADDITIONAL_OPTIONS=-DSPARROW_TARGET_32BIT=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL" >> $GITHUB_ENV
- name: Set dependencies install prefix dir for 32bit
if: matrix.target-arch.name == 'Win32'
run: |
echo "SPARROW_DEPS_PREFIX=$VCPKG_INSTALLED_DIR" >> $GITHUB_ENV
echo "SPARROW_INSTALL_PREFIX=${{ github.workspace }}/install" >> $GITHUB_ENV
echo "VCPKG_TARGET_TRIPLET='x86-windows'" >> $GITHUB_ENV
echo "VCPKG_BUILD_TYPE='Release'" >> $GITHUB_ENV
echo "CMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $GITHUB_ENV
echo "SPARROW_ADDITIONAL_OPTIONS=-DSPARROW_TARGET_32BIT=ON" >> $GITHUB_ENV
choco install ninja
- name: Enable runtime size/length/offset validity checks
if: matrix.config.name == 'Debug'
run: |
echo "SPARROW_CHECKS='$SPARROW_CHECKS -DSPARROW_ENABLE_SIZE_CHECKS=ON'" >> $GITHUB_ENV
- name: Enable runtime 32bit size/length/offset limit
if: matrix.target-arch.name == 'Win32' # Note: this is not a mandatory limitation in any context, we add this just to have at least one configuration testing that feature
run: echo "SPARROW_CHECKS='$SPARROW_CHECKS -DSPARROW_ENABLE_32BIT_SIZE_LIMIT=ON'" >> $GITHUB_ENV
- name: Enable tests coverage
if: matrix.config.name == 'Debug' && matrix.toolchain.compiler == 'msvc'
run: |
choco install opencppcoverage
echo "TEST_COVERAGE_ACTIVATION=' -DENABLE_COVERAGE=ON'" >> $GITHUB_ENV
- name: Set CMake generator environment variable
run: |
echo "CMAKE_GENERATOR=${{ matrix.build-system.name }}" >> $GITHUB_ENV
- name: Configure using CMake
run: |
cmake -S ./ -B ./build \
-DCMAKE_BUILD_TYPE:STRING=${{matrix.config.name}} \
-DCMAKE_PREFIX_PATH=$SPARROW_DEPS_PREFIX \
-DCMAKE_INSTALL_PREFIX=$SPARROW_INSTALL_PREFIX \
-DBUILD_TESTS=ON \
-DBUILD_EXAMPLES=ON \
-DUSE_LARGE_INT_PLACEHOLDERS=${{matrix.toolchain.use-large-int-placeholders}} \
-DUSE_DATE_POLYFILL=${{matrix.toolchain.date-polyfill}} \
$GENERATOR_EXTRA_FLAGS \
$SPARROW_CHECKS \
$SPARROW_ADDITIONAL_OPTIONS \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DFETCH_DEPENDENCIES_WITH_CMAKE=MISSING \
$TEST_COVERAGE_ACTIVATION
- name: Build library
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target sparrow --parallel 8
- name: Install
working-directory: build
run: cmake --install . --config ${{matrix.config.name}}
- name: Build tests
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target test_sparrow_lib --parallel 8
- name: Run tests
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target run_tests_with_junit_report
- name: Upload test results
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test_sparrow_lib_report_Windows_${{ matrix.toolchain.compiler }}_${{ matrix.build-system.name }}_${{ matrix.config.name }}_${{ matrix.target-arch.name }}_date-polyfill_${{ matrix.toolchain.date-polyfill}}
path: ./**/test*.xml
if-no-files-found: error
- name: Tests coverage
if: matrix.config.name == 'Debug' && matrix.toolchain.compiler == 'msvc'
working-directory: build
run: |
cmake --build . --config Debug --target generate_cobertura
- name: Upload coverage to Codecov
if: matrix.config.name == 'Debug' && matrix.toolchain.compiler == 'msvc'
env:
COMPILER: ${{ matrix.toolchain.compiler }}
BUILD_SYSTEM: ${{ matrix.build-system.name }}
CONFIG: ${{ matrix.config.name }}
TARGET_ARCH: ${{ matrix.target-arch.name }}
DATE_POLYFILL: ${{ matrix.toolchain.date-polyfill }}
uses: codecov/codecov-action@v5
with:
directory: ./build/coverage_reports/
fail_ci_if_error: true
files: ./cobertura.xml
env_vars: COMPILER,BUILD_SYSTEM,CONFIG,TARGET_ARCH,DATE_POLYFILL
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Run all examples
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target run_examples