From 0622037966943546897169fa0722c7c8eb7d9159 Mon Sep 17 00:00:00 2001 From: EFanZh Date: Tue, 7 Jan 2025 23:40:59 +0800 Subject: [PATCH] Fix CI --- .github/workflows/coverage.yml | 2 +- .github/workflows/progress.yml | 1 + .github/workflows/rust.yml | 4 ++++ c++/.clang-tidy | 3 +++ c++/tests/leet-code/test-utilities.h | 28 ++++++++++++++++++---------- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index fbaf929ac..8c1ca58c7 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -12,7 +12,7 @@ jobs: - run: >- cargo xtask coverage --cmake-toolchain-file "$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" - --llvm-version 14 + --llvm-version 18 -o coverage/lcov.info - uses: codecov/codecov-action@v3 with: diff --git a/.github/workflows/progress.yml b/.github/workflows/progress.yml index 9bacd5f8c..a075dc5f1 100644 --- a/.github/workflows/progress.yml +++ b/.github/workflows/progress.yml @@ -4,6 +4,7 @@ jobs: build: runs-on: ubuntu-latest steps: + - run: sudo apt-get install --no-install-recommends libfontconfig-dev - uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 42720c6d4..1d8133bae 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -16,6 +16,8 @@ jobs: clippy: runs-on: ${{ matrix.os }} steps: + - if: ${{ matrix.os == 'ubuntu-latest' }} + run: sudo apt-get install --no-install-recommends libfontconfig-dev - uses: actions/checkout@v4 - run: rustup update - run: cargo clippy --workspace --all-targets --all-features -- -D warnings @@ -28,6 +30,8 @@ jobs: tests: runs-on: ${{ matrix.os }} steps: + - if: ${{ matrix.os == 'ubuntu-latest' }} + run: sudo apt-get install --no-install-recommends libfontconfig-dev - uses: actions/checkout@v4 - run: rustup update - run: cargo test --workspace diff --git a/c++/.clang-tidy b/c++/.clang-tidy index 7911b0576..722962f12 100644 --- a/c++/.clang-tidy +++ b/c++/.clang-tidy @@ -6,6 +6,7 @@ Checks: >- -altera-struct-pack-align, -altera-unroll-loops, -bugprone-easily-swappable-parameters, + -cppcoreguidelines-avoid-do-while, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-pro-bounds-pointer-arithmetic, -fuchsia-default-arguments-calls, @@ -13,7 +14,9 @@ Checks: >- -llvm-include-order, -llvmlibc-callee-namespace, -llvmlibc-implementation-in-namespace, + -llvmlibc-inline-function-decl, -llvmlibc-restrict-system-libc-headers, + -misc-include-cleaner, -misc-no-recursion, -modernize-use-trailing-return-type, -readability-convert-member-functions-to-static, diff --git a/c++/tests/leet-code/test-utilities.h b/c++/tests/leet-code/test-utilities.h index 84864f0c3..8daaf3298 100644 --- a/c++/tests/leet-code/test-utilities.h +++ b/c++/tests/leet-code/test-utilities.h @@ -12,7 +12,7 @@ namespace leet_code::test_utilities { template std::tuple>, data_structures::list_node::ListNode *> -make_list(C &&values) { +make_list(const C &values) { using data_structures::list_node::ListNode; using std::unique_ptr; using std::vector; @@ -24,7 +24,7 @@ make_list(C &&values) { auto *head = static_cast(nullptr); auto *tail = &head; - for (const auto &value : values) { + for (const auto value : values) { *tail = buffer.emplace_back(std::make_unique(value)).get(); tail = &(*tail)->next; } @@ -33,7 +33,7 @@ make_list(C &&values) { } template -std::tuple>, T *> make_tree(C &&values) { +std::tuple>, T *> make_tree(const C &values) { using std::deque; using std::unique_ptr; using std::vector; @@ -44,7 +44,7 @@ std::tuple>, T *> make_tree(C &&values) { const auto it_end = std::cend(values); if (it != it_end) { - root = buffer.emplace_back(std::make_unique(**it)).get(); + root = buffer.emplace_back(std::make_unique(**it)).get(); // NOLINT(bugprone-unchecked-optional-access) ++it; @@ -52,10 +52,14 @@ std::tuple>, T *> make_tree(C &&values) { auto *target = root; for (; it != it_end; ++it) { - if (*it) { - target->left = buffer.emplace_back(std::make_unique(**it)).get(); + { + const auto value = *it; - queue.emplace_back(target->left); + if (value) { + target->left = buffer.emplace_back(std::make_unique(*value)).get(); + + queue.emplace_back(target->left); + } } ++it; @@ -64,10 +68,14 @@ std::tuple>, T *> make_tree(C &&values) { break; } - if (*it) { - target->right = buffer.emplace_back(std::make_unique(**it)).get(); + { + const auto value = *it; + + if (value) { + target->right = buffer.emplace_back(std::make_unique(*value)).get(); - queue.emplace_back(target->right); + queue.emplace_back(target->right); + } } target = queue.front();