From 835e5effe95a94d04a8c655a89e6b79ae5688bca Mon Sep 17 00:00:00 2001 From: Yannick Goumaz <61198661+ygoumaz@users.noreply.github.com> Date: Mon, 22 May 2023 13:50:58 +0200 Subject: [PATCH] Update workflows (#753) * new workflow * cleanup test sources * Restore cppcheck installation * test auto sync * fix clang format 14 * fix cppcheck * remove from PRs --- .github/workflows/sync_master_to_develop.yml | 43 +++++++++++++++++++ .github/workflows/tests_sources.yml | 9 ++-- webots_ros2_control/src/Ros2Control.cpp | 4 +- webots_ros2_control/src/Ros2ControlSystem.cpp | 4 +- .../include/webots_ros2_driver/utils/Math.hpp | 2 +- webots_ros2_driver/src/WebotsNode.cpp | 8 +++- .../src/plugins/static/Ros2LED.cpp | 7 ++- webots_ros2_driver/src/utils/Math.cpp | 2 +- 8 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/sync_master_to_develop.yml diff --git a/.github/workflows/sync_master_to_develop.yml b/.github/workflows/sync_master_to_develop.yml new file mode 100644 index 000000000..67af01022 --- /dev/null +++ b/.github/workflows/sync_master_to_develop.yml @@ -0,0 +1,43 @@ +name: Branch synchronizer + +on: + schedule: + - cron: '0 04 * * *' + +jobs: + sync-develop-with-master: + runs-on: ubuntu-latest + steps: + - name: Checkout master + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + ref: master + - name: Check for diff + id: check-diff + run: | + git fetch origin develop + git checkout develop + if [ -n "$(git diff develop...master)" ]; then + echo "Develop needs sync with master!"; + git checkout master + export BRANCH_NAME=sync-master-$(git rev-parse --short HEAD) + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + git checkout -b ${BRANCH_NAME} + git push origin ${BRANCH_NAME} + echo "create_pull_request=1" >> $GITHUB_OUTPUT + else + echo "Develop is already up to date."; + echo "create_pull_request=0" >> $GITHUB_OUTPUT + fi + - name: Create Pull Request if necessary + if: ${{ steps.check-diff.outputs.create_pull_request == 1 }} + uses: repo-sync/pull-request@v2.6.2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + source_branch: ${{ env.BRANCH_NAME }} + destination_branch: develop + pr_title: Merge master into develop + pr_body: Synchronizes changes of master branch into develop branch. + pr_reviewer: Maintainers diff --git a/.github/workflows/tests_sources.yml b/.github/workflows/tests_sources.yml index 239e5a2f9..5a378e426 100644 --- a/.github/workflows/tests_sources.yml +++ b/.github/workflows/tests_sources.yml @@ -21,24 +21,21 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04] + os: [ubuntu-22.04] python: ['3.10'] include: - - os: ubuntu-20.04 - DEPENDENCIES_INSTALLATION: "sudo apt -y install clang-format-10 cppcheck" + - os: ubuntu-22.04 + DEPENDENCIES_INSTALLATION: "sudo apt -y install cppcheck" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - if: github.event_name == 'schedule' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'test sources') with: submodules: true - name: Set up Python 3.10 - if: github.event_name == 'schedule' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'test sources') uses: actions/setup-python@v4 with: python-version: '3.10' - name: Test Sources - if: github.event_name == 'schedule' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'test sources') run: | ${{ matrix.DEPENDENCIES_INSTALLATION }} pip install -r tests/sources/requirements.txt diff --git a/webots_ros2_control/src/Ros2Control.cpp b/webots_ros2_control/src/Ros2Control.cpp index 35955f156..d1b176215 100644 --- a/webots_ros2_control/src/Ros2Control.cpp +++ b/webots_ros2_control/src/Ros2Control.cpp @@ -34,7 +34,9 @@ const double CONTROLLER_MANAGER_ALLOWED_SAMPLE_ERROR_MS = 1.0; namespace webots_ros2_control { - Ros2Control::Ros2Control() { mNode = NULL; } + Ros2Control::Ros2Control() { + mNode = NULL; + } void Ros2Control::step() { const int nowMs = wb_robot_get_time() * 1000.0; diff --git a/webots_ros2_control/src/Ros2ControlSystem.cpp b/webots_ros2_control/src/Ros2ControlSystem.cpp index 3dd151fe2..6908ea4d4 100644 --- a/webots_ros2_control/src/Ros2ControlSystem.cpp +++ b/webots_ros2_control/src/Ros2ControlSystem.cpp @@ -28,7 +28,9 @@ #include namespace webots_ros2_control { - Ros2ControlSystem::Ros2ControlSystem() { mNode = NULL; } + Ros2ControlSystem::Ros2ControlSystem() { + mNode = NULL; + } void Ros2ControlSystem::init(webots_ros2_driver::WebotsNode *node, const hardware_interface::HardwareInfo &info) { mNode = node; for (hardware_interface::ComponentInfo component : info.joints) { diff --git a/webots_ros2_driver/include/webots_ros2_driver/utils/Math.hpp b/webots_ros2_driver/include/webots_ros2_driver/utils/Math.hpp index 33edcb4a3..3151df87d 100644 --- a/webots_ros2_driver/include/webots_ros2_driver/utils/Math.hpp +++ b/webots_ros2_driver/include/webots_ros2_driver/utils/Math.hpp @@ -24,6 +24,6 @@ namespace webots_ros2_driver { void axisAngleToQuaternion(const double *axisAngle, geometry_msgs::msg::Quaternion &q); void quaternionToAxisAngle(const geometry_msgs::msg::Quaternion &q, double *axisAngle); - double interpolateLookupTable(double value, std::vector &table); + double interpolateLookupTable(double value, const std::vector &table); } // namespace webots_ros2_driver #endif diff --git a/webots_ros2_driver/src/WebotsNode.cpp b/webots_ros2_driver/src/WebotsNode.cpp index 58c8dc7e0..8fc91857b 100644 --- a/webots_ros2_driver/src/WebotsNode.cpp +++ b/webots_ros2_driver/src/WebotsNode.cpp @@ -44,7 +44,9 @@ namespace webots_ros2_driver { bool gShutdownSignalReceived = false; - void handleSigint(int sig) { gShutdownSignalReceived = true; } + void handleSigint(int sig) { + gShutdownSignalReceived = true; + } WebotsNode::WebotsNode(std::string name) : Node(name), mPluginLoader(gPluginInterfaceName, gPluginInterface) { mRobotDescription = this->declare_parameter("robot_description", ""); @@ -240,5 +242,7 @@ namespace webots_ros2_driver { mClient->async_send_request(request); } - void WebotsNode::handleSignals() { signal(SIGINT, handleSigint); } + void WebotsNode::handleSignals() { + signal(SIGINT, handleSigint); + } } // end namespace webots_ros2_driver diff --git a/webots_ros2_driver/src/plugins/static/Ros2LED.cpp b/webots_ros2_driver/src/plugins/static/Ros2LED.cpp index 69bb9d8d8..e601d01af 100644 --- a/webots_ros2_driver/src/plugins/static/Ros2LED.cpp +++ b/webots_ros2_driver/src/plugins/static/Ros2LED.cpp @@ -31,7 +31,10 @@ namespace webots_ros2_driver { topicName, rclcpp::SensorDataQoS().reliable(), std::bind(&Ros2LED::onMessageReceived, this, std::placeholders::_1)); } - void Ros2LED::step() {} + void Ros2LED::step() { + } - void Ros2LED::onMessageReceived(const std_msgs::msg::Int32::SharedPtr message) { wb_led_set(mLED, message->data); } + void Ros2LED::onMessageReceived(const std_msgs::msg::Int32::SharedPtr message) { + wb_led_set(mLED, message->data); + } } // namespace webots_ros2_driver diff --git a/webots_ros2_driver/src/utils/Math.cpp b/webots_ros2_driver/src/utils/Math.cpp index 72b612234..fe467a65a 100644 --- a/webots_ros2_driver/src/utils/Math.cpp +++ b/webots_ros2_driver/src/utils/Math.cpp @@ -115,7 +115,7 @@ namespace webots_ros2_driver { return slope * (value - startX) + startY; } - double interpolateLookupTable(double value, std::vector &table) { + double interpolateLookupTable(double value, const std::vector &table) { if (!table.size()) return value; const int size = table.size();