-
Notifications
You must be signed in to change notification settings - Fork 136
335 lines (276 loc) · 11.2 KB
/
Copy pathtest_cpp_client.yml
File metadata and controls
335 lines (276 loc) · 11.2 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
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
name: C++ Client and ROS 2 C++ Node CI
"on":
workflow_dispatch:
pull_request:
branches:
- main
paths:
- ".github/workflows/test_cpp_client.yml"
- "client/cpp/**"
- "client/python/example_user_scripts/sim_config/**"
- "core_sim/**"
- "ros/projectairsim_ros2_cpp/**"
push:
branches:
- main
paths:
- ".github/workflows/test_cpp_client.yml"
- "client/cpp/**"
- "client/python/example_user_scripts/sim_config/**"
- "core_sim/**"
- "ros/projectairsim_ros2_cpp/**"
permissions:
contents: read
pull-requests: read
jobs:
changes:
name: Detect changed components
runs-on: ubuntu-22.04
outputs:
client: ${{ steps.filter.outputs.client }}
ros2: ${{ steps.filter.outputs.ros2 }}
steps:
- uses: actions/checkout@v4
- name: Detect relevant changes
id: filter
if: github.event_name != 'workflow_dispatch'
uses: dorny/paths-filter@v3
with:
filters: |
client:
- '.github/workflows/test_cpp_client.yml'
- 'client/cpp/**'
- 'client/python/example_user_scripts/sim_config/**'
- 'core_sim/**'
ros2:
- '.github/workflows/test_cpp_client.yml'
- 'ros/projectairsim_ros2_cpp/**'
- 'client/cpp/**'
- 'client/python/example_user_scripts/sim_config/**'
- 'core_sim/**'
windows:
name: Windows package
needs: changes
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.client == 'true'
runs-on: windows-2022
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
- name: Configure
shell: cmd
run: >
cmake -S client/cpp
-B client/cpp/build_windows/Release
-G Ninja
-DCMAKE_BUILD_TYPE=Release
- name: Build
shell: cmd
run: cmake --build client/cpp/build_windows/Release --config Release --parallel
- name: Package
shell: cmd
run: cmake --build client/cpp/build_windows/Release --target package --config Release
- name: Extract package
shell: pwsh
run: |
$archive = Get-ChildItem packages/projectairsim_cpp_client -Filter "ProjectAirSimCppClient-*-win64.zip" | Select-Object -First 1
if (-not $archive) {
throw "ProjectAirSim C++ client package was not created."
}
New-Item -ItemType Directory -Force _cpp_client_ci/package | Out-Null
Expand-Archive -Path $archive.FullName -DestinationPath _cpp_client_ci/package -Force
$packageRoot = Get-ChildItem _cpp_client_ci/package -Directory | Select-Object -First 1
if (-not $packageRoot) {
throw "ProjectAirSim C++ client package did not contain a top-level directory."
}
$packageConfig = Get-ChildItem $packageRoot.FullName -Recurse -Filter "ProjectAirSimCppClientConfig.cmake" | Select-Object -First 1
if (-not $packageConfig) {
Get-ChildItem $packageRoot.FullName -Recurse | Select-Object -ExpandProperty FullName
throw "ProjectAirSim C++ client CMake config was not found in the package."
}
"PACKAGE_ROOT=$($packageRoot.FullName)" | Out-File -FilePath $env:GITHUB_ENV -Append
"PACKAGE_CONFIG_DIR=$($packageConfig.Directory.FullName)" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Smoke-test CMake package
shell: pwsh
run: |
$packageConfig = Get-ChildItem _cpp_client_ci/package -Recurse -Filter "ProjectAirSimCppClientConfig.cmake" | Select-Object -First 1
if (-not $packageConfig) {
Get-ChildItem _cpp_client_ci/package -Recurse | Select-Object -ExpandProperty FullName
throw "ProjectAirSim C++ client CMake config was not found before smoke test."
}
$packageConfigDir = $packageConfig.Directory.FullName
Write-Host "Using ProjectAirSimCppClient_DIR=$packageConfigDir"
New-Item -ItemType Directory -Force _cpp_client_ci/consumer | Out-Null
$cmakeLists = @'
cmake_minimum_required(VERSION 3.20)
project(ProjectAirSimCppClientConsumer LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(ProjectAirSimCppClient REQUIRED)
add_executable(consumer main.cpp)
target_link_libraries(consumer PRIVATE ProjectAirSim::Client)
'@
$cmakeLists | Set-Content _cpp_client_ci/consumer/CMakeLists.txt
$mainSource = @'
#include <ProjectAirsimClient/Client.h>
int main() {
return microsoft::projectairsim::client::Client::GetVersion() == nullptr;
}
'@
$mainSource | Set-Content _cpp_client_ci/consumer/main.cpp
cmake -S _cpp_client_ci/consumer `
-B _cpp_client_ci/consumer/build `
-G Ninja `
-DCMAKE_BUILD_TYPE=Release `
-DProjectAirSimCppClient_DIR="$packageConfigDir" `
-DCMAKE_PREFIX_PATH="$packageConfigDir"
cmake --build _cpp_client_ci/consumer/build --config Release --parallel
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: projectairsim-cpp-client-win64
path: |
packages/projectairsim_cpp_client/ProjectAirSimCppClient-*-win64.zip
packages/projectairsim_cpp_client/ProjectAirSimCppClient-*-win64.zip.sha256
if-no-files-found: error
linux:
name: Linux package (${{ matrix.os }})
needs: changes
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.client == 'true'
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Linux Prerequisites
shell: bash
run: |
sudo apt-get update
sudo apt-get -y install --no-install-recommends \
build-essential cmake ninja-build
- name: Configure
shell: bash
run: |
cmake -S client/cpp \
-B client/cpp/build_linux/Release \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release
- name: Build
shell: bash
run: cmake --build client/cpp/build_linux/Release --config Release --parallel
- name: Package
shell: bash
run: cmake --build client/cpp/build_linux/Release --target package --config Release
- name: Extract package
shell: bash
run: |
archive="$(find packages/projectairsim_cpp_client -maxdepth 1 -name 'ProjectAirSimCppClient-*-linux64.tar.gz' -print -quit)"
if [ -z "$archive" ]; then
echo "ProjectAirSim C++ client package was not created." >&2
exit 1
fi
mkdir -p _cpp_client_ci/package
tar -xzf "$archive" -C _cpp_client_ci/package
package_root="$(find _cpp_client_ci/package -mindepth 1 -maxdepth 1 -type d -print -quit)"
if [ -z "$package_root" ]; then
echo "ProjectAirSim C++ client package did not contain a top-level directory." >&2
exit 1
fi
package_config="$(find "$package_root" -name 'ProjectAirSimCppClientConfig.cmake' -print -quit)"
if [ -z "$package_config" ]; then
find "$package_root" -maxdepth 5 -print
echo "ProjectAirSim C++ client CMake config was not found in the package." >&2
exit 1
fi
echo "PACKAGE_ROOT=$package_root" >> "$GITHUB_ENV"
echo "PACKAGE_CONFIG_DIR=$(dirname "$package_config")" >> "$GITHUB_ENV"
- name: Smoke-test CMake package
shell: bash
run: |
package_config="$(find _cpp_client_ci/package -name 'ProjectAirSimCppClientConfig.cmake' -print -quit)"
if [ -z "$package_config" ]; then
find _cpp_client_ci/package -maxdepth 6 -print
echo "ProjectAirSim C++ client CMake config was not found before smoke test." >&2
exit 1
fi
package_config="$(realpath "$package_config")"
package_config_dir="$(dirname "$package_config")"
echo "Using ProjectAirSimCppClient_DIR=$package_config_dir"
mkdir -p _cpp_client_ci/consumer
cat > _cpp_client_ci/consumer/CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.20)
project(ProjectAirSimCppClientConsumer LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(ProjectAirSimCppClient REQUIRED)
add_executable(consumer main.cpp)
target_link_libraries(consumer PRIVATE ProjectAirSim::Client)
EOF
cat > _cpp_client_ci/consumer/main.cpp <<'EOF'
#include <ProjectAirsimClient/Client.h>
int main() {
return microsoft::projectairsim::client::Client::GetVersion() == nullptr;
}
EOF
cmake -S _cpp_client_ci/consumer \
-B _cpp_client_ci/consumer/build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DProjectAirSimCppClient_DIR="$package_config_dir" \
-DCMAKE_PREFIX_PATH="$package_config_dir"
cmake --build _cpp_client_ci/consumer/build --config Release --parallel
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: projectairsim-cpp-client-${{ matrix.os }}-linux64
path: |
packages/projectairsim_cpp_client/ProjectAirSimCppClient-*-linux64.tar.gz
packages/projectairsim_cpp_client/ProjectAirSimCppClient-*-linux64.tar.gz.sha256
if-no-files-found: error
ros2-humble:
name: ROS 2 Humble node build and unit tests
needs: changes
if: github.event_name == 'workflow_dispatch' || needs.changes.outputs.ros2 == 'true'
runs-on: ubuntu-22.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: Set up ROS 2 Humble
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: humble
- name: Install package dependencies
shell: bash
run: |
rosdep update
rosdep install \
--from-paths ros/projectairsim_ros2_cpp \
--ignore-src \
--rosdistro humble \
-y
- name: Build node
shell: bash
run: |
source /opt/ros/humble/setup.bash
colcon build \
--base-paths ros \
--packages-select projectairsim_ros2_cpp \
--cmake-args -DBUILD_TESTING=ON \
--event-handlers console_direct+
- name: Run unit tests
shell: bash
run: |
source /opt/ros/humble/setup.bash
source install/setup.bash
colcon test \
--base-paths ros \
--packages-select projectairsim_ros2_cpp \
--return-code-on-test-failure \
--event-handlers console_direct+
colcon test-result --test-result-base build --verbose