-
Notifications
You must be signed in to change notification settings - Fork 10
264 lines (234 loc) · 9.56 KB
/
Copy pathci.yml
File metadata and controls
264 lines (234 loc) · 9.56 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
# GitHub Actions CI for Poseidon (ROS Noetic / Catkin)
# - Builds and tests the Catkin workspace on the self-hosted ROS Noetic runner (Ubuntu 20.04/Focal)
# - Publishes JUnit test results and optional coverage output
# - Keeps configuration minimal and aligned with repository conventions
name: CI (ROS Noetic)
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
workflow_dispatch:
inputs:
run_hardware_e2e:
description: "Run hardware E2E (backend websocket + headless UI)"
required: false
type: boolean
default: false
defaults:
run:
shell: bash
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-test:
name: Build and Test
runs-on: [self-hosted, Linux, ARM64]
env:
CATKIN_WS: src/workspace
# Adjust blacklist to skip heavy/non-critical packages on CI if needed
CATKIN_BLACKLIST_PACKAGES: "mavros;inertial_sense;velodyne;ins_piksi;velodyne_pointcloud;velodyne_driver;velodyne_laserscan;gnss_mosaic_x5;tf"
steps:
- name: Ensure base packages
run: |
set -eo pipefail
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \
git ca-certificates \
build-essential cmake ccache \
python3-pip python3-rosdep \
gcovr \
ros-noetic-catkin ros-noetic-rostest ros-noetic-rosbash \
ros-noetic-diagnostic-updater ros-noetic-angles \
ros-noetic-tf2-geometry-msgs \
ros-noetic-pcl-ros ros-noetic-pcl-conversions libpcl-dev \
ros-noetic-sbg-driver \
ros-noetic-roslint ros-noetic-nodelet ros-noetic-dynamic-reconfigure ros-noetic-sensor-msgs \
libopencv-dev libexiv2-dev libwebsocketpp-dev \
rapidjson-dev libssl-dev libgps-dev libboost-system-dev \
python3-lxml libxml2-dev libxslt1-dev \
lcov \
python3-websockets
sudo -H python3 -m pip install --no-cache-dir catkin-lint flake8 coverage pytest
if [ ! -f /etc/ros/rosdep/sources.list.d/20-default.list ]; then
sudo rosdep init
fi
rosdep update
- name: Pre-clean workspace (sudo)
run: |
set -eo pipefail
sudo rm -rf "$GITHUB_WORKSPACE"/*
sudo mkdir -p "$GITHUB_WORKSPACE"
sudo chown -R "$USER:$USER" "$GITHUB_WORKSPACE"
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Clean Catkin workspace (self-hosted)
run: |
set -eo pipefail
if [ -d "$CATKIN_WS" ]; then
sudo rm -rf "$CATKIN_WS/build" "$CATKIN_WS/devel" "$CATKIN_WS/logs"
fi
- name: Resolve ROS package dependencies
run: |
set -eo pipefail
source /opt/ros/noetic/setup.bash
rosdep install --rosdistro noetic --from-paths "$CATKIN_WS/src" --ignore-src -r -y
- name: Lint (Python and Catkin)
run: |
set -eo pipefail
# Keep lint non-blocking initially; tighten later as needed
flake8 georef || true
catkin_lint "$CATKIN_WS/src" || true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: JavaScript tests (www/webroot/js)
run: |
set -eo pipefail
JS_DIR="www/webroot/js"
if [ ! -f "$JS_DIR/package.json" ]; then
echo "No package.json in $JS_DIR; skipping JS tests."
exit 0
fi
cd "$JS_DIR"
npm ci || npm install
npm test --if-present
- name: Configure ccache
run: |
set -eo pipefail
export CCACHE_DIR="$HOME/.ccache"
ccache -M 1G
- name: Build (Debug + sanitizers)
env:
CC: "ccache gcc"
CXX: "ccache g++"
run: |
set -eo pipefail
source /opt/ros/noetic/setup.bash
cd "$CATKIN_WS"
catkin_make \
-DCMAKE_BUILD_TYPE=Debug \
-DCATKIN_BLACKLIST_PACKAGES="$CATKIN_BLACKLIST_PACKAGES" \
-DCMAKE_CXX_FLAGS="-O0 -g --coverage" \
-DCMAKE_EXE_LINKER_FLAGS="--coverage"
- name: Run tests
run: |
set -eo pipefail
source /opt/ros/noetic/setup.bash
cd "$CATKIN_WS"
catkin_make run_tests -DCATKIN_BLACKLIST_PACKAGES="$CATKIN_BLACKLIST_PACKAGES"
# Report results but do not fail the whole job on first adoption
catkin_test_results build/test_results || true
- name: Setup Playwright (hardware E2E)
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.run_hardware_e2e == 'true') || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')) }}
run: |
set -eo pipefail
cd test/e2e
npm install --no-package-lock
npx playwright install --with-deps chromium
- name: Run hardware E2E (backend + headless UI)
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.run_hardware_e2e == 'true') || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')) }}
env:
# Hardware-specific: set this to the USB serial adapter used for injecting fake NMEA DBT strings.
# Must NOT point at /dev/sonar.
DIAGNOSTICS_FAKE_SERIAL_PORT: "/dev/ttyUSB1"
# Relaxed defaults; adjust if the bench needs longer to come up.
POSEIDON_E2E_WAIT_SECONDS: "120"
DIAGNOSTICS_WS_LAUNCH_TIMEOUT: "120"
POSEIDON_E2E_TIMEOUT_MS: "120000"
POSEIDON_E2E_LAUNCH_AS_ROOT: "1"
# Fail early if these expected rows disappear.
POSEIDON_E2E_REQUIRED_DIAGNOSTICS: "GNSS Fix,IMU Communication,Sonar Communication"
# Avoid port/node conflicts with a system-installed Poseidon service on the bench.
POSEIDON_E2E_EXCLUSIVE: "1"
# Make comm diagnostics more tolerant on benches where rates can be lower than nominal.
POSEIDON_DIAG_IMU_HZ: "5"
POSEIDON_DIAG_IMU_WINDOW: "2.0"
POSEIDON_DIAG_IMU_RATIO: "0.5"
POSEIDON_DIAG_SONAR_HZ: "1"
POSEIDON_DIAG_SONAR_WINDOW: "5.0"
POSEIDON_DIAG_SONAR_RATIO: "0.2"
POSEIDON_E2E_DIAGNOSTICS_REFRESH_DELAY_MS: "7000"
run: |
set -eo pipefail
bash test/e2e/run_poseidon_e2e.sh
- name: Upload hardware E2E artifacts
if: ${{ always() && ((github.event_name == 'workflow_dispatch' && github.event.inputs.run_hardware_e2e == 'true') || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'))) }}
uses: actions/upload-artifact@v4
with:
name: e2e-artifacts
path: test/e2e/artifacts
if-no-files-found: ignore
- name: C++ coverage report (gcovr)
run: |
set -eo pipefail
# gcovr 4.x cannot emit XML and HTML in one invocation; split to avoid skipping HTML output.
gcovr -r "$CATKIN_WS/src" "$CATKIN_WS" --xml -o coverage-cpp.xml || true
gcovr -r "$CATKIN_WS/src" "$CATKIN_WS" --html --html-details -o coverage-cpp.html || true
- name: Python coverage
run: |
set -eo pipefail
cd "$GITHUB_WORKSPACE"
coverage run -m pytest src/workspace/src || true
coverage xml -o coverage-python.xml || true
coverage html -d coverage-python || true
- name: Upload JS coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-js
path: www/webroot/js/coverage
if-no-files-found: ignore
- name: Upload JUnit test results
if: always()
uses: actions/upload-artifact@v4
with:
name: junit-test-results
path: |
src/workspace/build/test_results
if-no-files-found: ignore
- name: Upload C++ coverage artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-cpp
path: |
coverage-cpp.xml
coverage-cpp.html
if-no-files-found: ignore
- name: Upload Python coverage artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-python
path: |
coverage-python.xml
coverage-python
if-no-files-found: ignore
- name: Collect C++ coverage (optional)
run: |
set -eo pipefail
# Try to collect coverage; ignore failures if toolchain is not configured for it
lcov --directory . --capture --output-file coverage.info || true
lcov --remove coverage.info '/usr/*' '*/devel/*' '*/opt/ros/*' --output-file coverage.info || true
continue-on-error: true
- name: Upload coverage artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-lcov
path: coverage.info
if-no-files-found: ignore
- name: Coverage summary (CPP/Python/JS)
if: always()
run: |
set -eo pipefail
python3 .github/workflows/scripts/coverage_summary.py
# Self-hosted runner notes:
# - Runner must be registered on the repository/org with labels: self-hosted, Linux, ARM64.
# - Machine should run Ubuntu 20.04 with ROS Noetic installed in /opt/ros/noetic.
# - Ensure runner user has passwordless sudo for apt/rosdep during the workflow.