CI/CD Integration

This guide covers the Nexus Embedded Platform’s CI/CD system, including the optimized GitHub Actions workflows and integration with other CI/CD platforms.

Overview

The Nexus platform provides a comprehensive, modular CI/CD system with:

  • Intelligent Triggering: Path-based filtering and smart scheduling

  • Modular Design: Reusable workflows and composite actions

  • Multi-Platform Builds: Windows, Linux, macOS, and ARM cross-compilation

  • Quality Assurance: Code coverage, static analysis, sanitizers, and MISRA compliance

  • Performance Optimization: Build caching, parallel execution, and smart dependencies

  • Complete Documentation: Automated Doxygen and Sphinx documentation with i18n support

System Architecture

The Nexus CI/CD system uses a modular architecture:

ci.yml (Main Orchestrator)
    ↓
Smart Change Detection
    ↓
Trigger Sub-Workflows
    ├─► build-matrix.yml (Build & Test)
    │   ├─ Multi-platform builds
    │   ├─ Coverage analysis
    │   └─ Sanitizer tests
    │
    ├─► quality-checks.yml (Code Quality)
    │   ├─ Format checking
    │   ├─ Static analysis
    │   ├─ Complexity analysis
    │   └─ MISRA compliance
    │
    └─► docs-build.yml (Documentation)
        ├─ Doxygen API docs
        ├─ Sphinx user docs (EN/CN)
        └─ GitHub Pages deployment

Optimization Results

The optimized CI/CD system achieves:

  • 55% reduction in code size (from ~2000 to ~900 lines)

  • 40% faster build times (from 25 to 15 minutes)

  • 85% cache hit rate (up from 60%)

  • 140% more parallel tasks (from 3-5 to 8-12)

Other CI/CD Platforms

While GitHub Actions is recommended, Nexus can integrate with other platforms.

GitLab CI

Basic .gitlab-ci.yml configuration:

stages:
  - build
  - test
  - deploy

variables:
  GIT_SUBMODULE_STRATEGY: recursive

build:linux:
  stage: build
  image: ubuntu:22.04
  before_script:
    - apt-get update && apt-get install -y cmake ninja-build gcc g++
  script:
    - cmake --preset linux-gcc-release
    - cmake --build --preset linux-gcc-release
  artifacts:
    paths:
      - build/
    expire_in: 1 hour

test:
  stage: test
  image: ubuntu:22.04
  dependencies:
    - build:linux
  script:
    - ctest --preset linux-gcc-release --output-on-failure

Jenkins

Basic Jenkinsfile configuration:

pipeline {
    agent any

    stages {
        stage('Checkout') {
            steps {
                checkout scm
                sh 'git submodule update --init --recursive'
            }
        }

        stage('Build') {
            steps {
                sh '''
                    cmake --preset linux-gcc-release
                    cmake --build --preset linux-gcc-release --parallel
                '''
            }
        }

        stage('Test') {
            steps {
                sh 'ctest --preset linux-gcc-release --output-on-failure'
            }
        }
    }

    post {
        always {
            archiveArtifacts artifacts: 'build/**/*', allowEmptyArchive: true
        }
    }
}

Azure DevOps

Basic azure-pipelines.yml configuration:

trigger:
  branches:
    include:
      - main
      - develop

pool:
  vmImage: 'ubuntu-latest'

steps:
  - checkout: self
    submodules: true

  - script: |
      cmake --preset linux-gcc-release
      cmake --build --preset linux-gcc-release --parallel
    displayName: 'Build'

  - script: |
      ctest --preset linux-gcc-release --output-on-failure
    displayName: 'Test'

Best Practices

Caching Strategy

GitHub Actions:

- name: Cache Build
  uses: actions/cache@v4
  with:
    path: |
      build
      ~/.cache/ccache
    key: ${{ runner.os }}-${{ matrix.preset }}-${{ hashFiles('**/CMakeLists.txt') }}

Benefits:

  • 85% cache hit rate

  • 40% faster builds

  • Reduced CI costs

Parallel Execution

Matrix Strategy:

strategy:
  fail-fast: false
  matrix:
    os: [ubuntu-latest, windows-latest, macos-latest]
    preset: [debug, release]

Benefits:

  • 8-12 parallel tasks

  • Faster feedback

  • Better resource utilization

Artifact Management

Upload Artifacts:

- uses: actions/upload-artifact@v4
  with:
    name: build-artifacts
    path: |
      build/*/bin/*
      build/*/lib/*
    retention-days: 7

Best Practices:

  • Only upload necessary artifacts

  • Set appropriate retention periods

  • Use compression for large files

Quality Gates

Coverage Threshold:

- name: Check Coverage
  run: |
    COVERAGE=$(lcov --summary coverage.info | grep lines | awk '{print $2}')
    if (( $(echo "$COVERAGE < 80.0" | bc -l) )); then
      echo "Coverage $COVERAGE% below threshold"
      exit 1
    fi

Code Quality:

  • Format check must pass

  • No critical static analysis issues

  • Complexity within limits (CCN < 15)

  • MISRA compliance for safety-critical code

Troubleshooting

Common Issues

1. Submodule Checkout Failure

- uses: actions/checkout@v4
  with:
    submodules: recursive
    token: ${{ secrets.GITHUB_TOKEN }}

2. Build Cache Corruption

# Clear cache and rebuild
rm -rf build ~/.cache/ccache
cmake --preset linux-gcc-release
cmake --build --preset linux-gcc-release

3. Test Timeout

- run: ctest --preset linux-gcc-release --timeout 600

4. Coverage Upload Failure

# Verify coverage file
ls -la coverage.info
lcov --list coverage.info

5. ARM Toolchain Issues

# Verify toolchain
arm-none-eabi-gcc --version

# Check PATH
echo $PATH | grep arm-none-eabi

Performance Optimization

Build Time Optimization:

  • Use ccache for compilation caching

  • Enable parallel builds (--parallel)

  • Use Ninja generator for faster builds

  • Cache CMake configuration

CI Cost Optimization:

  • Use path filters to skip unnecessary builds

  • Set appropriate artifact retention periods

  • Use concurrency control to cancel outdated runs

  • Schedule heavy jobs (performance, security) weekly

Monitoring and Metrics

Key Metrics:

  • Build success rate: > 95%

  • Average build time: < 20 minutes

  • Cache hit rate: > 80%

  • Test pass rate: > 99%

  • Coverage: > 80%

Monitoring Tools:

  • GitHub Actions dashboard

  • Codecov for coverage trends

  • Custom metrics in workflow summaries

See Also

Additional Resources