|
| 1 | +<!-- |
| 2 | +SPDX-FileCopyrightText: 2025 VTT Technical Research Centre of Finland Ltd |
| 3 | +SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | +--> |
| 5 | + |
| 6 | +# GitHub Actions Workflows |
| 7 | + |
| 8 | +This directory contains CI/CD workflows for the OpenPFC project. |
| 9 | + |
| 10 | +## Workflows |
| 11 | + |
| 12 | +### 🔧 `ci.yml` - Main CI Pipeline |
| 13 | + |
| 14 | +**Runs on:** Push to master/main/develop, PRs to master/main |
| 15 | + |
| 16 | +**Purpose:** Primary continuous integration pipeline ensuring code quality and functionality. |
| 17 | + |
| 18 | +**Jobs:** |
| 19 | + |
| 20 | +1. **Code Quality** |
| 21 | + - clang-format checking (excludes build, external dependencies) |
| 22 | + - REUSE compliance verification |
| 23 | + |
| 24 | +2. **Nix Build & Test** |
| 25 | + - Runs `nix flake check` |
| 26 | + - Executes test suite (excluding benchmarks) |
| 27 | + - Uses Cachix for build caching (optional) |
| 28 | + |
| 29 | +3. **CMake Build Matrix** |
| 30 | + - **OS:** Ubuntu 22.04, Ubuntu 20.04 |
| 31 | + - **Compilers:** GCC 11, GCC 13, Clang 14, Clang 16 |
| 32 | + - **Build Types:** Debug, Release |
| 33 | + - Caches HeFFTe installation |
| 34 | + - Runs full test suite with CTest |
| 35 | + - Uploads test logs on failure |
| 36 | + |
| 37 | +4. **CI Status Check** |
| 38 | + - Required status check for merging |
| 39 | + - Aggregates results from all jobs |
| 40 | + |
| 41 | +**Typical Duration:** 20-30 minutes (with cache), 45-60 minutes (cold cache) |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +### 📚 `docs.yml` - Documentation |
| 46 | + |
| 47 | +**Runs on:** |
| 48 | +- Push to master/main |
| 49 | +- PRs to master/main (when docs/, include/, or README.md changed) |
| 50 | +- Manual trigger (workflow_dispatch) |
| 51 | + |
| 52 | +**Purpose:** Build and deploy Doxygen documentation. |
| 53 | + |
| 54 | +**Jobs:** |
| 55 | + |
| 56 | +1. **Build Documentation** |
| 57 | + - Installs Doxygen, Graphviz, LaTeX |
| 58 | + - Generates HTML and PDF documentation |
| 59 | + - Checks for Doxygen warnings (fails on warnings) |
| 60 | + - Uploads documentation artifact |
| 61 | + |
| 62 | +2. **Deploy to GitHub Pages** (master branch only) |
| 63 | + - Deploys to GitHub Pages |
| 64 | + - Comments deployment URL on commit |
| 65 | + - Requires Pages to be enabled in repository settings |
| 66 | + |
| 67 | +**Typical Duration:** 10-15 minutes |
| 68 | + |
| 69 | +**Setup Required:** |
| 70 | +1. Enable GitHub Pages in repository settings |
| 71 | +2. Set source to "GitHub Actions" |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +### 📊 `coverage.yml` - Code Coverage |
| 76 | + |
| 77 | +**Runs on:** |
| 78 | +- Push to master/main/develop |
| 79 | +- PRs to master/main |
| 80 | +- Weekly schedule (Sunday 00:00 UTC) |
| 81 | +- Manual trigger (workflow_dispatch) |
| 82 | + |
| 83 | +**Purpose:** Measure and report test coverage (target: >90%). |
| 84 | + |
| 85 | +**Jobs:** |
| 86 | + |
| 87 | +1. **Coverage Analysis** |
| 88 | + - Builds with GCC 11 + coverage flags |
| 89 | + - Runs full test suite |
| 90 | + - Generates lcov coverage report |
| 91 | + - Uploads to Codecov |
| 92 | + - Comments coverage summary on PRs |
| 93 | + - Uploads HTML coverage report artifact |
| 94 | + |
| 95 | +**Coverage Targets:** |
| 96 | +- **Line Coverage:** >90% |
| 97 | +- **Function Coverage:** >90% |
| 98 | + |
| 99 | +**Typical Duration:** 15-20 minutes |
| 100 | + |
| 101 | +**Setup Required:** |
| 102 | +1. Create Codecov account (optional) |
| 103 | +2. Add `CODECOV_TOKEN` secret to repository |
| 104 | +3. Without token, artifact is still uploaded |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## Secrets Configuration |
| 109 | + |
| 110 | +Required secrets (configure in repository settings): |
| 111 | + |
| 112 | +| Secret | Required | Purpose | Where to Get | |
| 113 | +|--------|----------|---------|--------------| |
| 114 | +| `CACHIX_AUTH_TOKEN` | Optional | Speed up Nix builds | [cachix.org](https://cachix.org) | |
| 115 | +| `CODECOV_TOKEN` | Optional | Upload coverage to Codecov | [codecov.io](https://codecov.io) | |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +## Caching Strategy |
| 120 | + |
| 121 | +All workflows use GitHub Actions cache to speed up builds: |
| 122 | + |
| 123 | +- **HeFFTe builds:** Cached per OS/compiler/build-type |
| 124 | +- **Nix builds:** Cached via Cachix (optional) |
| 125 | +- **Cache retention:** 7 days |
| 126 | + |
| 127 | +Expected speedup: 2-3x faster on cache hits |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +## Badges |
| 132 | + |
| 133 | +Add these badges to your README.md: |
| 134 | + |
| 135 | +```markdown |
| 136 | +[](https://github.com/VTT-ProperTune/OpenPFC/actions/workflows/ci.yml) |
| 137 | +[](https://github.com/VTT-ProperTune/OpenPFC/actions/workflows/docs.yml) |
| 138 | +[](https://github.com/VTT-ProperTune/OpenPFC/actions/workflows/coverage.yml) |
| 139 | +[](https://codecov.io/gh/VTT-ProperTune/OpenPFC) |
| 140 | +``` |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +## Troubleshooting |
| 145 | + |
| 146 | +### Build Matrix Failures |
| 147 | + |
| 148 | +**Problem:** One compiler/OS combination fails |
| 149 | +**Solution:** Check uploaded test logs in workflow artifacts |
| 150 | + |
| 151 | +### Coverage Below Threshold |
| 152 | + |
| 153 | +**Problem:** Coverage drops below 90% |
| 154 | +**Solution:** Add tests for uncovered code paths, view HTML coverage report |
| 155 | + |
| 156 | +### Documentation Warnings |
| 157 | + |
| 158 | +**Problem:** Doxygen warnings fail the build |
| 159 | +**Solution:** Fix warnings in source code documentation, or temporarily disable check |
| 160 | + |
| 161 | +### Slow Builds |
| 162 | + |
| 163 | +**Problem:** Workflows take >45 minutes |
| 164 | +**Solution:** |
| 165 | +1. Ensure caching is working |
| 166 | +2. Consider reducing matrix size |
| 167 | +3. Use Cachix for Nix builds |
| 168 | + |
| 169 | +--- |
| 170 | + |
| 171 | +## Local Testing |
| 172 | + |
| 173 | +Test workflows locally before pushing: |
| 174 | + |
| 175 | +```bash |
| 176 | +# Install act (GitHub Actions local runner) |
| 177 | +# https://github.com/nektos/act |
| 178 | + |
| 179 | +# Run CI workflow |
| 180 | +act push |
| 181 | + |
| 182 | +# Run specific job |
| 183 | +act -j build-and-test |
| 184 | + |
| 185 | +# Run with specific matrix combination |
| 186 | +act -j build-and-test --matrix os:ubuntu-22.04 --matrix compiler:gcc-11 |
| 187 | +``` |
| 188 | + |
| 189 | +--- |
| 190 | + |
| 191 | +## Maintenance |
| 192 | + |
| 193 | +### Adding New Compilers |
| 194 | + |
| 195 | +Edit `ci.yml` matrix section: |
| 196 | + |
| 197 | +```yaml |
| 198 | +matrix: |
| 199 | + compiler: [gcc-11, gcc-13, gcc-14] # Add gcc-14 |
| 200 | + include: |
| 201 | + - compiler: gcc-14 |
| 202 | + cc: gcc-14 |
| 203 | + cxx: g++-14 |
| 204 | +``` |
| 205 | +
|
| 206 | +### Updating Dependencies |
| 207 | +
|
| 208 | +Update version numbers in: |
| 209 | +- HeFFTe download URL: `v2.4.0` → `v2.5.0` |
| 210 | +- Cache keys: `heffte-2.4.0-...` → `heffte-2.5.0-...` |
| 211 | +- Update in all three workflows |
| 212 | + |
| 213 | +--- |
| 214 | + |
| 215 | +**Last Updated:** 2025-12-12 |
0 commit comments