Skip to content
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
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Set update schedule for GitHub Actions
version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
31 changes: 24 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:
contents: read

env:
# We don't need every tool in the manifest for CI.
# We don't need every tool in the manifest for CI, we specify the ones we need in each job.
MISE_TASK_RUN_AUTO_INSTALL: "false"

jobs:
Expand All @@ -20,41 +20,58 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install --yes build-essential

- name: Set up mise
uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c
uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
with:
install_args: aqua:Kitware/CMake

- name: Run unit tests
run: mise run test

lint:
name: Cppcheck
name: cppcheck
runs-on: ubuntu-latest

env:
MISE_TASK_RUN_AUTO_INSTALL: "false"

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive

- name: Set up mise
uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c
uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
with:
install_args: >-
aqua:Kitware/CMake
conda:cppcheck
vfox:jdx/vfox-gcc-arm-none-eabi

- name: Run cppcheck
run: mise run lint
run: mise run lint

format:
name: clang-format
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up mise
uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
with:
install_args: >-
clang-format

- name: Check formatting
run: mise run format:check
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ To reset the device:
mise run reset
```

To format the C application code with `clang-format`:

```sh
mise run reset
```

To lint the C application code with `cppcheck`:

```sh
mise run lint
```

### Debugging

To debug the firmware, first build it with the debug preset, then install the probe-rs vscode
Expand Down
305 changes: 305 additions & 0 deletions mise.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"aqua:Kitware/CMake" = "4.3.1"
"conda:cppcheck" = "2.21.0"
"cargo:probe-rs-tools" = "0.31.0"
clang-format = "23.1.2"
python = "3.14"
uv = "0.11.19"
# For PlantUML diagrams.
Expand Down Expand Up @@ -117,3 +118,9 @@ description = "Lint all Python files"
run = '''
uvx ruff check
'''

[tasks.format]
run = "./scripts/clang-format.sh -i"

[tasks."format:check"]
run = "./scripts/clang-format.sh --dry-run --Werror"
9 changes: 9 additions & 0 deletions scripts/clang-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail

find app tests \
\( -path 'app/drivers/vl53l0x' -o -path 'tests/unity' \) -prune -o \
-type f \( -name '*.c' -o -name '*.h' \) \
! -path 'app/config/SEGGER_RTT_Conf.h' \
-print0 |
xargs -0 -r clang-format "$@"
9 changes: 6 additions & 3 deletions tests/integration/test-drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
#include "main.h"
#include "tim.h"

void app_init(void) {
void app_init(void)
{
// We need TIM17 for the microsecond sleep timer we use to wake the motor drivers.
MX_TIM17_Init();
if (HAL_TIM_Base_Start(&htim17) != HAL_OK) {
if (HAL_TIM_Base_Start(&htim17) != HAL_OK)
{
Error_Handler();
}
motor_driver_init();
}

void app_run(void) {
void app_run(void)
{
// Enable LED and wait for 5 seconds before starting.
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, SET);
motor_drive(0, DRIVE_STOP);
Expand Down
5 changes: 3 additions & 2 deletions tests/test_ring_buffer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "unity.h"
#include "ring_buffer.h"
#include "unity.h"

#define TEST_BUFFER_CAPACITY 8

Expand Down Expand Up @@ -33,7 +33,8 @@ void test_push_then_pop_then_empty(void)

void test_push_beyond_full_drops_oldest_value(void)
{
// Note that the capacity is one smaller, since we reserve one slot to determine if the buffer is full.
// Note that the capacity is one smaller, since we reserve one slot to determine if the buffer
// is full.
for (int i = 0; i < TEST_BUFFER_CAPACITY; i++)
{
ring_buffer_push(&rb, &i);
Expand Down
Loading