This directory contains comprehensive examples demonstrating how to use the Zephyr RTOS build automation system for different types of projects and use cases.
File: basic-zephyr-app.yml
Simple example for getting started with Zephyr builds:
- Single board build (qemu_x86)
- Basic testing enabled
- Minimal configuration
- Perfect for learning and small projects
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
board: 'qemu_x86'
build-type: 'debug'
run-tests: trueFile: multi-board-matrix.yml
Advanced matrix build strategy for multiple boards and configurations:
- Multiple target boards (qemu_x86, nucleo_f429zi, esp32, etc.)
- Multiple build types (debug, release)
- Matrix exclusions for optimization
- Artifact upload for release builds
- Coverage collection for specific boards
strategy:
matrix:
board: [qemu_x86, nucleo_f429zi, esp32]
build-type: [debug, release]File: iot-device-ci.yml
Complete CI/CD pipeline for IoT device development:
- Quick Validation: Fast PR validation with security scanning
- IoT Builds: Multiple IoT boards (ESP32, nRF52840)
- Connectivity Testing: Network protocol validation
- Hardware-in-the-Loop: Real hardware testing (optional)
- Performance Testing: Memory analysis and stress testing
- Security Analysis: Comprehensive security validation
- Release Preparation: Automated release packaging
- Notifications: Teams integration for build status
Features:
- Conditional execution based on triggers
- Hardware testing with self-hosted runners
- Comprehensive test coverage
- Security and compliance validation
- Automated release management
Use basic-zephyr-app.yml as a starting point:
name: 🚀 My Zephyr Project
on: [push, pull_request]
jobs:
build:
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
boards: '["qemu_x86"]'
run-tests: trueAdapt multi-board-matrix.yml for your boards:
jobs:
matrix-build:
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
boards: '["your_board1", "your_board2"]'
build-types: '["debug", "release"]'
enable-coverage: trueUse iot-device-ci.yml as a comprehensive template:
jobs:
production-build:
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
config-file: 'iot-device'
boards: '["esp32", "nrf52840dk_nrf52840"]'
build-types: '["release"]'
run-tests: true
enable-coverage: true
static-analysis: true
upload-artifacts: trueChoose appropriate boards for your project:
# Emulation (fast, always available)
boards: '["qemu_x86", "qemu_cortex_m3", "native_posix"]'
# ARM Development Boards
boards: '["nucleo_f429zi", "nucleo_f767zi", "frdm_k64f"]'
# IoT Platforms
boards: '["esp32", "esp32s3", "nrf52840dk_nrf52840"]'Select appropriate build configurations:
# Development
build-types: '["debug"]'
# Testing
build-types: '["debug", "release"]'
# Production
build-types: '["release"]'
# Optimization Analysis
build-types: '["debug", "release", "size_optimized"]'# Basic features
run-tests: true
enable-coverage: false
static-analysis: false
# Quality assurance
run-compliance: true
static-analysis: true
enable-coverage: true
# Production ready
upload-artifacts: true
timeout-minutes: 120
fail-fast: falseIf your Zephyr application is not in the repository root:
jobs:
build:
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
application-path: 'firmware/my-app'
west-config-path: 'firmware/west.yml'For project-specific build configurations:
jobs:
build:
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
extra-cmake-args: |
-DCONFIG_MY_FEATURE=y
-DCONFIG_LOG_DEFAULT_LEVEL=2
-DOVERLAY_CONFIG=boards/my_board.confFor projects with hardware-in-the-loop testing:
jobs:
hardware-test:
runs-on: [self-hosted, zephyr-hardware, my-board]
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
boards: '["my_custom_board"]'
# Hardware testing is automatically enabled on self-hosted runnersCreate .github/config/zephyr-build/my-config.yml and reference it:
jobs:
build:
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
config-file: 'my-config'jobs:
hardware-test:
if: |
contains(github.event.pull_request.labels.*.name, 'hardware-test') ||
github.ref == 'refs/heads/main'
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
boards: '["nucleo_f429zi"]'jobs:
development:
if: github.ref != 'refs/heads/main'
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
config-file: 'development'
production:
if: github.ref == 'refs/heads/main'
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
config-file: 'production'jobs:
build-app1:
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
application-path: 'applications/app1'
build-app2:
uses: bauer-group/automation-templates/.github/workflows/zephyr-build.yml@main
with:
application-path: 'applications/app2'Begin with basic-zephyr-app.yml and gradually add features:
- Basic build and test
- Add coverage collection
- Enable static analysis
- Add multiple boards
- Implement hardware testing
- Add release automation
# Good: Efficient matrix with strategic exclusions
strategy:
matrix:
board: [qemu_x86, esp32, nrf52840dk_nrf52840]
build-type: [debug, release]
exclude:
- board: esp32
build-type: debug # Skip debug builds for ESP32# Quick validation for PRs
quick-test:
if: github.event_name == 'pull_request'
with:
boards: '["qemu_x86"]'
# Full testing for main branch
full-test:
if: github.ref == 'refs/heads/main'
with:
boards: '["qemu_x86", "esp32", "nucleo_f429zi"]'- Use caching:
cache-enabled: true - Parallel jobs:
parallel-jobs: 'auto' - Smart artifact uploads
- Conditional hardware testing
- Build Failures: Check board support and Zephyr version compatibility
- Test Timeouts: Increase timeout for complex tests
- Artifact Size: Use compression and selective inclusion
- Hardware Connectivity: Verify self-hosted runner configuration
# Enable debug logging
env:
RUNNER_DEBUG: 1
ACTIONS_STEP_DEBUG: true
# Use specific Zephyr version for reproducibility
with:
zephyr-version: '0.17.4' # Instead of 'latest'To contribute new examples:
- Create a new
.ymlfile in this directory - Follow the naming convention:
purpose-description.yml - Add comprehensive comments explaining the configuration
- Update this README with the new example
- Test the workflow thoroughly
- Issues: Report problems
- Discussions: Ask questions
- Documentation: Full documentation
For more information about the Zephyr build system, see the complete documentation.