Skip to content

Commit 551af7f

Browse files
manforowiczMarcin Anforowiczpavel-kirienko
authored
ESP-IDF Component Continuous Integration (#229)
This pull request is meant to resolve #227 by adding continuous integration for publishing Libcanard to the [ESP Component Registry](https://components.espressif.com/). Files added: - `idf_component.yml`. This file contains required ESP component metadata. - `Kconfig`. ESP components use this file as a standard way for controlling build options. I've added options for enabling/disabling assertions and the CRC table. - `CMakeLists.txt`. This file is required to register the component with the ESP build system. - `.github/workflows/esp_publish.yml`. This workflow uploads the component to the ESP-IDF registry whenever a new GitHub release is published. - `.github/workflows/esp_dry_run.yml`. This workflow does a dry-run of uploading to the ESP-IDF registry, without publishing anything. It can only be manually triggered. I've tested this in my repository, and it seems to work. The GitHub workflows require `IDF_COMPONENT_API_TOKEN` with an [ESP registry token](https://components.espressif.com/settings/tokens/) to be added to the repository secrets. --------- Co-authored-by: Marcin Anforowicz <[email protected]> Co-authored-by: Pavel Kirienko <[email protected]>
1 parent 00f9d5c commit 551af7f

File tree

6 files changed

+124
-0
lines changed

6 files changed

+124
-0
lines changed

.github/workflows/esp_dry_run.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This workflow only runs when it is manually dispatched using GitHub.
2+
# It does a dry-run of publishing this project to the ESP component registry.
3+
# The project won't actually be published.
4+
5+
name: Dry-run upload to the ESP component registry
6+
on:
7+
workflow_dispatch:
8+
9+
jobs:
10+
upload_component:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
submodules: "recursive"
16+
17+
- name: Dry-run upload to the ESP component registry
18+
run: |
19+
bash esp_metadata/package_esp_component.sh
20+
export IDF_COMPONENT_API_TOKEN="${{ secrets.IDF_COMPONENT_API_TOKEN }}"
21+
cd package/libcanard
22+
compote component upload --namespace opencyphal --name libcanard --version 0.0.0 --dry-run

.github/workflows/esp_publish.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This workflow gets triggered when a GitHub release is published.
2+
# It publishes this project to the public ESP-IDF component registry.
3+
4+
name: Publish component to the ESP-IDF registry
5+
on:
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
upload_component:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
submodules: "recursive"
16+
17+
- name: Publish component to the ESP-IDF registry
18+
run: |
19+
bash esp_metadata/package_esp_component.sh
20+
export IDF_COMPONENT_API_TOKEN="${{ secrets.IDF_COMPONENT_API_TOKEN }}"
21+
cd package/libcanard
22+
compote component upload --namespace opencyphal --name libcanard --version ${{ github.event.release.tag_name }}

esp_metadata/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file is used when packaging libcanard
2+
# for the ESP-IDF component registry:
3+
# https://components.espressif.com/
4+
5+
idf_component_register(SRCS "canard.c"
6+
INCLUDE_DIRS "include")
7+
8+
# Apply the Kconfig options to the source file.
9+
10+
if(NOT CONFIG_CANARD_ASSERTIONS)
11+
target_compile_definitions(${COMPONENT_LIB} PRIVATE "CANARD_ASSERT=(void)")
12+
endif()
13+
14+
if(CONFIG_CANARD_CRC_TABLE)
15+
target_compile_definitions(${COMPONENT_LIB} PRIVATE CANARD_CRC_TABLE=1)
16+
else()
17+
target_compile_definitions(${COMPONENT_LIB} PRIVATE CANARD_CRC_TABLE=0)
18+
endif()

esp_metadata/Kconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is used when packaging libcanard
2+
# for the ESP-IDF component registry:
3+
# https://components.espressif.com/
4+
5+
# This file defines customizable ESP-IDF build options
6+
# that can be configured by running 'idf.py menuconfig'.
7+
8+
menu "Libcanard"
9+
10+
config CANARD_ASSERTIONS
11+
bool "Enable libcanard assertions."
12+
default y
13+
help
14+
Set to 'n' to disable libcanard assertions.
15+
16+
config CANARD_CRC_TABLE
17+
bool "Enable libcanard CRC table"
18+
default y
19+
help
20+
Set to 'n' to use slow but ROM-efficient transfer-CRC computation algorithm.
21+
Doing so is expected to save ca. 500 bytes of ROM and
22+
increase the cost of RX/TX transfer processing by ~half.
23+
24+
endmenu

esp_metadata/idf_component.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used when packaging libcanard
2+
# for the ESP-IDF component registry:
3+
# https://components.espressif.com/
4+
5+
# Note: Version is not specified in this file,
6+
# because the 'esp_publish.yml' GitHub action
7+
# automatically sets it based on the release version.
8+
9+
description: "Cyphal/CAN for embedded systems."
10+
license: "MIT"
11+
url: "https://github.com/OpenCyphal/libcanard"
12+
repository: "https://github.com/OpenCyphal/libcanard"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# This script must be called from the root of this repository.
5+
# It packages up libcanard as an ESP-IDF component in package/libcanard.
6+
7+
mkdir -p package/libcanard/include
8+
9+
cp CONTRIBUTING.md package/libcanard/CONTRIBUTING.md
10+
cp LICENSE package/libcanard/LICENSE
11+
cp README.md package/libcanard/README.md
12+
13+
cp libcanard/canard.c package/libcanard/canard.c
14+
cp libcanard/_canard_cavl.h package/libcanard/_canard_cavl.h
15+
cp libcanard/canard.h package/libcanard/include/canard.h
16+
17+
cp esp_metadata/CMakeLists.txt package/libcanard/CMakeLists.txt
18+
cp esp_metadata/Kconfig package/libcanard/Kconfig
19+
cp esp_metadata/idf_component.yml package/libcanard/idf_component.yml
20+
21+
# Install compote, a tool for uploading ESP-IDF components.
22+
python3 -m pip install --upgrade idf-component-manager
23+
24+
echo "Successfully packaged ESP component into package/libcanard:"
25+
find package/libcanard
26+
echo

0 commit comments

Comments
 (0)