Skip to content

Commit

Permalink
Format, make CI actually fail if not formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
qhdwight committed Sep 19, 2024
1 parent 05833a6 commit fdd738b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- name: Style Check
run: . /home/mrover/ros2_ws/src/mrover/venv/bin/activate && cd $GITHUB_WORKSPACE/src/mrover/ && ./style.sh
- name: Compiler Cache
if: github.event.pull_request.draft == false
uses: hendrikmuhs/[email protected]
- name: Build
if: github.event.pull_request.draft == false
Expand Down
5 changes: 2 additions & 3 deletions perception/object_detector/object_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ namespace mrover {
{"hitcount_max", mObjMaxHitcount, 10},
{"model_name", mModelName, "Large-Dataset"},
{"model_score_threshold", mModelScoreThreshold, 0.75},
{"model_nms_threshold", mModelNmsThreshold, 0.5}
};
{"model_nms_threshold", mModelNmsThreshold, 0.5}};

ParameterWrapper::declareParameters(this, params);

std::filesystem::path packagePath = std::filesystem::path{ament_index_cpp::get_package_prefix("mrover")} / ".." / ".." / "src" / "mrover";
std::filesystem::path packagePath = std::filesystem::path{ament_index_cpp::get_package_prefix("mrover")} / ".." / ".." / "src" / "mrover";

RCLCPP_INFO_STREAM(get_logger(), "Opening Model " << mModelName);

Expand Down
2 changes: 1 addition & 1 deletion perception/object_detector/pch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
#include <opencv2/imgproc.hpp>

// Ros Client Library
#include <ament_index_cpp/get_package_prefix.hpp>
#include <rclcpp/rclcpp.hpp>
#include <tf2_ros/transform_broadcaster.h>
#include <tf2_ros/transform_listener.h>
#include <ament_index_cpp/get_package_prefix.hpp>

// Messages
#include "sensor_msgs/image_encodings.hpp"
Expand Down
3 changes: 1 addition & 2 deletions perception/zed_wrapper/zed_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ namespace mrover {
{"depth_maximum_distance", mDepthMaximumDistance, 12.0},
{"use_builtin_visual_odom", mUseBuiltinPosTracking, false},
{"use_pose_smoothing", mUsePoseSmoothing, true},
{"use_area_memory", mUseAreaMemory, true}
};
{"use_area_memory", mUseAreaMemory, true}};

ParameterWrapper::declareParameters(this, params);

Expand Down
18 changes: 7 additions & 11 deletions style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# See: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -Eeuo pipefail

# Prevent globbing from failing if no files match
shopt -s nullglob

readonly RED='\033[0;31m'
readonly NC='\033[0m'
readonly YELLOW_BOLD='\033[1;33m'
Expand All @@ -19,7 +22,7 @@ CLANG_FORMAT_ARGS=(
if [ $# -eq 0 ] || [ "$1" != "--fix" ]; then
BLACK_ARGS+=("--diff") # Show difference
BLACK_ARGS+=("--check") # Exit with non-zero code if changes are required (for CI)
CLANG_FORMAT_ARGS+=("--dry-run")
CLANG_FORMAT_ARGS+=("--dry-run" "--Werror") # Don't modify, exit with non-zero code if changes are required
fi

function print_update_error() {
Expand Down Expand Up @@ -51,18 +54,11 @@ readonly MYPY_PATH=$(find_executable mypy 1.11.2)
## Run checks

# Add new directories with C++ code here:
readonly CPP_DIRS=(
./perception
./lie
./esw
./simulator
readonly CPP_FILES=(
./{perception,lie,esw,simulator}/**/*.{cpp,hpp,h,cu,cuh}
)

echo "Style checking C++ ..."
readonly CPP_FILES=$(find "${CPP_DIRS[@]}" -name "*.cpp" -o -name "*.hpp" -o -name "*.h" -o -name "*.cu")
for file in $CPP_FILES; do
"${CLANG_FORMAT_PATH}" "${CLANG_FORMAT_ARGS[@]}" -i "${file}"
done
"${CLANG_FORMAT_PATH}" "${CLANG_FORMAT_ARGS[@]}" -i "${CPP_FILES[@]}"
echo "Done"

# Add new directories with Python code here:
Expand Down

0 comments on commit fdd738b

Please sign in to comment.