libhal/ci - Continuous Integration
The libhal/ci repository provides a collection of GitHub Actions workflows
that are designed to automate the process of building, testing, and deploying
software libraries for various hardware platforms. These workflows are designed
to be used with the libhal library, but can be adapted for use with other
libraries as well.
To test work flows locally on your machine, use the
act command.
The repository contains the following callable workflows:
-
api_docs_gen.yml: Generates API documentation using Doxygen and deploys it to the API documentation repository. This workflow is triggered on releases. -
app_builder2.yml: Builds applications for a specified platform. Replaces the deprecatedapp_builder.ymlanddemo_builder.ymlworkflows with a unified approach using conan-config2. -
docs.yml: Validates public API documentation using Doxygen. Checks that all public APIs are properly documented and generates warnings for missing documentation. -
library_check.yml: Runs a complete suite of checks on a library including tests, linting, and documentation validation. This is the primary CI workflow for library development. -
lint.yml: Checks code formatting using clang-format. Validates that code follows the libhal style guide forinclude/,src/,demos/, andtests/directories. -
package_and_upload.yml: Creates Conan packages for a specific platform and optionally uploads them to a Conan repository. Replaces the deprecateddeploy.yml,deploy_linux.yml, anddeploy_mac.ymlworkflows. -
package_and_upload_all.yml: Creates Conan packages for all supported platforms and architectures that libhal supports. Replaces the deprecateddeploy_all.ymlworkflow. -
tests.yml: Runs unit tests for a library on multiple platforms (Linux, macOS, and optionally Windows) with optional code coverage reporting.
These workflows are used internally by the libhal/ci repository and are not typically called directly by other repositories:
rebase.yml: Automatically rebases the 5.x.y branch onto mainself_check.yml: Runs checks on various libhal libraries to ensure workflows are functioning correctlytake.yml: Allows contributors to self-assign issues by commenting.take
To use these workflows in your own repository, you can reference them in your
own GitHub Actions workflows. For example, the libhal/libhal-stm32f1
repository uses these workflows in its ci.yml workflow.
Here is an example of how to use the library_check.yml, demo_builder.yml, and deploy.yml workflows from the libhal/ci repository:
name: âś… CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
# Every week re-run these checks to see if changes to the ecosystem have
# broken this package.
schedule:
- cron: "0 12 * * 0"
jobs:
# Build and run unit tests on the library package
library_checks:
uses: libhal/ci/.github/workflows/library_check.yml@5.x.y
secrets: inherit
# Check the deploy flow. Without the "version" parameter specified, deploy
# runs a dry run of the deploy without pushing anything to the server.
deploy_cortex-m4f_check:
uses: libhal/ci/.github/workflows/deploy.yml@5.x.y
with:
arch: cortex-m4f
os: baremetal
compiler: gcc
compiler_version: 12.3
compiler_package: arm-gnu-toolchain
secrets: inherit
# Build the demo for a specific chip. Because most of the stm32f1
# architectures are "mostly" the same besides their flash and ram size, if
# demos build one for chip then it should work for others.
demo_check:
uses: libhal/ci/.github/workflows/demo_builder.yml@5.x.y
with:
compiler_profile_url: https://github.com/libhal/arm-gnu-toolchain.git
compiler_profile: v1/arm-gcc-12.3
platform_profile_url: https://github.com/libhal/libhal-stm32f1.git
platform_profile: v2/stm32f103c8
secrets: inheritThe libhal/ci workflows can also be used with device-specific libraries. These
libraries provide implementations of the libhal interfaces for specific devices.
The libhal-esp8266 library provides an implementation of the libhal interfaces
for the ESP8266 device. The library uses the libhal/ci workflows to automate
building, testing, and deploying the library.
The ci.yml workflow for the libhal-esp8266 library is as follows:
name: âś… CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
schedule:
- cron: "0 12 * * 0"
jobs:
ci:
uses: libhal/ci/.github/workflows/library_check.yml@5.x.y
secrets: inherit
deploy_cortex-m4f_check:
uses: libhal/ci/.github/workflows/deploy.yml@5.x.y
with:
arch: cortex-m4f
os: baremetal
compiler: gcc
compiler_version: 12.3
compiler_package: arm-gnu-toolchain
secrets: inherit
demo_check:
uses: libhal/ci/.github/workflows/demo_builder.yml@5.x.y
with:
compiler_profile_url: https://github.com/libhal/arm-gnu-toolchain.git
compiler_profile: v1/arm-gcc-12.3
platform_profile_url: https://github.com/libhal/libhal-arm-mcu.git
platform_profile: v1/lpc4078
secrets: inherit
In this workflow:
-
The
cijob uses thelibrary_check.ymlworkflow fromlibhal/cito build and test thelibhal-esp8266library. Code coverage is enabled for this job. -
The
deployjob uses thedeploy.ymlworkflow fromlibhal/cito build packages for thelibhal-esp8266library for thecortex-m4fprocessor. This simply shows that the package can be built for this specific architecture. Because the library doesn't have anything that wouldn't work between different cortex-m CPU, only deploying for one architecture should be enough. -
The
demo_checkjob uses thedemo_builder.ymlworkflow fromlibhal/cito build a demo for thelibhal-esp8266library for thelpc4078platform. Theprocessor_profileandplatform_profileinputs specify the profiles to use for the processor and platform, respectively.
To use the libhal/ci workflows with your own device-specific library, you can
follow the same pattern as the libhal-esp8266 library. Just replace
libhal-esp8266 with the name of your library, and adjust the
processor_profile and platform_profile inputs as needed for your device.
Important
This section is missing the new way we run deployments. Specifically using the deploy_all.yml along with a tag number.
Generates and deploys API documentation for libhal libraries.
Inputs:
- None (uses repository name and version from GitHub context)
Usage:
jobs:
api_docs:
uses: libhal/ci/.github/workflows/api_docs_gen.yml@5.x.y
secrets: inheritBuilds applications/demos for embedded platforms using the new conan-config2 system.
Inputs:
repo(string): GitHub repository to build from. Default: current repositoryversion(string): Version/tag to checkout. Default: "" (uses current branch)conan_version(string): Conan version to use. Default: "2.16.1"compiler_profile(string, required): Compiler profile path (e.g., "hal/tc/arm-gcc-12.3")platform_profile(string, required): Platform profile path (e.g., "hal/mcu/lpc4078")config2_version(string): Branch/tag of conan-config2 to use. Default: "main"dir(string): Directory containing the application. Default: "."
Usage:
jobs:
build_demo:
uses: libhal/ci/.github/workflows/app_builder2.yml@5.x.y
with:
compiler_profile: hal/tc/arm-gcc-12.3
platform_profile: hal/mcu/lpc4078
secrets: inheritValidates that all public APIs are properly documented using Doxygen.
Inputs:
library(string, required): Name of the librarysource_dir(string, required): Source directory to documentrepo(string, required): GitHub repository locationversion(string): Version/tag to checkout. Default: "" (uses current branch)dir(string, required): Directory containing the Conan package
Usage:
jobs:
docs:
uses: libhal/ci/.github/workflows/docs.yml@5.x.y
with:
library: libhal-actuator
source_dir: src
repo: libhal/libhal-actuator
dir: .
secrets: inheritComprehensive CI workflow that runs tests, linting, and documentation checks.
Inputs:
library(string): Library name. Default: repository nameversion(string): Version/tag to checkout. Default: "" (dry-run, no deployment)coverage(boolean): Enable code coverage reporting. Default: truefail_on_coverage(boolean): Fail if coverage threshold not met. Default: falsecoverage_threshold(string): Min/max coverage thresholds. Default: "40 80"source_dir(string): Source code directory. Default: "src"repo(string): GitHub repository. Default: current repositoryconan_version(string): Conan version. Default: "2.22.2"dir(string): Conan package directory. Default: "."
Usage:
jobs:
ci:
uses: libhal/ci/.github/workflows/library_check.yml@5.x.y
with:
coverage: true
fail_on_coverage: false
coverage_threshold: "40 80"
secrets: inheritValidates code formatting using clang-format.
Inputs:
library(string, required): Library namesource_dir(string, required): Source directory to lintrepo(string, required): GitHub repositoryversion(string): Version/tag to checkout. Default: ""dir(string): Package directory. Default: "."
Usage:
jobs:
lint:
uses: libhal/ci/.github/workflows/lint.yml@5.x.y
with:
library: libhal-util
source_dir: src
repo: libhal/libhal-util
secrets: inheritCreates Conan packages for a specific platform/architecture and uploads to a repository.
Inputs:
library(string): Library name. Default: repository namerepo(string): GitHub repository. Default: current repositoryconan_version(string): Conan version. Default: "2.18.0"config2_version(string): conan-config2 branch/tag. Default: "main"version(string): Package version. Default: "latest" (no upload)runner_os(string, required): GitHub runner OS (e.g., "ubuntu-24.04", "macos-latest")arch(string, required): Target architecture (e.g., "x86_64", "cortex-m4f")os(string, required): Target OS (e.g., "Linux", "baremetal")compiler_profile(string, required): Compiler profile pathdir(string): Conan package directory. Default: "."remote_url(string): Conan repository URL. Default: ""
Secrets:
conan_remote_user: Username for Conan repositoryconan_remote_password: Password for Conan repository
Usage:
jobs:
deploy:
uses: libhal/ci/.github/workflows/package_and_upload.yml@5.x.y
with:
runner_os: ubuntu-24.04
arch: cortex-m4f
os: baremetal
compiler_profile: hal/tc/arm-gcc
version: "1.0.0"
remote_url: https://example.jfrog.io/artifactory/api/conan/my-repo
secrets:
conan_remote_user: ${{ secrets.CONAN_USER }}
conan_remote_password: ${{ secrets.CONAN_PASSWORD }}Creates Conan packages for all supported platforms and architectures.
Inputs:
library(string): Library name. Default: repository namerepo(string): GitHub repository. Default: current repositoryversion(string): Package version. Default: "latest" (no upload)conan_version(string): Conan version. Default: "2.22.2"dir(string): Conan package directory. Default: "."remote_url(string): Conan repository URL. Default: ""
Secrets:
conan_remote_user: Username for Conan repositoryconan_remote_password: Password for Conan repository
Builds packages for:
- Linux x86_64 (LLVM)
- Linux armv8 (LLVM)
- macOS armv8 (LLVM)
- Cortex-M0+, M1, M3, M4, M4F, M7F, M7D (ARM GCC)
- Cortex-M23, M33, M33F, M35PF, M55, M85 (ARM GCC)
Usage:
jobs:
deploy_all:
uses: libhal/ci/.github/workflows/package_and_upload_all.yml@5.x.y
with:
version: "1.0.0"
remote_url: https://example.jfrog.io/artifactory/api/conan/my-repo
secrets:
conan_remote_user: ${{ secrets.CONAN_USER }}
conan_remote_password: ${{ secrets.CONAN_PASSWORD }}Runs unit tests on multiple platforms with optional coverage reporting.
Inputs:
library(string, required): Library nameversion(string): Version/tag to checkout. Default: ""coverage(boolean, required): Enable code coveragefail_on_coverage(boolean, required): Fail on coverage thresholdcoverage_threshold(string, required): Coverage thresholdsrepo(string, required): GitHub repositoryconan_version(string, required): Conan versionconfig2_version(string): conan-config2 branch/tag. Default: "main"dir(string): Package directory. Default: "."llvm(string): (DEPRECATED NO LONGER USED). Tests will use the latest version of LLVM available in the libhal conan-config2 repo.
Runs tests on:
- Ubuntu 24.04 (x86_64, Linux)
- macOS latest (armv8, macOS)
Usage:
jobs:
tests:
uses: libhal/ci/.github/workflows/tests.yml@5.x.y
with:
library: libhal-util
repo: libhal/libhal-util
coverage: true
fail_on_coverage: false
coverage_threshold: "40 80"
conan_version: "2.22.2"
secrets: inheritThe following workflows are deprecated and should not be used in new projects. They are maintained for backwards compatibility but will be removed in a future release.
Status: Deprecated - Use app_builder2.yml instead
This workflow has been replaced by app_builder2.yml which uses the new conan-config2 system for a more streamlined configuration approach.
Status: Deprecated - Use app_builder2.yml instead
This workflow has been replaced by app_builder2.yml. The new workflow handles both applications and demos with a unified approach.
Status: Deprecated - Use package_and_upload.yml instead
This workflow has been replaced by package_and_upload.yml which provides better configuration options and supports custom Conan repositories.
Status: Deprecated - Use package_and_upload_all.yml instead
This workflow has been replaced by package_and_upload_all.yml which includes updated architecture support and uses the new conan-config2 system.
Status: Deprecated - Use package_and_upload.yml instead
This workflow has been replaced by package_and_upload.yml with runner_os: ubuntu-24.04 specified.
Status: Deprecated - Use package_and_upload.yml instead
This workflow has been replaced by package_and_upload.yml with runner_os: macos-latest specified.
See CONTRIBUTING.md for details.
Apache 2.0; see LICENSE for details.