Skip to content

Commit 0f15eea

Browse files
committed
ci(mavros): merge mission+offboard into one workflow, migrate to noetic and Python 3
Consolidate mavros_mission_tests.yml and mavros_offboard_tests.yml into a single mavros_tests.yml with a matrix strategy. Switch from docker-in-docker with px4-dev-ros-melodic to a native container using px4-dev-ros-noetic, enabling ccache and composite actions (setup-ccache, build-gazebo-sitl, save-ccache). Migrate all five MAVROS Python test files from Python 2 to Python 3 (remove six/xrange, from __future__ imports, replace px4tools with pyulog for estimator analysis). Bump git-auto-commit-action from v4 to v7 in ekf_update_change_indicator.yml. Signed-off-by: Ramon Roche <mrpollo@gmail.com>
1 parent 9eddd0c commit 0f15eea

File tree

9 files changed

+142
-136
lines changed

9 files changed

+142
-136
lines changed

.github/workflows/ekf_update_change_indicator.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
GIT_COMMITTER_NAME: PX4BuildBot
1818

1919
steps:
20-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v6
2121
with:
2222
fetch-depth: 0
2323

@@ -39,7 +39,7 @@ jobs:
3939
4040
- name: auto-commit any changes to change indication
4141
if: steps.diff-check.outputs.CHANGE_INDICATED == 'true'
42-
uses: stefanzweifel/git-auto-commit-action@v4
42+
uses: stefanzweifel/git-auto-commit-action@v7
4343
with:
4444
file_pattern: 'src/modules/ekf2/test/change_indication/*.csv'
4545
commit_user_name: ${{ env.GIT_COMMITTER_NAME }}

.github/workflows/mavros_mission_tests.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/mavros_offboard_tests.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/mavros_tests.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: MAVROS Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths-ignore:
8+
- 'docs/**'
9+
pull_request:
10+
branches:
11+
- '**'
12+
paths-ignore:
13+
- 'docs/**'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
test:
21+
name: "MAVROS ${{ matrix.config.name }}"
22+
runs-on: [runs-on,runner=4cpu-linux-x64,image=ubuntu24-full-x64,"run-id=${{ github.run_id }}",spot=false,extras=s3-cache]
23+
permissions:
24+
contents: read
25+
container:
26+
image: px4io/px4-dev-ros-noetic:2021-09-08
27+
env:
28+
PX4_SBOM_DISABLE: 1
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
config:
33+
- {name: "Mission", test_file: "mavros_posix_test_mission.test", params: "mission:=MC_mission_box vehicle:=iris"}
34+
- {name: "Offboard", test_file: "mavros_posix_tests_offboard_posctl.test", params: "vehicle:=iris"}
35+
steps:
36+
- uses: runs-on/action@v2
37+
38+
- uses: actions/checkout@v6
39+
with:
40+
fetch-depth: 1
41+
42+
- name: Setup - Configure Git Safe Directory
43+
run: git config --system --add safe.directory '*'
44+
45+
- name: Setup - Install Python Test Dependencies
46+
run: pip3 install -r Tools/setup/requirements.txt
47+
48+
- uses: ./.github/actions/setup-ccache
49+
id: ccache
50+
with:
51+
cache-key-prefix: ccache-sitl-gazebo-classic
52+
max-size: 350M
53+
54+
- uses: ./.github/actions/build-gazebo-sitl
55+
56+
- name: Test - MAVROS ${{ matrix.config.name }}
57+
run: |
58+
./test/rostest_px4_run.sh \
59+
${{ matrix.config.test_file }} \
60+
${{ matrix.config.params }}
61+
timeout-minutes: 10
62+
63+
- uses: ./.github/actions/save-ccache
64+
if: always()
65+
with:
66+
cache-primary-key: ${{ steps.ccache.outputs.cache-primary-key }}
67+
68+
- name: Upload - Failed Test Logs
69+
if: failure()
70+
uses: actions/upload-artifact@v7
71+
with:
72+
name: failed-mavros-${{ matrix.config.name }}-logs.zip
73+
path: |
74+
logs/**/**/**/*.log
75+
logs/**/**/**/*.ulg

integrationtests/python_src/px4_it/mavros/mavros_offboard_attctl_test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2
1+
#!/usr/bin/env python3
22
#***************************************************************************
33
#
44
# Copyright (c) 2015 PX4 Development Team. All rights reserved.
@@ -35,9 +35,6 @@
3535
#
3636
# @author Andreas Antener <andreas@uaventure.com>
3737
#
38-
# The shebang of this file is currently Python2 because some
39-
# dependencies such as pymavlink don't play well with Python3 yet.
40-
from __future__ import division
4138

4239
PKG = 'px4'
4340

@@ -46,7 +43,6 @@
4643
from mavros_msgs.msg import AttitudeTarget
4744
from mavros_test_common import MavrosTestCommon
4845
from pymavlink import mavutil
49-
from six.moves import xrange
5046
from std_msgs.msg import Header
5147
from threading import Thread
5248
from tf.transformations import quaternion_from_euler
@@ -124,7 +120,7 @@ def test_attctl(self):
124120
loop_freq = 2 # Hz
125121
rate = rospy.Rate(loop_freq)
126122
crossed = False
127-
for i in xrange(timeout * loop_freq):
123+
for i in range(timeout * loop_freq):
128124
if (self.local_position.pose.position.x > boundary_x and
129125
self.local_position.pose.position.y > boundary_y and
130126
self.local_position.pose.position.z > boundary_z):

integrationtests/python_src/px4_it/mavros/mavros_offboard_posctl_test.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2
1+
#!/usr/bin/env python3
22
#***************************************************************************
33
#
44
# Copyright (c) 2015 PX4 Development Team. All rights reserved.
@@ -35,9 +35,6 @@
3535
#
3636
# @author Andreas Antener <andreas@uaventure.com>
3737
#
38-
# The shebang of this file is currently Python2 because some
39-
# dependencies such as pymavlink don't play well with Python3 yet.
40-
from __future__ import division
4138

4239
PKG = 'px4'
4340

@@ -48,7 +45,6 @@
4845
from mavros_msgs.msg import ParamValue
4946
from mavros_test_common import MavrosTestCommon
5047
from pymavlink import mavutil
51-
from six.moves import xrange
5248
from std_msgs.msg import Header
5349
from threading import Thread
5450
from tf.transformations import quaternion_from_euler
@@ -132,7 +128,7 @@ def reach_position(self, x, y, z, timeout):
132128
loop_freq = 2 # Hz
133129
rate = rospy.Rate(loop_freq)
134130
reached = False
135-
for i in xrange(timeout * loop_freq):
131+
for i in range(timeout * loop_freq):
136132
if self.is_at_position(self.pos.pose.position.x,
137133
self.pos.pose.position.y,
138134
self.pos.pose.position.z, self.radius):
@@ -174,7 +170,7 @@ def test_posctl(self):
174170
positions = ((0, 0, 0), (50, 50, 20), (50, -50, 20), (-50, -50, 20),
175171
(0, 0, 20))
176172

177-
for i in xrange(len(positions)):
173+
for i in range(len(positions)):
178174
self.reach_position(positions[i][0], positions[i][1],
179175
positions[i][2], 30)
180176

integrationtests/python_src/px4_it/mavros/mavros_offboard_yawrate_test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2
1+
#!/usr/bin/env python3
22
#***************************************************************************
33
#
44
# Copyright (c) 2020 PX4 Development Team. All rights reserved.
@@ -35,16 +35,13 @@
3535
# @author Pedro Roque <padr@kth.se>
3636
#
3737

38-
from __future__ import division
39-
4038
PKG = 'px4'
4139

4240
import rospy
4341
from geometry_msgs.msg import Quaternion, Vector3
4442
from mavros_msgs.msg import AttitudeTarget
4543
from mavros_test_common import MavrosTestCommon
4644
from pymavlink import mavutil
47-
from six.moves import xrange
4845
from std_msgs.msg import Header
4946
from threading import Thread
5047
from tf.transformations import quaternion_from_euler
@@ -134,7 +131,7 @@ def test_attctl(self):
134131
loop_freq = 2 # Hz
135132
rate = rospy.Rate(loop_freq)
136133
crossed = False
137-
for i in xrange(timeout * loop_freq):
134+
for i in range(timeout * loop_freq):
138135
if (self.local_position.pose.position.x < boundary_x and
139136
self.local_position.pose.position.x > -boundary_x and
140137
self.local_position.pose.position.y < boundary_y and

integrationtests/python_src/px4_it/mavros/mavros_test_common.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python2
2-
from __future__ import division
1+
#!/usr/bin/env python3
32

43
import unittest
54
import rospy
@@ -11,7 +10,6 @@
1110
WaypointPush
1211
from pymavlink import mavutil
1312
from sensor_msgs.msg import NavSatFix, Imu
14-
from six.moves import xrange
1513

1614

1715
class MavrosTestCommon(unittest.TestCase):
@@ -183,7 +181,7 @@ def set_arm(self, arm, timeout):
183181
loop_freq = 1 # Hz
184182
rate = rospy.Rate(loop_freq)
185183
arm_set = False
186-
for i in xrange(timeout * loop_freq):
184+
for i in range(timeout * loop_freq):
187185
if self.state.armed == arm:
188186
arm_set = True
189187
rospy.loginfo("set arm success | seconds: {0} of {1}".format(
@@ -213,7 +211,7 @@ def set_mode(self, mode, timeout):
213211
loop_freq = 1 # Hz
214212
rate = rospy.Rate(loop_freq)
215213
mode_set = False
216-
for i in xrange(timeout * loop_freq):
214+
for i in range(timeout * loop_freq):
217215
if self.state.mode == mode:
218216
mode_set = True
219217
rospy.loginfo("set mode success | seconds: {0} of {1}".format(
@@ -247,7 +245,7 @@ def set_param(self, param_id, param_value, timeout):
247245
loop_freq = 1 # Hz
248246
rate = rospy.Rate(loop_freq)
249247
param_set = False
250-
for i in xrange(timeout * loop_freq):
248+
for i in range(timeout * loop_freq):
251249
try:
252250
res = self.set_param_srv(param_id, param_value)
253251
if res.success:
@@ -274,7 +272,7 @@ def wait_for_topics(self, timeout):
274272
loop_freq = 1 # Hz
275273
rate = rospy.Rate(loop_freq)
276274
simulation_ready = False
277-
for i in xrange(timeout * loop_freq):
275+
for i in range(timeout * loop_freq):
278276
if all(value for value in self.sub_topics_ready.values()):
279277
simulation_ready = True
280278
rospy.loginfo("simulation topics ready | seconds: {0} of {1}".
@@ -297,7 +295,7 @@ def wait_for_landed_state(self, desired_landed_state, timeout, index):
297295
loop_freq = 10 # Hz
298296
rate = rospy.Rate(loop_freq)
299297
landed_state_confirmed = False
300-
for i in xrange(timeout * loop_freq):
298+
for i in range(timeout * loop_freq):
301299
if self.extended_state.landed_state == desired_landed_state:
302300
landed_state_confirmed = True
303301
rospy.loginfo("landed state confirmed | seconds: {0} of {1}".
@@ -325,7 +323,7 @@ def wait_for_vtol_state(self, transition, timeout, index):
325323
loop_freq = 10 # Hz
326324
rate = rospy.Rate(loop_freq)
327325
transitioned = False
328-
for i in xrange(timeout * loop_freq):
326+
for i in range(timeout * loop_freq):
329327
if transition == self.extended_state.vtol_state:
330328
rospy.loginfo("transitioned | seconds: {0} of {1}".format(
331329
i / loop_freq, timeout))
@@ -348,7 +346,7 @@ def clear_wps(self, timeout):
348346
loop_freq = 1 # Hz
349347
rate = rospy.Rate(loop_freq)
350348
wps_cleared = False
351-
for i in xrange(timeout * loop_freq):
349+
for i in range(timeout * loop_freq):
352350
if not self.mission_wp.waypoints:
353351
wps_cleared = True
354352
rospy.loginfo("clear waypoints success | seconds: {0} of {1}".
@@ -381,7 +379,7 @@ def send_wps(self, waypoints, timeout):
381379
rate = rospy.Rate(loop_freq)
382380
wps_sent = False
383381
wps_verified = False
384-
for i in xrange(timeout * loop_freq):
382+
for i in range(timeout * loop_freq):
385383
if not wps_sent:
386384
try:
387385
res = self.wp_push_srv(start_index=0, waypoints=waypoints)
@@ -417,7 +415,7 @@ def wait_for_mav_type(self, timeout):
417415
loop_freq = 1 # Hz
418416
rate = rospy.Rate(loop_freq)
419417
res = False
420-
for i in xrange(timeout * loop_freq):
418+
for i in range(timeout * loop_freq):
421419
try:
422420
res = self.get_param_srv('MAV_TYPE')
423421
if res.success:

0 commit comments

Comments
 (0)