|
| 1 | +# OpENer CI/CD Workflows |
| 2 | + |
| 3 | +This document describes the continuous integration and analysis workflows for the OpENer project. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The CI/CD pipeline is split into two workflows optimized for different purposes: |
| 8 | + |
| 9 | +### 1. **CI Workflow** (`ci.yml`) |
| 10 | +- **Purpose**: Fast feedback for daily development |
| 11 | +- **Triggers**: Every push to `master`, every pull request |
| 12 | +- **Duration**: ~5-10 minutes |
| 13 | +- **Analysis Level**: Standard (fast) static analysis |
| 14 | + |
| 15 | +### 2. **Exhaustive Analysis** (`exhaustive-analysis.yml`) |
| 16 | +- **Purpose**: Thorough validation for releases |
| 17 | +- **Triggers**: |
| 18 | + - Release branches (`release/**`) |
| 19 | + - Version tags (`v*`) |
| 20 | + - Nightly at 3 AM UTC |
| 21 | + - Manual workflow dispatch |
| 22 | +- **Duration**: ~30-60 minutes |
| 23 | +- **Analysis Level**: Exhaustive static analysis |
| 24 | + |
| 25 | +## Workflow Details |
| 26 | + |
| 27 | +### CI Workflow (Fast) |
| 28 | + |
| 29 | +**Jobs:** |
| 30 | +1. **lint** - Quick code quality checks |
| 31 | + - MegaLinter with standard cppcheck |
| 32 | + - Auto-applies formatting fixes on PRs |
| 33 | + - Suppresses `normalCheckLevelMaxBranches` info message |
| 34 | + |
| 35 | +2. **build-test** - Build and test |
| 36 | + - Compiles with optimizations enabled |
| 37 | + - Runs full test suite with parallel execution |
| 38 | + - Generates code coverage reports |
| 39 | + - Posts coverage summary on PRs |
| 40 | + |
| 41 | +**Best Practices Applied:** |
| 42 | +- ✅ Parallel builds (`-j$(nproc)`) |
| 43 | +- ✅ Parallel test execution |
| 44 | +- ✅ Action version pinning with SHA (security) |
| 45 | +- ✅ Automatic linter fixes |
| 46 | +- ✅ Coverage reporting on PRs |
| 47 | + |
| 48 | +### Exhaustive Analysis (Thorough) |
| 49 | + |
| 50 | +**Jobs:** |
| 51 | +1. **exhaustive-lint** - Deep static analysis |
| 52 | + - Full branch analysis with `--check-level=exhaustive` |
| 53 | + - Enables all cppcheck warnings (style, performance, portability) |
| 54 | + - Creates GitHub issue on nightly failures |
| 55 | + - Retains reports for 30 days |
| 56 | + |
| 57 | +2. **build-release** - Release configuration testing |
| 58 | + - Strict compiler warnings (`-Wall -Wextra -Werror`) |
| 59 | + - Full optimization testing |
| 60 | + - Separate coverage report for releases |
| 61 | + |
| 62 | +## Configuration Files |
| 63 | + |
| 64 | +### `.mega-linter.yml` |
| 65 | +Central MegaLinter configuration with: |
| 66 | +- Linter inclusions/exclusions |
| 67 | +- File filtering rules |
| 68 | +- Report settings |
| 69 | +- Parallel processing enabled |
| 70 | + |
| 71 | +### When Does Each Workflow Run? |
| 72 | + |
| 73 | +| Event | CI (Fast) | Exhaustive | |
| 74 | +|-------|-----------|------------| |
| 75 | +| Push to `master` | ✅ | ❌ | |
| 76 | +| Pull request | ✅ | ❌ | |
| 77 | +| Push to `release/*` | ❌ | ✅ | |
| 78 | +| Version tag (`v*`) | ❌ | ✅ | |
| 79 | +| Nightly (3 AM UTC) | ❌ | ✅ | |
| 80 | +| Manual trigger | ❌ | ✅ | |
| 81 | + |
| 82 | +## Benefits of This Approach |
| 83 | + |
| 84 | +### For Developers |
| 85 | +- ⚡ **Fast feedback** on PRs (5-10 min) |
| 86 | +- 🔧 **Auto-fixes** for formatting issues |
| 87 | +- 📊 **Immediate coverage** reports |
| 88 | +- 🎯 **No waiting** for exhaustive checks during development |
| 89 | + |
| 90 | +### For Releases |
| 91 | +- 🔍 **Thorough validation** before releases |
| 92 | +- 🛡️ **Deep branch analysis** finds edge cases |
| 93 | +- 📈 **Long-term tracking** with nightly runs |
| 94 | +- 🚨 **Automatic alerts** for regressions |
| 95 | + |
| 96 | +### For Industrial/Safety Context |
| 97 | +- ✅ OpENer is used in **manufacturing and automation** |
| 98 | +- ✅ Exhaustive checks catch **subtle issues** in critical paths |
| 99 | +- ✅ **Nightly monitoring** ensures code health |
| 100 | +- ✅ **Release validation** provides confidence for production deployments |
| 101 | + |
| 102 | +## Maintenance |
| 103 | + |
| 104 | +### Updating Dependencies |
| 105 | +All action versions are pinned to specific commits for security. To update: |
| 106 | + |
| 107 | +```bash |
| 108 | +# Check for updates |
| 109 | +gh workflow view ci.yml |
| 110 | + |
| 111 | +# Update specific action |
| 112 | +# Replace SHA in workflows with new version |
| 113 | +``` |
| 114 | + |
| 115 | +### Adjusting Analysis Depth |
| 116 | + |
| 117 | +**To make standard checks more thorough:** |
| 118 | +```yaml |
| 119 | +# In ci.yml |
| 120 | +CPPCHECK_ARGUMENTS: --inline-suppr --enable=warning |
| 121 | +``` |
| 122 | +
|
| 123 | +**To reduce exhaustive analysis:** |
| 124 | +```yaml |
| 125 | +# In exhaustive-analysis.yml |
| 126 | +CPPCHECK_ARGUMENTS: --check-level=exhaustive --inline-suppr |
| 127 | +# Remove: --enable=warning,style,performance,portability |
| 128 | +``` |
| 129 | + |
| 130 | +### Troubleshooting |
| 131 | + |
| 132 | +**If CI is too slow:** |
| 133 | +- Reduce parallel jobs: `cmake --build ... -j2` |
| 134 | +- Skip tests on draft PRs |
| 135 | +- Reduce validation scope |
| 136 | + |
| 137 | +**If exhaustive analysis fails nightly:** |
| 138 | +- Check created GitHub issues |
| 139 | +- Download artifacts for detailed reports |
| 140 | +- Review cppcheck output for false positives |
| 141 | + |
| 142 | +**If linter fixes cause conflicts:** |
| 143 | +- Add `skip fix` to commit message |
| 144 | +- Adjust `.mega-linter.yml` rules |
| 145 | +- Disable specific fixers |
| 146 | + |
| 147 | +## Migration from Old Workflow |
| 148 | + |
| 149 | +The new structure maintains all functionality from `build.yml`: |
| 150 | + |
| 151 | +| Old Feature | New Location | Changes | |
| 152 | +|------------|--------------|---------| |
| 153 | +| MegaLinter | `ci.yml` → lint | Split into standard/exhaustive | |
| 154 | +| Build & Test | `ci.yml` → build-test | Added parallel execution | |
| 155 | +| Coverage | `ci.yml` → build-test | Enhanced reporting | |
| 156 | +| Auto-fixes | `ci.yml` → lint | Simplified logic | |
| 157 | +| Release validation | NEW: `exhaustive-analysis.yml` | Added thorough checks | |
| 158 | + |
| 159 | +## Manual Workflow Execution |
| 160 | + |
| 161 | +```bash |
| 162 | +# Trigger exhaustive analysis manually |
| 163 | +gh workflow run exhaustive-analysis.yml |
| 164 | + |
| 165 | +# View recent runs |
| 166 | +gh run list --workflow=ci.yml |
| 167 | + |
| 168 | +# Download artifacts |
| 169 | +gh run download <run-id> |
| 170 | +``` |
| 171 | + |
| 172 | +## Questions? |
| 173 | + |
| 174 | +- **Why two workflows?** Balance between speed (dev) and thoroughness (release) |
| 175 | +- **Why nightly exhaustive?** Catches regressions without slowing daily work |
| 176 | +- **Can I run exhaustive on my PR?** Yes, via workflow dispatch, but not recommended for regular PRs |
| 177 | +- **What if exhaustive finds issues?** Fix in a follow-up PR; doesn't block daily development |
| 178 | + |
| 179 | +--- |
| 180 | + |
| 181 | +*Last updated: December 2025* |
0 commit comments