From a5496840e5f834ac1c5ae142e4b5f3012a9ab4b6 Mon Sep 17 00:00:00 2001 From: Bjoern Date: Fri, 15 Nov 2024 17:40:38 +0100 Subject: [PATCH 01/24] format --- src/output/graphics/renderers/HudRenderer.cpp | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/output/graphics/renderers/HudRenderer.cpp b/src/output/graphics/renderers/HudRenderer.cpp index 0f0d19c6..9ffd6a58 100644 --- a/src/output/graphics/renderers/HudRenderer.cpp +++ b/src/output/graphics/renderers/HudRenderer.cpp @@ -33,22 +33,23 @@ void HudRenderer::renderAltimeter() const { static_cast(graphics::UNIT_TO_PIXEL_RATIO); // Step size of the altimeter const int currentAltitude = - static_cast(world.getHiker().getPosition().y * - static_cast(graphics::UNIT_TO_PIXEL_RATIO)); // Current altitude of the hiker - const int topAltitude = currentAltitude - GetScreenHeight() / 2; // Top altitude of the screen - const int bottomAltitude = currentAltitude + GetScreenHeight() / 2; // Bottom altitude of the screen + static_cast(world.getHiker().getPosition().y * + static_cast(graphics::UNIT_TO_PIXEL_RATIO)); // Current altitude of the hiker + const int topAltitude = currentAltitude - GetScreenHeight() / 2; // Top altitude of the screen + const int bottomAltitude = currentAltitude + GetScreenHeight() / 2; // Bottom altitude of the screen for (int i = GraphicsUtil::floorToNearest(bottomAltitude, stepSize) + stepSize; i > topAltitude; i -= static_cast(graphics::UNIT_TO_PIXEL_RATIO)) { const int drawY = GetScreenHeight() / 2 - (i - currentAltitude); const int drawAltitude = - (i + gameConstants.visualConstants.cameraToHikerOffset) / static_cast(graphics::UNIT_TO_PIXEL_RATIO); + (i + gameConstants.visualConstants.cameraToHikerOffset) / static_cast( + graphics::UNIT_TO_PIXEL_RATIO); renderAltimeterStep(drawY, drawAltitude, gameConstants.visualConstants.fontSizeAltimeter); } if (!this->debugMode) { - for (const auto &landmark : landmarks) { + for (const auto &landmark: landmarks) { const int altitude = (landmark.second - 1) * static_cast(graphics::UNIT_TO_PIXEL_RATIO) - gameConstants.visualConstants.cameraToHikerOffset; const int drawY = (GetScreenHeight() / 2 - (altitude - currentAltitude)); @@ -116,8 +117,10 @@ void HudRenderer::renderItemSlot(const Inventory &inventory, const auto texture = resourceManager.getTexture(textureName); const floatType inventorySlotSize = gameConstants.itemsConstants.inventorySlotSize; DrawTexturePro(texture, {0, 0, static_cast(texture.width), static_cast(texture.height)}, - {static_cast(startX) + static_cast(slotNumber) * inventorySlotSize, - static_cast(startY), inventorySlotSize, inventorySlotSize}, + { + static_cast(startX) + static_cast(slotNumber) * inventorySlotSize, + static_cast(startY), inventorySlotSize, inventorySlotSize + }, {0, 0}, 0, WHITE); const size_t numberOfItems = inventory.getNumberOfItems(slotNumber); if (numberOfItems > 0) { @@ -134,10 +137,10 @@ void HudRenderer::renderHealthBar() const { static_cast(gameConstants.hikerConstants.hikerMaxHealth); const int screenWidth = GetScreenWidth(); const int startX = - screenWidth - gameConstants.visualConstants.healthBarWidth - gameConstants.visualConstants.uiMargin; + screenWidth - gameConstants.visualConstants.healthBarWidth - gameConstants.visualConstants.uiMargin; const int startY = gameConstants.visualConstants.uiMargin; const auto healthBarFill = - static_cast(static_cast(gameConstants.visualConstants.healthBarWidth) * health); + static_cast(static_cast(gameConstants.visualConstants.healthBarWidth) * health); // Draw the health bar DrawRectangle(startX, startY, gameConstants.visualConstants.healthBarWidth, @@ -171,11 +174,13 @@ void HudRenderer::drawScoreTexture(const Texture2D &texture, floatType widthOffset, floatType uiMarginMultiplier) const { DrawTexturePro(texture, {0, 0, static_cast(texture.width), static_cast(texture.height)}, - {static_cast(GetScreenWidth() - gameConstants.visualConstants.uiMargin) - - static_cast(gameConstants.visualConstants.fontSizeScore) * widthOffset, - static_cast(gameConstants.visualConstants.uiMargin) * uiMarginMultiplier, - static_cast(gameConstants.visualConstants.fontSizeScore * 4), - static_cast(gameConstants.visualConstants.fontSizeScore * 3)}, + { + static_cast(GetScreenWidth() - gameConstants.visualConstants.uiMargin) - + static_cast(gameConstants.visualConstants.fontSizeScore) * widthOffset, + static_cast(gameConstants.visualConstants.uiMargin) * uiMarginMultiplier, + static_cast(gameConstants.visualConstants.fontSizeScore * 4), + static_cast(gameConstants.visualConstants.fontSizeScore * 3) + }, {0, 0}, 0, WHITE); } @@ -196,11 +201,15 @@ void HudRenderer::renderCoinScore() const { const auto coinTexture = resourceManager.getTexture("coin"); DrawTexturePro(resourceManager.getTexture("coin"), {0, 0, static_cast(coinTexture.width), static_cast(coinTexture.height)}, - {static_cast(GetScreenWidth() - gameConstants.visualConstants.uiMargin * 2), - static_cast(gameConstants.visualConstants.uiMargin * 8), - static_cast(gameConstants.visualConstants.fontSizeScore), - static_cast(gameConstants.visualConstants.fontSizeScore)}, + { + static_cast(GetScreenWidth() - gameConstants.visualConstants.uiMargin * 2), + static_cast(gameConstants.visualConstants.uiMargin * 8), + static_cast(gameConstants.visualConstants.fontSizeScore), + static_cast(gameConstants.visualConstants.fontSizeScore) + }, {0, 0}, 0, WHITE); } -void HudRenderer::reset() { /* Nothing to reset */ } +void HudRenderer::reset() { + /* Nothing to reset */ +} From dd38398c22eced145ff2fc141fc9def985a981b0 Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:54:32 +0100 Subject: [PATCH 02/24] Create main-ci-pipeline.yml --- .github/workflows/main-ci-pipeline.yml | 116 +++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .github/workflows/main-ci-pipeline.yml diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml new file mode 100644 index 00000000..ab13d9e5 --- /dev/null +++ b/.github/workflows/main-ci-pipeline.yml @@ -0,0 +1,116 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - main + pull_request: + types: + - opened + - reopened + - synchronize + +jobs: + build-job: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up CMake + uses: lukka/get-cmake@v3 + + - name: Build project + run: | + cmake -S . -B cmake-build-debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DENABLE_COVERAGE=ON -DCOVERAGE_DIR_NAME="coverage" + cmake --build cmake-build-debug + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: build-artifacts + path: | + cmake-build-debug/src/surviving-sarntal + retention-days: 1 + + test-job: + name: Test + runs-on: ubuntu-latest + needs: build-job + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts + + - name: Run tests + run: | + ctest --test-dir cmake-build-debug/test --rerun-failed --output-on-failure + cmake --build cmake-build-debug --target coverage + COVERAGE=$(lcov --summary cmake-build-debug/../coverage/coverage.info | awk '/lines/ {print $2}') + echo "Line coverage $COVERAGE" + + # Remove percentage symbol and compare numeric value + COVERAGE_VALUE=$(echo "$COVERAGE" | sed 's/%//') + if [ "$COVERAGE_VALUE" -lt 80 ]; then + echo "Coverage is below 80%! Failing pipeline." + # TODO once the test coverage is high enough, we should fail the pipeline here + # exit 1 + else + echo "Coverage is sufficient: $COVERAGE_VALUE%" + fi + + - name: Upload coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage-report + path: coverage/report + retention-days: 1 + + clang-format: + name: Clang Format + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run clang-format + run: | + clang-format -style=file $(find src/ test/ -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" \)) --Werror --dry-run + + clang-tidy: + name: Clang Tidy + runs-on: ubuntu-latest + needs: [build-job, test-job] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts + + - name: Run clang-tidy + run: | + clang-tidy -p=cmake-build-debug/ $(find src/ test/ -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" \)) --warnings-as-errors=* --header-filter="^((src|test)/.*)$" --use-color + + run-exe: + name: Run Executable + runs-on: ubuntu-latest + needs: build-job + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts + + - name: Run Executable + run: ./build-utils/run_check.sh From 7ed2e6eb3c02c93ff481496f74b2c81ebc78a930 Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:02:02 +0100 Subject: [PATCH 03/24] Update main-ci-pipeline.yml Small Change --- .github/workflows/main-ci-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index ab13d9e5..2a154d38 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v3 - name: Set up CMake - uses: lukka/get-cmake@v3 + uses: lukka/get-cmake@v3.31.0 - name: Build project run: | From 6e8834a5d2e398a146aa1f7a3d5a8df199f4d4e8 Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:10:11 +0100 Subject: [PATCH 04/24] Update main-ci-pipeline.yml --- .github/workflows/main-ci-pipeline.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index 2a154d38..02f0c3a2 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -21,6 +21,28 @@ jobs: - name: Set up CMake uses: lukka/get-cmake@v3.31.0 + # Restore the APT cache (if available) + - name: Restore APT cache + uses: actions/cache@v3 + with: + path: /var/cache/apt + key: ${{ runner.os }}-apt-cache + restore-keys: | + ${{ runner.os }}-apt-cache + + # Run the setup script to install dependencies + - name: Run setup script + run: | + chmod +x build-utils/pipe_setup.sh + ./build-utils/pipe_setup.sh + + # Save the updated APT cache for future workflows + - name: Save APT cache + uses: actions/cache@v3 + with: + path: /var/cache/apt + key: ${{ runner.os }}-apt-cache + - name: Build project run: | cmake -S . -B cmake-build-debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DENABLE_COVERAGE=ON -DCOVERAGE_DIR_NAME="coverage" From 330ecf522d9a7e08ec8031fcdf1b55330d82c4ed Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:19:28 +0100 Subject: [PATCH 05/24] Create pipe_setup.sh --- build-utils/pipe_setup.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 build-utils/pipe_setup.sh diff --git a/build-utils/pipe_setup.sh b/build-utils/pipe_setup.sh new file mode 100644 index 00000000..40ae60c4 --- /dev/null +++ b/build-utils/pipe_setup.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Update the package list +sudo apt-get update + +# Install required dependencies +sudo apt-get install -y \ + build-essential \ + cmake \ + xorg-dev \ + libsdl2-dev \ + clang-tidy \ + clang-format \ + git \ + pre-commit \ + python3 \ + lcov From 08d3383ec3b4078daf8d463d407d104368533cd1 Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:36:10 +0100 Subject: [PATCH 06/24] Update main-ci-pipeline.yml --- .github/workflows/main-ci-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index 02f0c3a2..057f5de1 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -53,7 +53,7 @@ jobs: with: name: build-artifacts path: | - cmake-build-debug/src/surviving-sarntal + cmake-build-debug retention-days: 1 test-job: From 6cfa374fb946bff5f236eebf22101c21c959189b Mon Sep 17 00:00:00 2001 From: Bjoern Date: Fri, 15 Nov 2024 17:58:45 +0100 Subject: [PATCH 07/24] sorry, format again --- src/output/graphics/renderers/HudRenderer.cpp | 49 ++++++++----------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/src/output/graphics/renderers/HudRenderer.cpp b/src/output/graphics/renderers/HudRenderer.cpp index 9ffd6a58..0f0d19c6 100644 --- a/src/output/graphics/renderers/HudRenderer.cpp +++ b/src/output/graphics/renderers/HudRenderer.cpp @@ -33,23 +33,22 @@ void HudRenderer::renderAltimeter() const { static_cast(graphics::UNIT_TO_PIXEL_RATIO); // Step size of the altimeter const int currentAltitude = - static_cast(world.getHiker().getPosition().y * - static_cast(graphics::UNIT_TO_PIXEL_RATIO)); // Current altitude of the hiker - const int topAltitude = currentAltitude - GetScreenHeight() / 2; // Top altitude of the screen - const int bottomAltitude = currentAltitude + GetScreenHeight() / 2; // Bottom altitude of the screen + static_cast(world.getHiker().getPosition().y * + static_cast(graphics::UNIT_TO_PIXEL_RATIO)); // Current altitude of the hiker + const int topAltitude = currentAltitude - GetScreenHeight() / 2; // Top altitude of the screen + const int bottomAltitude = currentAltitude + GetScreenHeight() / 2; // Bottom altitude of the screen for (int i = GraphicsUtil::floorToNearest(bottomAltitude, stepSize) + stepSize; i > topAltitude; i -= static_cast(graphics::UNIT_TO_PIXEL_RATIO)) { const int drawY = GetScreenHeight() / 2 - (i - currentAltitude); const int drawAltitude = - (i + gameConstants.visualConstants.cameraToHikerOffset) / static_cast( - graphics::UNIT_TO_PIXEL_RATIO); + (i + gameConstants.visualConstants.cameraToHikerOffset) / static_cast(graphics::UNIT_TO_PIXEL_RATIO); renderAltimeterStep(drawY, drawAltitude, gameConstants.visualConstants.fontSizeAltimeter); } if (!this->debugMode) { - for (const auto &landmark: landmarks) { + for (const auto &landmark : landmarks) { const int altitude = (landmark.second - 1) * static_cast(graphics::UNIT_TO_PIXEL_RATIO) - gameConstants.visualConstants.cameraToHikerOffset; const int drawY = (GetScreenHeight() / 2 - (altitude - currentAltitude)); @@ -117,10 +116,8 @@ void HudRenderer::renderItemSlot(const Inventory &inventory, const auto texture = resourceManager.getTexture(textureName); const floatType inventorySlotSize = gameConstants.itemsConstants.inventorySlotSize; DrawTexturePro(texture, {0, 0, static_cast(texture.width), static_cast(texture.height)}, - { - static_cast(startX) + static_cast(slotNumber) * inventorySlotSize, - static_cast(startY), inventorySlotSize, inventorySlotSize - }, + {static_cast(startX) + static_cast(slotNumber) * inventorySlotSize, + static_cast(startY), inventorySlotSize, inventorySlotSize}, {0, 0}, 0, WHITE); const size_t numberOfItems = inventory.getNumberOfItems(slotNumber); if (numberOfItems > 0) { @@ -137,10 +134,10 @@ void HudRenderer::renderHealthBar() const { static_cast(gameConstants.hikerConstants.hikerMaxHealth); const int screenWidth = GetScreenWidth(); const int startX = - screenWidth - gameConstants.visualConstants.healthBarWidth - gameConstants.visualConstants.uiMargin; + screenWidth - gameConstants.visualConstants.healthBarWidth - gameConstants.visualConstants.uiMargin; const int startY = gameConstants.visualConstants.uiMargin; const auto healthBarFill = - static_cast(static_cast(gameConstants.visualConstants.healthBarWidth) * health); + static_cast(static_cast(gameConstants.visualConstants.healthBarWidth) * health); // Draw the health bar DrawRectangle(startX, startY, gameConstants.visualConstants.healthBarWidth, @@ -174,13 +171,11 @@ void HudRenderer::drawScoreTexture(const Texture2D &texture, floatType widthOffset, floatType uiMarginMultiplier) const { DrawTexturePro(texture, {0, 0, static_cast(texture.width), static_cast(texture.height)}, - { - static_cast(GetScreenWidth() - gameConstants.visualConstants.uiMargin) - - static_cast(gameConstants.visualConstants.fontSizeScore) * widthOffset, - static_cast(gameConstants.visualConstants.uiMargin) * uiMarginMultiplier, - static_cast(gameConstants.visualConstants.fontSizeScore * 4), - static_cast(gameConstants.visualConstants.fontSizeScore * 3) - }, + {static_cast(GetScreenWidth() - gameConstants.visualConstants.uiMargin) - + static_cast(gameConstants.visualConstants.fontSizeScore) * widthOffset, + static_cast(gameConstants.visualConstants.uiMargin) * uiMarginMultiplier, + static_cast(gameConstants.visualConstants.fontSizeScore * 4), + static_cast(gameConstants.visualConstants.fontSizeScore * 3)}, {0, 0}, 0, WHITE); } @@ -201,15 +196,11 @@ void HudRenderer::renderCoinScore() const { const auto coinTexture = resourceManager.getTexture("coin"); DrawTexturePro(resourceManager.getTexture("coin"), {0, 0, static_cast(coinTexture.width), static_cast(coinTexture.height)}, - { - static_cast(GetScreenWidth() - gameConstants.visualConstants.uiMargin * 2), - static_cast(gameConstants.visualConstants.uiMargin * 8), - static_cast(gameConstants.visualConstants.fontSizeScore), - static_cast(gameConstants.visualConstants.fontSizeScore) - }, + {static_cast(GetScreenWidth() - gameConstants.visualConstants.uiMargin * 2), + static_cast(gameConstants.visualConstants.uiMargin * 8), + static_cast(gameConstants.visualConstants.fontSizeScore), + static_cast(gameConstants.visualConstants.fontSizeScore)}, {0, 0}, 0, WHITE); } -void HudRenderer::reset() { - /* Nothing to reset */ -} +void HudRenderer::reset() { /* Nothing to reset */ } From 7d9098d034e1e08096b0b86ad3e3fa37d2fd404e Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Fri, 15 Nov 2024 18:05:59 +0100 Subject: [PATCH 08/24] Update main-ci-pipeline.yml --- .github/workflows/main-ci-pipeline.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index 057f5de1..6f806f2c 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -100,6 +100,15 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Check clang-format version + run: | + clang-format --version + + - name: Find .clang-format file + run: | + echo "Looking for .clang-format file..." + find . -name ".clang-format" -print || echo ".clang-format file not found" + - name: Run clang-format run: | clang-format -style=file $(find src/ test/ -type f \( -name "*.cpp" -o -name "*.hpp" -o -name "*.h" \)) --Werror --dry-run From 5f11da5ed75a66a08766fc39f57dd017d182baf9 Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Fri, 15 Nov 2024 18:40:27 +0100 Subject: [PATCH 09/24] Update main-ci-pipeline.yml --- .github/workflows/main-ci-pipeline.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index 6f806f2c..37cd9d87 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -10,9 +10,9 @@ on: - reopened - synchronize -jobs: - build-job: - name: Build +jobs: + setup-job: + name: System Setup runs-on: ubuntu-latest steps: - name: Checkout code @@ -42,7 +42,14 @@ jobs: with: path: /var/cache/apt key: ${{ runner.os }}-apt-cache - + + build-job: + name: Build + runs-on: ubuntu-latest + needs: [setup-job] + steps: + - name: Checkout code + uses: actions/checkout@v3 - name: Build project run: | cmake -S . -B cmake-build-debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DENABLE_COVERAGE=ON -DCOVERAGE_DIR_NAME="coverage" @@ -96,6 +103,7 @@ jobs: clang-format: name: Clang Format runs-on: ubuntu-latest + needs: [setup-job] steps: - name: Checkout code uses: actions/checkout@v3 From 8b2a7ec34b3ae205dc2da34bc852ef1b91113c3d Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Sun, 17 Nov 2024 00:20:57 +0100 Subject: [PATCH 10/24] Update main-ci-pipeline.yml --- .github/workflows/main-ci-pipeline.yml | 106 +++++++++++++++++-------- 1 file changed, 73 insertions(+), 33 deletions(-) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index 37cd9d87..0e2ce916 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -11,45 +11,23 @@ on: - synchronize jobs: - setup-job: - name: System Setup + + build-job: + name: Build runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - + - name: Set up CMake uses: lukka/get-cmake@v3.31.0 - # Restore the APT cache (if available) - - name: Restore APT cache - uses: actions/cache@v3 - with: - path: /var/cache/apt - key: ${{ runner.os }}-apt-cache - restore-keys: | - ${{ runner.os }}-apt-cache - # Run the setup script to install dependencies - name: Run setup script run: | chmod +x build-utils/pipe_setup.sh ./build-utils/pipe_setup.sh - - # Save the updated APT cache for future workflows - - name: Save APT cache - uses: actions/cache@v3 - with: - path: /var/cache/apt - key: ${{ runner.os }}-apt-cache - - build-job: - name: Build - runs-on: ubuntu-latest - needs: [setup-job] - steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Build project run: | cmake -S . -B cmake-build-debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DENABLE_COVERAGE=ON -DCOVERAGE_DIR_NAME="coverage" @@ -71,6 +49,15 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Set up CMake + uses: lukka/get-cmake@v3.31.0 + + # Run the setup script to install dependencies + - name: Run setup script + run: | + chmod +x build-utils/pipe_setup.sh + ./build-utils/pipe_setup.sh + - name: Download build artifacts uses: actions/download-artifact@v3 with: @@ -103,19 +90,36 @@ jobs: clang-format: name: Clang Format runs-on: ubuntu-latest - needs: [setup-job] steps: - name: Checkout code uses: actions/checkout@v3 - - name: Check clang-format version + - name: Set up CMake + uses: lukka/get-cmake@v3.31.0 + + # Run the setup script to install dependencies + - name: Run setup script run: | - clang-format --version + chmod +x build-utils/pipe_setup.sh + ./build-utils/pipe_setup.sh - - name: Find .clang-format file + - name: Check clang-format version run: | - echo "Looking for .clang-format file..." - find . -name ".clang-format" -print || echo ".clang-format file not found" + # Check and install clang-format version 18 if needed + if command -v clang-format &> /dev/null; then + INSTALLED_VERSION=$(clang-format --version | awk '{print $3}' | cut -d'.' -f1) + if [ "$INSTALLED_VERSION" -lt 18 ]; then + echo "Clang-format version $INSTALLED_VERSION is less than 18. Installing clang-format version 18..." + sudo apt-get install -y clang-format-18 + sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100 + else + echo "Clang-format version $INSTALLED_VERSION is sufficient." + fi + else + echo "Clang-format is not installed. Installing clang-format version 18..." + sudo apt-get install -y clang-format-18 + sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100 + fi - name: Run clang-format run: | @@ -129,6 +133,33 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Set up CMake + uses: lukka/get-cmake@v3.31.0 + + # Run the setup script to install dependencies + - name: Run setup script + run: | + chmod +x build-utils/pipe_setup.sh + ./build-utils/pipe_setup.sh + + - name: Check clang-tidy version + run: | + # Check and install clang-tidy version 18 if needed + if command -v clang-tidy &> /dev/null; then + INSTALLED_VERSION=$(clang-tidy --version | awk '{print $4}' | cut -d'.' -f1) + if [ "$INSTALLED_VERSION" -lt 18 ]; then + echo "Clang-tidy version $INSTALLED_VERSION is less than 18. Installing clang-tidy version 18..." + sudo apt-get install -y clang-tidy-18 + sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 100 + else + echo "Clang-tidy version $INSTALLED_VERSION is sufficient." + fi + else + echo "Clang-tidy is not installed. Installing clang-tidy version 18..." + sudo apt-get install -y clang-tidy-18 + sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 100 + fi + - name: Download build artifacts uses: actions/download-artifact@v3 with: @@ -146,6 +177,15 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Set up CMake + uses: lukka/get-cmake@v3.31.0 + + # Run the setup script to install dependencies + - name: Run setup script + run: | + chmod +x build-utils/pipe_setup.sh + ./build-utils/pipe_setup.sh + - name: Download build artifacts uses: actions/download-artifact@v3 with: From c3b33df54a888750d8133c2a7708bbb40577bec6 Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Sun, 17 Nov 2024 00:26:19 +0100 Subject: [PATCH 11/24] Update main-ci-pipeline.yml --- .github/workflows/main-ci-pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index 0e2ce916..d2b79d7a 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -107,7 +107,7 @@ jobs: run: | # Check and install clang-format version 18 if needed if command -v clang-format &> /dev/null; then - INSTALLED_VERSION=$(clang-format --version | awk '{print $3}' | cut -d'.' -f1) + INSTALLED_VERSION=$(clang-format --version | grep -oP '(?<=version )\d+' | head -n 1) # Extracts major version after "version" if [ "$INSTALLED_VERSION" -lt 18 ]; then echo "Clang-format version $INSTALLED_VERSION is less than 18. Installing clang-format version 18..." sudo apt-get install -y clang-format-18 @@ -146,7 +146,7 @@ jobs: run: | # Check and install clang-tidy version 18 if needed if command -v clang-tidy &> /dev/null; then - INSTALLED_VERSION=$(clang-tidy --version | awk '{print $4}' | cut -d'.' -f1) + INSTALLED_VERSION=$(clang-tidy --version | grep -oP '(?<=version )\d+' | head -n 1) # Extracts major version after "version" if [ "$INSTALLED_VERSION" -lt 18 ]; then echo "Clang-tidy version $INSTALLED_VERSION is less than 18. Installing clang-tidy version 18..." sudo apt-get install -y clang-tidy-18 From 9f42da31922a5dc8c1efe9a1095e8aaacd45edaf Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Sun, 17 Nov 2024 00:31:54 +0100 Subject: [PATCH 12/24] Update pipe_setup.sh --- build-utils/pipe_setup.sh | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/build-utils/pipe_setup.sh b/build-utils/pipe_setup.sh index 40ae60c4..f245454a 100644 --- a/build-utils/pipe_setup.sh +++ b/build-utils/pipe_setup.sh @@ -15,3 +15,50 @@ sudo apt-get install -y \ pre-commit \ python3 \ lcov + +sudo apt-get install -y software-properties-common wget build-essential cmake xorg-dev libsdl2-dev git pre-commit python3 lcov + +# Add the official LLVM APT repository for the latest Clang versions +wget https://apt.llvm.org/llvm.sh +chmod +x llvm.sh +sudo ./llvm.sh 18 # Install LLVM version 18 + +# Update alternatives to ensure the correct versions of clang-format and clang-tidy +if command -v clang-format &> /dev/null; then + INSTALLED_VERSION=$(clang-format --version | grep -oP '(?<=version )\d+' | head -n 1) + if [ "$INSTALLED_VERSION" -lt 18 ]; then + echo "Clang-format version $INSTALLED_VERSION is less than 18. Updating alternatives for clang-format version 18..." + sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100 + else + echo "Clang-format version $INSTALLED_VERSION is sufficient." + fi +else + echo "Clang-format is not installed. Setting up clang-format version 18..." + sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100 +fi + +if command -v clang-tidy &> /dev/null; then + INSTALLED_VERSION=$(clang-tidy --version | grep -oP '(?<=version )\d+' | head -n 1) + if [ "$INSTALLED_VERSION" -lt 18 ]; then + echo "Clang-tidy version $INSTALLED_VERSION is less than 18. Updating alternatives for clang-tidy version 18..." + sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 100 + else + echo "Clang-tidy version $INSTALLED_VERSION is sufficient." + fi +else + echo "Clang-tidy is not installed. Setting up clang-tidy version 18..." + sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 100 +fi + +# Echo installed software versions +echo "Installed software versions:" +echo "--------------------------------" +echo "gcc version: $(gcc --version | head -n 1)" +echo "cmake version: $(cmake --version | head -n 1)" +echo "clang-tidy version: $(clang-tidy --version | head -n 1)" +echo "clang-format version: $(clang-format --version | head -n 1)" +echo "git version: $(git --version)" +echo "pre-commit version: $(pre-commit --version)" +echo "python3 version: $(python3 --version)" +echo "lcov version: $(lcov --version | head -n 1)" +echo "--------------------------------" From 2af0eae3d42312c85b6bb42388b6ca0512cc803e Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Sun, 17 Nov 2024 00:38:11 +0100 Subject: [PATCH 13/24] Update pipe_setup.sh --- build-utils/pipe_setup.sh | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/build-utils/pipe_setup.sh b/build-utils/pipe_setup.sh index f245454a..d16f6a92 100644 --- a/build-utils/pipe_setup.sh +++ b/build-utils/pipe_setup.sh @@ -23,31 +23,23 @@ wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 18 # Install LLVM version 18 -# Update alternatives to ensure the correct versions of clang-format and clang-tidy -if command -v clang-format &> /dev/null; then - INSTALLED_VERSION=$(clang-format --version | grep -oP '(?<=version )\d+' | head -n 1) - if [ "$INSTALLED_VERSION" -lt 18 ]; then - echo "Clang-format version $INSTALLED_VERSION is less than 18. Updating alternatives for clang-format version 18..." - sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100 - else - echo "Clang-format version $INSTALLED_VERSION is sufficient." - fi +# Verify installation paths +CLANG_FORMAT_PATH="/usr/lib/llvm-18/bin/clang-format" +CLANG_TIDY_PATH="/usr/lib/llvm-18/bin/clang-tidy" + +# Update alternatives to point to LLVM tools +if [ -f "$CLANG_FORMAT_PATH" ]; then + echo "Setting up clang-format version 18..." + sudo update-alternatives --install /usr/bin/clang-format clang-format "$CLANG_FORMAT_PATH" 100 else - echo "Clang-format is not installed. Setting up clang-format version 18..." - sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100 + echo "Error: clang-format-18 binary not found at $CLANG_FORMAT_PATH" fi -if command -v clang-tidy &> /dev/null; then - INSTALLED_VERSION=$(clang-tidy --version | grep -oP '(?<=version )\d+' | head -n 1) - if [ "$INSTALLED_VERSION" -lt 18 ]; then - echo "Clang-tidy version $INSTALLED_VERSION is less than 18. Updating alternatives for clang-tidy version 18..." - sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 100 - else - echo "Clang-tidy version $INSTALLED_VERSION is sufficient." - fi +if [ -f "$CLANG_TIDY_PATH" ]; then + echo "Setting up clang-tidy version 18..." + sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy "$CLANG_TIDY_PATH" 100 else - echo "Clang-tidy is not installed. Setting up clang-tidy version 18..." - sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 100 + echo "Error: clang-tidy-18 binary not found at $CLANG_TIDY_PATH" fi # Echo installed software versions From 4b42ba670698f2cf49528fcea283797d07e9987c Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Sun, 17 Nov 2024 00:42:43 +0100 Subject: [PATCH 14/24] Update pipe_setup.sh --- build-utils/pipe_setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-utils/pipe_setup.sh b/build-utils/pipe_setup.sh index d16f6a92..d462b379 100644 --- a/build-utils/pipe_setup.sh +++ b/build-utils/pipe_setup.sh @@ -24,8 +24,8 @@ chmod +x llvm.sh sudo ./llvm.sh 18 # Install LLVM version 18 # Verify installation paths -CLANG_FORMAT_PATH="/usr/lib/llvm-18/bin/clang-format" -CLANG_TIDY_PATH="/usr/lib/llvm-18/bin/clang-tidy" +CLANG_FORMAT_PATH=$(find /usr /lib /opt -name clang-format-18 | head -n 1) +CLANG_TIDY_PATH=$(find /usr /lib /opt -name clang-tidy-18 | head -n 1) # Update alternatives to point to LLVM tools if [ -f "$CLANG_FORMAT_PATH" ]; then From 1801aaf13262ebacc936194a0bad192a6d05550b Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Sun, 17 Nov 2024 00:47:46 +0100 Subject: [PATCH 15/24] Update main-ci-pipeline.yml --- .github/workflows/main-ci-pipeline.yml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index d2b79d7a..e5c9527e 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -103,23 +103,13 @@ jobs: chmod +x build-utils/pipe_setup.sh ./build-utils/pipe_setup.sh - - name: Check clang-format version + - name: Debug LLVM Binaries run: | - # Check and install clang-format version 18 if needed - if command -v clang-format &> /dev/null; then - INSTALLED_VERSION=$(clang-format --version | grep -oP '(?<=version )\d+' | head -n 1) # Extracts major version after "version" - if [ "$INSTALLED_VERSION" -lt 18 ]; then - echo "Clang-format version $INSTALLED_VERSION is less than 18. Installing clang-format version 18..." - sudo apt-get install -y clang-format-18 - sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100 - else - echo "Clang-format version $INSTALLED_VERSION is sufficient." - fi - else - echo "Clang-format is not installed. Installing clang-format version 18..." - sudo apt-get install -y clang-format-18 - sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100 - fi + sudo find /usr /lib /opt -name clang-format-18 -o -name clang-tidy-18 + dpkg-query -L clang-format-18 || echo "clang-format-18 not found in package files" + llvm-config --bindir || echo "llvm-config not installed or misconfigured" + echo $PATH + - name: Run clang-format run: | From 2240e29b035f81c245cc0445550d178429b73d5a Mon Sep 17 00:00:00 2001 From: Bjoern Date: Wed, 20 Nov 2024 18:59:44 +0100 Subject: [PATCH 16/24] Some script stuff --- build-utils/bisect.py | 27 +++++++++++++++++++++++++++ build-utils/pipe_setup.sh | 0 build-utils/test.sh | 7 +++++++ 3 files changed, 34 insertions(+) create mode 100644 build-utils/bisect.py mode change 100644 => 100755 build-utils/pipe_setup.sh mode change 100644 => 100755 build-utils/test.sh diff --git a/build-utils/bisect.py b/build-utils/bisect.py new file mode 100644 index 00000000..d3f4ee55 --- /dev/null +++ b/build-utils/bisect.py @@ -0,0 +1,27 @@ +import subprocess + +def run_command(command): + """Run a shell command and check for errors.""" + result = subprocess.run(command, shell=True, text=True) + if result.returncode != 0: + print(f"Command failed: {command}") + exit(result.returncode) + +# Welcome message +print("Welcome to Bisection Hell") + +# Get user inputs +last = input('Please enter the latest (bad) commit of the bisection: ').strip() +first = input('Please enter the earliest (good) commit of the bisection: ').strip() + +# Start the bisection +print("Starting Bisection...") +run_command(f'git bisect start {last} {first}') + +# Run the test script +try: + run_command('git bisect run ./build-utils/test.sh') +finally: + # Always reset bisect, even if the script fails + print("Resetting bisection...") + run_command('git bisect reset') diff --git a/build-utils/pipe_setup.sh b/build-utils/pipe_setup.sh old mode 100644 new mode 100755 diff --git a/build-utils/test.sh b/build-utils/test.sh old mode 100644 new mode 100755 index 6520b79e..b6987687 --- a/build-utils/test.sh +++ b/build-utils/test.sh @@ -15,8 +15,15 @@ cd ./cmake-build-debug/test || exit if [[ "$OSTYPE" == "cygwin"* || "$OSTYPE" == "msys"* || "$OSTYPE" == "win32"* ]]; then ./test-surviving-sarntal.exe + res=$? else ./test-surviving-sarntal + res=$? fi cd ../.. + +if [ $res -ne 0 ]; then + exit 1 +fi +exit 0 From e2ce52ca6af2438699619b43366531d648aeb8c2 Mon Sep 17 00:00:00 2001 From: Bjoern Date: Wed, 20 Nov 2024 19:03:47 +0100 Subject: [PATCH 17/24] Pipe setup executable --- .github/workflows/main-ci-pipeline.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index e5c9527e..677f3a35 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -25,7 +25,6 @@ jobs: # Run the setup script to install dependencies - name: Run setup script run: | - chmod +x build-utils/pipe_setup.sh ./build-utils/pipe_setup.sh - name: Build project @@ -55,7 +54,6 @@ jobs: # Run the setup script to install dependencies - name: Run setup script run: | - chmod +x build-utils/pipe_setup.sh ./build-utils/pipe_setup.sh - name: Download build artifacts @@ -100,7 +98,6 @@ jobs: # Run the setup script to install dependencies - name: Run setup script run: | - chmod +x build-utils/pipe_setup.sh ./build-utils/pipe_setup.sh - name: Debug LLVM Binaries @@ -129,7 +126,6 @@ jobs: # Run the setup script to install dependencies - name: Run setup script run: | - chmod +x build-utils/pipe_setup.sh ./build-utils/pipe_setup.sh - name: Check clang-tidy version @@ -173,7 +169,6 @@ jobs: # Run the setup script to install dependencies - name: Run setup script run: | - chmod +x build-utils/pipe_setup.sh ./build-utils/pipe_setup.sh - name: Download build artifacts From d7811aa227c6d5fc483537196dc9e9add6ac8b2d Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Wed, 20 Nov 2024 19:09:10 +0100 Subject: [PATCH 18/24] Update .github/workflows/main-ci-pipeline.yml Update upload-artifact action from v3 to v4 as v3 support runs out Co-authored-by: Gerasimos Chourdakis --- .github/workflows/main-ci-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index 677f3a35..712a50a7 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -33,7 +33,7 @@ jobs: cmake --build cmake-build-debug - name: Upload build artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: build-artifacts path: | From 9f7ef382df595f42f08fbd67ff4b8874155f23a1 Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Wed, 20 Nov 2024 19:11:40 +0100 Subject: [PATCH 19/24] Update .github/workflows/main-ci-pipeline.yml --- .github/workflows/main-ci-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index 712a50a7..1fc2fc1f 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -38,7 +38,7 @@ jobs: name: build-artifacts path: | cmake-build-debug - retention-days: 1 + retention-days: 7 test-job: name: Test From c62ffe70eab1cbd2971d47e7534a55e846c00131 Mon Sep 17 00:00:00 2001 From: bjoheimer <97056280+bjoheimer@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:14:21 +0100 Subject: [PATCH 20/24] Update main-ci-pipeline.yml --- .github/workflows/main-ci-pipeline.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main-ci-pipeline.yml b/.github/workflows/main-ci-pipeline.yml index 1fc2fc1f..f9bc2589 100644 --- a/.github/workflows/main-ci-pipeline.yml +++ b/.github/workflows/main-ci-pipeline.yml @@ -57,7 +57,7 @@ jobs: ./build-utils/pipe_setup.sh - name: Download build artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: build-artifacts @@ -79,11 +79,11 @@ jobs: fi - name: Upload coverage report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage-report path: coverage/report - retention-days: 1 + retention-days: 7 clang-format: name: Clang Format @@ -147,7 +147,7 @@ jobs: fi - name: Download build artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: build-artifacts @@ -172,7 +172,7 @@ jobs: ./build-utils/pipe_setup.sh - name: Download build artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: build-artifacts From 3da4874bfbd684f1e0805f6dbdf00d0a7fff0640 Mon Sep 17 00:00:00 2001 From: Bjoern Date: Fri, 22 Nov 2024 10:47:09 +0100 Subject: [PATCH 21/24] Small test script fix --- build-utils/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-utils/test.sh b/build-utils/test.sh index b6987687..f3376985 100755 --- a/build-utils/test.sh +++ b/build-utils/test.sh @@ -24,6 +24,6 @@ fi cd ../.. if [ $res -ne 0 ]; then - exit 1 + return 1 fi -exit 0 +return 0 From 8a2560984addc6677cacb90b4fef14d7b8f95a2a Mon Sep 17 00:00:00 2001 From: Bjoern Date: Fri, 22 Nov 2024 10:59:01 +0100 Subject: [PATCH 22/24] Fix bisect --- build-utils/bisect.py | 2 +- build-utils/bisect_test.sh | 29 +++++++++++++++++++++++++++++ build-utils/test.sh | 7 ------- 3 files changed, 30 insertions(+), 8 deletions(-) create mode 100755 build-utils/bisect_test.sh diff --git a/build-utils/bisect.py b/build-utils/bisect.py index d3f4ee55..3e21aa04 100644 --- a/build-utils/bisect.py +++ b/build-utils/bisect.py @@ -20,7 +20,7 @@ def run_command(command): # Run the test script try: - run_command('git bisect run ./build-utils/test.sh') + run_command('git bisect run ./build-utils/bisect_test.sh') finally: # Always reset bisect, even if the script fails print("Resetting bisection...") diff --git a/build-utils/bisect_test.sh b/build-utils/bisect_test.sh new file mode 100755 index 00000000..6dae1b06 --- /dev/null +++ b/build-utils/bisect_test.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Cross-platform test script + +# Ensure the project is built +source build-utils/build.sh + +# Refer to the coverage scripts if you want to add coverage testing + +# mkdir -p cmake-build-debug/coverage +# lcov -c -i -d cmake-build-debug/src -o cmake-build-debug/coverage/base.info + +# Run tests +cd ./cmake-build-debug/test || exit + +if [[ "$OSTYPE" == "cygwin"* || "$OSTYPE" == "msys"* || "$OSTYPE" == "win32"* ]]; then + ./test-surviving-sarntal.exe + res=$? +else + ./test-surviving-sarntal + res=$? +fi + +cd ../.. + +if [ $res -ne 0 ]; then + exit 1 +fi +exit 0 \ No newline at end of file diff --git a/build-utils/test.sh b/build-utils/test.sh index f3376985..6520b79e 100755 --- a/build-utils/test.sh +++ b/build-utils/test.sh @@ -15,15 +15,8 @@ cd ./cmake-build-debug/test || exit if [[ "$OSTYPE" == "cygwin"* || "$OSTYPE" == "msys"* || "$OSTYPE" == "win32"* ]]; then ./test-surviving-sarntal.exe - res=$? else ./test-surviving-sarntal - res=$? fi cd ../.. - -if [ $res -ne 0 ]; then - return 1 -fi -return 0 From 16b568a10ac92872f2b300b9640121fb93e5da65 Mon Sep 17 00:00:00 2001 From: Bjoern Date: Fri, 22 Nov 2024 11:01:56 +0100 Subject: [PATCH 23/24] Update bisect_test.sh --- build-utils/bisect_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-utils/bisect_test.sh b/build-utils/bisect_test.sh index 6dae1b06..e70bb82f 100755 --- a/build-utils/bisect_test.sh +++ b/build-utils/bisect_test.sh @@ -1,6 +1,7 @@ #!/bin/bash -# Cross-platform test script +# Cross-platform bisect test script +# In contrast to test.sh, this exits with a code for bisect to work # Ensure the project is built source build-utils/build.sh From 761f87e44344ee560faf2dfb5dbf1a978a3047c8 Mon Sep 17 00:00:00 2001 From: Felix Roehr Date: Fri, 22 Nov 2024 13:09:09 +0100 Subject: [PATCH 24/24] fix audio in hiker test --- src/output/audio/AudioService.hpp | 2 +- test/entities/HikerTest.cpp | 4 ++++ test/entities/MockAudioService.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/output/audio/AudioService.hpp b/src/output/audio/AudioService.hpp index 9dbd30fe..b19d0c2c 100644 --- a/src/output/audio/AudioService.hpp +++ b/src/output/audio/AudioService.hpp @@ -19,7 +19,7 @@ class AudioService { void playMovingSound(floatType hikerSpeed, floatType maxHikerSpeed); void interruptMovingSound(); void playSoundWithSpeedIfNotAlreadyPlaying(const std::string &soundName, float speed) const; - void interruptSound(const std::string &soundName) const; + virtual void interruptSound(const std::string &soundName) const; private: ResourceManager &resourceManager; diff --git a/test/entities/HikerTest.cpp b/test/entities/HikerTest.cpp index e5293430..eb1f233a 100644 --- a/test/entities/HikerTest.cpp +++ b/test/entities/HikerTest.cpp @@ -66,6 +66,8 @@ TEST_F(HikerTestFixture, JumpOnceTest) { MockAudioService mockAudioService(mockResourceManager); ON_CALL(mockAudioService, playSound("jump")).WillByDefault(::testing::Return()); EXPECT_CALL(mockAudioService, playSound("jump")).Times(1); + ON_CALL(mockAudioService, interruptSound("moving")).WillByDefault(::testing::Return()); + EXPECT_CALL(mockAudioService, interruptSound("moving")).Times(1); Hiker hiker(Vector{0, 0}, mockAudioService, inputHandler, gameConstants.hikerConstants); hiker.jump(); @@ -80,6 +82,8 @@ TEST_F(HikerTestFixture, JumpTwiceTest) { MockAudioService mockAudioService(mockResourceManager); ON_CALL(mockAudioService, playSound("jump")).WillByDefault(::testing::Return()); EXPECT_CALL(mockAudioService, playSound("jump")).Times(2); + ON_CALL(mockAudioService, interruptSound("moving")).WillByDefault(::testing::Return()); + EXPECT_CALL(mockAudioService, interruptSound("moving")).Times(2); Hiker hiker(Vector{0, 0}, mockAudioService, inputHandler, gameConstants.hikerConstants); hiker.jump(); diff --git a/test/entities/MockAudioService.h b/test/entities/MockAudioService.h index 0148b278..3a512913 100644 --- a/test/entities/MockAudioService.h +++ b/test/entities/MockAudioService.h @@ -12,6 +12,7 @@ class MockAudioService : public AudioService { public: explicit MockAudioService(ResourceManager &resourceManager) : AudioService(resourceManager) {} MOCK_METHOD(void, playSound, (const std::string &soundName), (const, override)); + MOCK_METHOD(void, interruptSound, (const std::string &soundName), (const, override)); }; #endif // SURVIVING_SARNTAL_MOCKAUDIOSERVICE_H