From 0715165c9e2fa449180f926caa26d5293f642d73 Mon Sep 17 00:00:00 2001 From: wispl Date: Sat, 1 Aug 2026 01:31:21 -0400 Subject: [PATCH] ci: add tests --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + test/support/stub_hal.h | 8 ++++++-- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2093919 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + name: Tests + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '4.0' + + - name: Install Build Tools and Ceedling + run: | + sudo apt-get update + sudo apt-get install -y gcc cmake ninja-build gcovr + gem install ceedling + + - name: Fetch Dependencies + run: cmake -B build + + - name: Run Tests + run: ceedling gcov:all + + - name: Upload Coverage + uses: actions/upload-artifact@v7 + if: always() + with: + name: code-coverage-report + path: build/ceedling/artifacts/gcov/gcovr/GcovCoverageResults.html + archive: false + retention-days: 7 diff --git a/.gitignore b/.gitignore index 845cda6..84674eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build/ # Prerequisites *.d diff --git a/test/support/stub_hal.h b/test/support/stub_hal.h index 108b4ee..c732ff9 100644 --- a/test/support/stub_hal.h +++ b/test/support/stub_hal.h @@ -5,17 +5,21 @@ typedef int HAL_StatusTypeDef; #define HAL_OK 0 +#define HAL_MAX_DELAY 0 typedef struct { uint32_t dummy; } I2C_HandleTypeDef; +typedef struct { uint32_t dummy; } SPI_HandleTypeDef; typedef struct { uint32_t dummy; } GPIO_TypeDef; typedef struct { uint32_t dummy; } UART_HandleTypeDef; #define HAL_I2C_Mem_Read(...) (0) #define HAL_I2C_Mem_Write(...) (0) #define HAL_I2C_GetError(...) (0) -#define HAL_GPIO_WritePin(...) ((void)0) +#define HAL_SPI_Transmit(...) (0) +#define HAL_SPI_Receive(...) (0) +#define HAL_GPIO_WritePin(...) (0) #define HAL_GPIO_ReadPin(...) (0) #define HAL_UART_Transmit(...) (0) -#define HAL_Delay(...) ((void)0) +#define HAL_Delay(...) (0) #endif