Skip to content
Open
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
51 changes: 6 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,53 +27,14 @@ jobs:
echo "EOF"
} >> "$GITHUB_OUTPUT"

build-docker-image:
# skip for forked PRs (can't push to ghcr)
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check if Docker rebuild is necessary
id: changed
uses: dorny/paths-filter@v3
with:
filters: |
image:
- 'Dockerfile.arm-gnu'
- '.github/workflows/ci.yml'

- name: Login to ghcr
uses: docker/login-action@v3
if: steps.changed.outputs.image == 'true'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up buildx
uses: docker/setup-buildx-action@v3
if: steps.changed.outputs.image == 'true'

- name: Build and push
uses: docker/build-push-action@v6
if: steps.changed.outputs.image == 'true'
with:
context: .
file: ./Dockerfile.arm-gnu
push: true
tags: |
ghcr.io/${{ github.repository }}/arm-gnu:13.3
ghcr.io/${{ github.repository }}/arm-gnu:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
docker-image:
uses: ./.github/workflows/docker.yml

style:
needs: build-docker-image
needs: docker-image
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/arm-gnu:13.3
image: ghcr.io/${{ github.repository }}/arm-gnu:${{ needs.docker-image.outputs.image_tag }}
steps:
- uses: actions/checkout@v4

Expand All @@ -91,11 +52,11 @@ jobs:

test-build:
needs:
- build-docker-image
- docker-image
- generate-test-matrix
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/arm-gnu:13.3
image: ghcr.io/${{ github.repository }}/arm-gnu:${{ needs.docker-image.outputs.image_tag }}

strategy:
fail-fast: false
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: docker

on:
workflow_call:
outputs:
image_tag:
description: "tag of the image to use"
value: ${{ jobs.build-docker-image.outputs.image_tag }}

permissions:
contents: read
packages: write

jobs:
build-docker-image:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.tag.outputs.tag }}
steps:
- uses: actions/checkout@v4

- name: Check if Docker rebuild is necessary
id: changed
uses: dorny/paths-filter@v3
with:
filters: |
image:
- 'Dockerfile.arm-gnu'
- '.github/workflows/ci.yml'

- name: Login to ghcr
uses: docker/login-action@v3
if: steps.changed.outputs.image == 'true'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up buildx
uses: docker/setup-buildx-action@v3
if: steps.changed.outputs.image == 'true'

- name: Build and push
uses: docker/build-push-action@v6
if: steps.changed.outputs.image == 'true'
with:
context: .
file: ./Dockerfile.arm-gnu
push: true
tags: |
ghcr.io/${{ github.repository }}/arm-gnu:13.3
ghcr.io/${{ github.repository }}/arm-gnu:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false

- id: tag
run: echo "tag=13.3" >> "$GITHUB_OUTPUT"
72 changes: 72 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: release CAN library

on:
workflow_dispatch:
inputs:
version_tag:
description: 'the semver version tag for this release (e.g., v1.0.4)'
required: true
type: string

permissions:
contents: write
packages: write

jobs:

docker-image:
uses: ./.github/workflows/docker.yml

release-can:
needs: docker-image
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/arm-gnu:${{ needs.docker-image.outputs.image_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Validate version tag format
run: |
TAG="${{ inputs.version_tag }}"
# regex matches strict format: 'v' followed by numbers separated by dots (e.g., v1.23.0)
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::invalid tag format '$TAG' - release tags must strictly follow semver formatting (e.g., v1.0.4)"
exit 1
fi

- name: Create python venv
run: |
cmake -S ./tools -B ./tools/build
cmake --build ./tools/build --target python_env_ready
rm -rf tools/build/

- name: Generate DBC sources
run: |
. tools/venv/bin/activate
# force override cmake dependencies (usually provided by STM32 cmake or scripts)
cmake -S ./lib/dbc -B ./lib/dbc/build \
-DVENV_PYTHON=$(which python) \
-DTOOLS_DIR=$(pwd)/tools
# create only the DBC source files
cmake --build ./lib/dbc/build --target dbc

- name: Package release assets
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
mkdir -p release_package
cp lib/dbc/build/*.hpp release_package/
cp lib/dbc/release.CMakeLists.txt release_package/CMakeLists.txt
tar -czf mrover_can.tar.gz -C release_package .

- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version_tag }}
name: Release ${{ inputs.version_tag }}
files: mrover_can.tar.gz
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ if (DEFINED MX_SRC_DIR AND DEFINED MX_INC_DIR AND DEFINED MX_STARTUP_S)
add_subdirectory(stm32g4)
endif ()
add_subdirectory(stm32)
add_subdirectory(units)
add_subdirectory(util)
7 changes: 7 additions & 0 deletions lib/dbc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
cmake_minimum_required(VERSION 3.22)

project(dbc_generation LANGUAGES CXX)

# NOTE(eric): this exists to force the target to exist for CI
if(NOT TARGET python_env_ready)
add_custom_target(python_env_ready)
endif()

get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE)
set(DBC_SOURCE_DIR "${PROJECT_ROOT}/dbc")
set(DBC_GEN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build")
Expand Down
5 changes: 5 additions & 0 deletions lib/dbc/release.CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.22)
project(mrover_can LANGUAGES CXX)

add_library(dbc INTERFACE)
target_include_directories(dbc INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
16 changes: 0 additions & 16 deletions lib/units/CMakeLists.txt

This file was deleted.

Loading
Loading