From bb92b9b0301f4229db3994d57fe664fec3c6eb0e Mon Sep 17 00:00:00 2001 From: JulienThevenoz Date: Wed, 10 Jan 2024 11:44:48 +0100 Subject: [PATCH] added CLI --sim option to test_flights_sim and made two different systemtests workflows as suggested by Wolfram --- .github/workflows/systemtests_real.yml | 58 ++++++++++++++++++++++++++ .github/workflows/systemtests_sim.yml | 0 systemtests/test_flights_sim.py | 12 +++++- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/systemtests_real.yml create mode 100644 .github/workflows/systemtests_sim.yml diff --git a/.github/workflows/systemtests_real.yml b/.github/workflows/systemtests_real.yml new file mode 100644 index 000000000..8a88f2db9 --- /dev/null +++ b/.github/workflows/systemtests_real.yml @@ -0,0 +1,58 @@ +name: System Tests Real + + +#run the physical tests only manually or on push from feature-systemtests-downloadUSD +on: + push: + branches: [ "feature-systemtests-downloadUSD" ] + # manual trigger + workflow_dispatch: + +jobs: + build: + runs-on: self-hosted + steps: + - name: Create workspace + id: step1 + run: | + cd ros2_ws/src || mkdir -p ros2_ws/src + - name: Checkout motion capture package + id: step2 + run: | + cd ros2_ws/src + ls motion_capture_tracking || git clone --branch ros2 --recursive https://github.com/IMRCLab/motion_capture_tracking.git + - name: Checkout Crazyswarm2 + id: step3 + uses: actions/checkout@v4 + with: + path: ros2_ws/src/crazyswarm2 + submodules: 'recursive' + - name: Build workspace + id: step4 + run: | + source /opt/ros/humble/setup.bash + cd ros2_ws + colcon build --symlink-install + + - name: Flight test + id: step5 + run: | + cd ros2_ws + source /opt/ros/humble/setup.bash + . install/local_setup.bash + export ROS_LOCALHOST_ONLY=1 + python3 src/crazyswarm2/systemtests/test_flights.py + + - name: Upload files + id: step6 + if: '!cancelled()' + uses: actions/upload-artifact@v3 + with: + name: pdf_rosbags_and_logs + path: | + ros2_ws/results + + + + + diff --git a/.github/workflows/systemtests_sim.yml b/.github/workflows/systemtests_sim.yml new file mode 100644 index 000000000..e69de29bb diff --git a/systemtests/test_flights_sim.py b/systemtests/test_flights_sim.py index 64ff7851f..120d61099 100644 --- a/systemtests/test_flights_sim.py +++ b/systemtests/test_flights_sim.py @@ -48,7 +48,7 @@ def clean_process(process:Popen) -> int : class TestFlights(unittest.TestCase): - SIM = True + SIM = False def __init__(self, methodName: str = "runTest") -> None: super().__init__(methodName) @@ -171,4 +171,12 @@ def test_multi_trajectory(self): if __name__ == '__main__': - unittest.main() + from argparse import ArgumentParser, Namespace + import sys + parser = ArgumentParser(description="Runs (real or simulated) flight tests with pytest framework") + parser.add_argument("--sim", action="store_true", help="Runs the test from the simulation backend") + args, other_args = parser.parse_known_args() + if args.sim : + TestFlights.SIM = True + + unittest.main(argv=[sys.argv[0]] + other_args)