Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various CI failures #132

Merged
merged 5 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ Checks: >
performance-*,
portability-*,
readability-*,
-bugprone-unchecked-optional-access,
-concurrency-mt-unsafe,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-misc-include-cleaner,
-misc-non-private-member-variables-in-classes,
-modernize-avoid-bind,
-modernize-use-trailing-return-type,
-readability-avoid-unconditional-preprocessor-if,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-magic-numbers,
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
cmake:
name: cmake (${{ matrix.ros_distro }}, ${{ matrix.preset }}, ${{ matrix.compiler.name }})
strategy:
fail-fast: false
matrix:
ros_distro: [humble, rolling]
preset: [debug, release, asan, codecov]
Expand All @@ -18,6 +19,8 @@ jobs:
exclude:
- preset: codecov
compiler: { name: Clang }
- preset: codecov
ros_distro: humble
runs-on: ubuntu-22.04
container: ghcr.io/picknikrobotics/rsl:upstream-${{ matrix.ros_distro }}
env:
Expand Down Expand Up @@ -52,7 +55,7 @@ jobs:
run: cmake --build build/${{ matrix.preset }} --target tidy
- name: Generate LCOV report
if: ${{ matrix.preset == 'codecov' }}
run: lcov -c -d . -o coverage.info --no-external --exclude "*/build/**"
run: lcov -c -d . -o coverage.info --no-external --exclude "*/build/**" --ignore-errors mismatch
- uses: codecov/codecov-action@v3
if: ${{ matrix.preset == 'codecov' }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
container: ghcr.io/picknikrobotics/rsl:upstream-rolling
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Source ROS
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: pre-commit
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
- name: Install clang-format-14
run: sudo apt-get install clang-format-14
Expand Down
2 changes: 1 addition & 1 deletion include/rsl/monad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ template <typename T, typename Fn, typename = std::enable_if_t<rsl::is_optional<
typename = std::enable_if_t<std::is_invocable_v<
Fn, typename std::remove_cv_t<std::remove_reference_t<T>>::value_type>>>
[[nodiscard]] constexpr auto operator|(T&& opt, Fn&& fn) {
return rsl::mbind(opt, fn);
return rsl::mbind(std::forward<T>(opt), std::forward<Fn>(fn));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

find_package(Catch2 3.5.0 REQUIRED)
find_package(Catch2 3.6.0 REQUIRED)
find_package(range-v3 REQUIRED)

# Test library
Expand Down
20 changes: 10 additions & 10 deletions tests/monad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@

using namespace std::string_literals;

static constexpr auto maybe_non_zero(int in) {
return (in != 0) ? std::optional(in) : std::nullopt;
}
namespace {
constexpr auto maybe_non_zero(int in) { return (in != 0) ? std::optional(in) : std::nullopt; }

static auto maybe_lt_3_round(double in) {
auto maybe_lt_3_round(double in) {
return (in < 3) ? std::optional<int>(std::round(in)) : std::nullopt;
}

static auto unsafe_divide_4_by(double val) {
auto unsafe_divide_4_by(double val) {
if (val == 0) throw std::runtime_error("divide by zero");
return 4.0 / val;
}

template <typename T>
using Result = tl::expected<T, std::string>;

static Result<double> divide(double x, double y) {
Result<double> divide(double x, double y) {
if (y == 0) return tl::unexpected("divide by 0"s);
return x / y;
}

static Result<double> multiply(double x, double y) { return x * y; }
Result<double> multiply(double x, double y) { return x * y; }

static Result<double> divide_3(double x) { return divide(3, x); }
Result<double> divide_3(double x) { return divide(3, x); }

static Result<double> multiply_3(double x) { return multiply(3, x); }
Result<double> multiply_3(double x) { return multiply(3, x); }
} // namespace

TEST_CASE("rsl::mbind") {
SECTION("Optional value") {
Expand Down Expand Up @@ -210,7 +210,7 @@ TEST_CASE("operator|") {
auto const k = [](auto x) { return [=](auto) { return x; }; };
auto const mul = [](auto x, auto y) { return x * y; };
auto const bind1 = [](auto fn, auto x) { return [=](auto y) { return fn(x, y); }; };
auto const three = [](auto) { return int{3}; };
auto const three = [](auto) { return 3; };
auto const wrap = [](auto x) { return Result<decltype(x)>{x}; };

CHECK((int{5} | i) == 5);
Expand Down
2 changes: 1 addition & 1 deletion tests/overload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <variant>

TEST_CASE("rsl::Overload") {
enum class Type { INT, FLOAT, STRING };
enum class Type : std::uint8_t { INT, FLOAT, STRING };

auto const overload =
rsl::Overload{[](int) { return Type::INT; }, [](float) { return Type::FLOAT; },
Expand Down
4 changes: 3 additions & 1 deletion tests/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

#include <thread>

static auto const* const rng = &rsl::rng({0, 1});
namespace {
auto const* const rng = &rsl::rng({0, 1});
}

TEST_CASE("rsl::rng") {
SECTION("Repeated calls in thread yield same object") {
Expand Down
2 changes: 1 addition & 1 deletion tests/static_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ TEST_CASE("rsl::StaticString") {
}

TEST_CASE("rsl::to_string") {
CHECK(rsl::to_string(rsl::StaticString<0>()) == ""s);
CHECK(rsl::to_string(rsl::StaticString<0>()).empty());
CHECK(rsl::to_string(rsl::StaticString<10>("happy"s)) == "happy"s);
}
4 changes: 3 additions & 1 deletion tests/try.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

using ExpectedType = tl::expected<int, std::string>;

static ExpectedType check_try_macro(ExpectedType const& expected) {
namespace {
ExpectedType check_try_macro(ExpectedType const& expected) {
ExpectedType::value_type value = TRY(expected);
return ++value;
}
} // namespace

TEST_CASE("TRY") {
CHECK(check_try_macro(ExpectedType(42)) == 43);
Expand Down
Loading