Skip to content

Latest commit

Β 

History

History
506 lines (434 loc) Β· 19.2 KB

File metadata and controls

506 lines (434 loc) Β· 19.2 KB

CI/CD Pipeline Documentation

Pipeline Architecture

                         GitHub Push/PR Event
                                  β”‚
                                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       CI Pipeline Stages                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                         β”‚                         β”‚
        β–Ό                         β–Ό                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Stage 1:     β”‚       β”‚  Stage 2:     β”‚       β”‚  Stage 3:     β”‚
β”‚  Lint & Format│──────►│  Build & Test │──────►│  Security     β”‚
β”‚               β”‚       β”‚               β”‚       β”‚  Scanning     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  ↓ Jobs:                 ↓ Jobs:                 ↓ Jobs:
  β€’ clang-format          β€’ Linux (x64)           β€’ CodeQL
  β€’ clang-tidy            β€’ macOS (x64/ARM)       β€’ Snyk
  β€’ cppcheck              β€’ Windows (x64)         β€’ Trivy
  β€’ CMake format          β€’ Run Tests             β€’ Gitleaks
  β€’ Shell lint            β€’ Coverage              β€’ Semgrep
  β€’ YAML lint                                     β€’ Bearer
  β€’ Spell check                                   β€’ Grype

        β”‚                         β”‚                         β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚  Stage 4:         β”‚
                        β”‚  Quality Analysis β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          ↓ Jobs:
                          β€’ SonarCloud
                          β€’ Lizard (complexity)
                          β€’ Valgrind (memory)

                                  β”‚
                                  β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   All Checks Passed?      β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚                     β”‚
                  Yesβ”‚                     β”‚No
                     β–Ό                     β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚  PR Approved    β”‚   β”‚  Fix Issues &   β”‚
            β”‚  Ready to Merge β”‚   β”‚  Re-run Pipelineβ”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Detailed Workflow

Stage 1: Lint and Format Checks

Purpose: Fast failure for code style and format issues

Format Check (clang-format)
    β”‚
    β”œβ”€β–Ί Checks C/C++ code formatting
    β”œβ”€β–Ί Uses clang-format-18
    └─► Runs in ~15 seconds

CMake Format Check
    β”‚
    β”œβ”€β–Ί Validates CMake file formatting
    β”œβ”€β–Ί Uses gersemi
    └─► Runs in ~10 seconds

Static Analysis (clang-tidy)
    β”‚
    β”œβ”€β–Ί Advanced C/C++ static analysis
    β”œβ”€β–Ί Checks for bugs, performance issues
    └─► Runs in ~50 seconds

Static Analysis (cppcheck)
    β”‚
    β”œβ”€β–Ί C/C++ static analysis
    β”œβ”€β–Ί Finds bugs and undefined behavior
    └─► Runs in ~30 seconds

Shell Script Analysis (shellcheck)
    β”‚
    β”œβ”€β–Ί Validates bash scripts
    └─► Runs in ~5 seconds

YAML Lint
    β”‚
    β”œβ”€β–Ί Validates workflow YAML files
    └─► Runs in ~5 seconds

Spell Check (codespell)
    β”‚
    β”œβ”€β–Ί Catches typos in code and docs
    └─► Runs in ~15 seconds

Exit Criteria: All linters pass, code is properly formatted

Stage 2: Build and Test

Purpose: Verify code compiles and tests pass on all platforms

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Multi-Platform Build Matrix                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                           β”‚
β”‚  Ubuntu 22.04 (x86_64)                                   β”‚
β”‚    β”œβ”€β–Ί Build Debug & Release                             β”‚
β”‚    β”œβ”€β–Ί Run Unit Tests (CTest)                            β”‚
β”‚    β”œβ”€β–Ί Generate Coverage Report                          β”‚
β”‚    └─► Upload Artifacts                                  β”‚
β”‚                                                           β”‚
β”‚  macOS (Intel x64)                                       β”‚
β”‚    β”œβ”€β–Ί Build Universal Binary                            β”‚
β”‚    β”œβ”€β–Ί Run Unit Tests                                    β”‚
β”‚    β”œβ”€β–Ί Code Sign (if certificates available)             β”‚
β”‚    └─► Upload Artifacts                                  β”‚
β”‚                                                           β”‚
β”‚  macOS (Apple Silicon ARM64)                             β”‚
β”‚    β”œβ”€β–Ί Build Universal Binary                            β”‚
β”‚    β”œβ”€β–Ί Run Unit Tests                                    β”‚
β”‚    └─► Upload Artifacts                                  β”‚
β”‚                                                           β”‚
β”‚  Windows (x64)                                           β”‚
β”‚    β”œβ”€β–Ί Build Debug & Release                             β”‚
β”‚    β”œβ”€β–Ί Run Unit Tests                                    β”‚
β”‚    └─► Upload Artifacts                                  β”‚
β”‚                                                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Build Process:

Install Dependencies
    β”‚
    β”œβ”€β–Ί libobs-dev
    β”œβ”€β–Ί libcurl-dev
    β”œβ”€β–Ί libjansson-dev
    └─► CMake, Ninja
    β”‚
    β–Ό
Configure CMake
    β”‚
    β”œβ”€β–Ί -DCMAKE_BUILD_TYPE=Release
    β”œβ”€β–Ί -DENABLE_TESTING=ON
    └─► -DENABLE_COVERAGE=ON (Linux only)
    β”‚
    β–Ό
Build Project
    β”‚
    β”œβ”€β–Ί ninja build
    └─► ~2 minutes per platform
    β”‚
    β–Ό
Run Tests
    β”‚
    β”œβ”€β–Ί Unit tests (CTest)
    β”œβ”€β–Ί API tests
    β”œβ”€β–Ί Config tests
    └─► Multistream tests
    β”‚
    β–Ό
Generate Reports
    β”‚
    β”œβ”€β–Ί Coverage (Linux)
    β”œβ”€β–Ί Test Results (JUnit XML)
    └─► Build Artifacts

Exit Criteria: All platforms build successfully, all tests pass

Stage 3: Security Scanning

Purpose: Identify security vulnerabilities and secrets

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Security Scanners                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                          β”‚
β”‚  CodeQL (GitHub Native) - SECURITY + QUALITY            β”‚
β”‚    β”œβ”€β–Ί Deep semantic code analysis                      β”‚
β”‚    β”œβ”€β–Ί Queries: security-extended + security-and-qualityβ”‚
β”‚    β”œβ”€β–Ί Security: SQL injection, XSS, buffer overflow    β”‚
β”‚    β”œβ”€β–Ί Quality: Code smells, best practices, bugs       β”‚
β”‚    β”œβ”€β–Ί Maintainability & reliability metrics            β”‚
β”‚    └─► Results β†’ GitHub Security Tab + Code Scanning    β”‚
β”‚                                                          β”‚
β”‚  Snyk                                                   β”‚
β”‚    β”œβ”€β–Ί Dependency vulnerability scanning               β”‚
β”‚    β”œβ”€β–Ί Severity threshold: high                        β”‚
β”‚    β”œβ”€β–Ί SARIF output                                    β”‚
β”‚    └─► Results β†’ GitHub Security Tab                    β”‚
β”‚                                                          β”‚
β”‚  Trivy (Aqua Security)                                  β”‚
β”‚    β”œβ”€β–Ί Filesystem vulnerability scanner                β”‚
β”‚    β”œβ”€β–Ί Detects: HIGH, CRITICAL                         β”‚
β”‚    β”œβ”€β–Ί Scans dependencies and code                     β”‚
β”‚    └─► Results β†’ GitHub Security Tab                    β”‚
β”‚                                                          β”‚
β”‚  Gitleaks                                               β”‚
β”‚    β”œβ”€β–Ί Secret scanning (API keys, tokens)              β”‚
β”‚    β”œβ”€β–Ί Full git history scan                           β”‚
β”‚    └─► Prevents credential leaks                        β”‚
β”‚                                                          β”‚
β”‚  Semgrep                                                β”‚
β”‚    β”œβ”€β–Ί Pattern-based code analysis                     β”‚
β”‚    β”œβ”€β–Ί Config: auto (community rules)                  β”‚
β”‚    β”œβ”€β–Ί Detects: insecure patterns                      β”‚
β”‚    └─► Results β†’ GitHub Security Tab                    β”‚
β”‚                                                          β”‚
β”‚  Bearer                                                 β”‚
β”‚    β”œβ”€β–Ί Data security and privacy scanner               β”‚
β”‚    β”œβ”€β–Ί Detects: PII handling issues                    β”‚
β”‚    β”œβ”€β–Ί With SARIF validation                           β”‚
β”‚    └─► Results β†’ GitHub Security Tab                    β”‚
β”‚                                                          β”‚
β”‚  Grype (Anchore)                                        β”‚
β”‚    β”œβ”€β–Ί Vulnerability scanner                            β”‚
β”‚    β”œβ”€β–Ί Severity cutoff: high                           β”‚
β”‚    └─► Results β†’ GitHub Security Tab                    β”‚
β”‚                                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Security Flow:

PR/Push Event
    β”‚
    β”œβ”€β–Ί Run 7 security scanners in parallel
    β”‚
    β”œβ”€β–Ί Generate SARIF reports
    β”‚
    β”œβ”€β–Ί Upload to GitHub Security Tab
    β”‚
    β”œβ”€β–Ί Check for CRITICAL/HIGH findings
    β”‚
    └─► Flag PR if critical issues found

Exit Criteria: No critical/high vulnerabilities, no secrets detected

Stage 4: Code Quality Analysis

Purpose: Ensure code maintainability and performance

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               Code Quality Tools                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                          β”‚
β”‚  SonarCloud                                             β”‚
β”‚    β”œβ”€β–Ί Comprehensive quality metrics                    β”‚
β”‚    β”œβ”€β–Ί Code coverage analysis                           β”‚
β”‚    β”œβ”€β–Ί Technical debt calculation                       β”‚
β”‚    β”œβ”€β–Ί Code smells detection                            β”‚
β”‚    β”œβ”€β–Ί Duplicate code detection                         β”‚
β”‚    └─► Quality gate: Pass/Fail                          β”‚
β”‚                                                          β”‚
β”‚  Lizard (Complexity Analysis)                           β”‚
β”‚    β”œβ”€β–Ί Cyclomatic complexity (CCN)                      β”‚
β”‚    β”œβ”€β–Ί Threshold: CCN < 15                              β”‚
β”‚    β”œβ”€β–Ί Function analysis                                β”‚
β”‚    β”œβ”€β–Ί HTML report generation                           β”‚
β”‚    └─► Artifact: lizard-report.html                     β”‚
β”‚                                                          β”‚
β”‚  Valgrind (Memory Analysis)                             β”‚
β”‚    β”œβ”€β–Ί Memory leak detection                            β”‚
β”‚    β”œβ”€β–Ί Invalid memory access                            β”‚
β”‚    β”œβ”€β–Ί Uninitialized value usage                        β”‚
β”‚    β”œβ”€β–Ί Runs tests with --leak-check=full                β”‚
β”‚    └─► Artifact: valgrind-output.txt                    β”‚
β”‚                                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Quality Metrics:

SonarCloud Quality Gate
    β”‚
    β”œβ”€β–Ί Coverage: > 80%
    β”œβ”€β–Ί Duplications: < 3%
    β”œβ”€β–Ί Maintainability Rating: A
    β”œβ”€β–Ί Reliability Rating: A
    β”œβ”€β–Ί Security Rating: A
    └─► Pass/Fail Decision

Complexity Check
    β”‚
    β”œβ”€β–Ί Max CCN per function: 15
    β”œβ”€β–Ί Flag high-complexity functions
    └─► Suggest refactoring

Memory Safety
    β”‚
    β”œβ”€β–Ί Zero memory leaks
    β”œβ”€β–Ί No invalid access
    └─► All tests pass under Valgrind

Exit Criteria: Quality gate passes, complexity acceptable, no memory leaks

Release Workflow

Tag Created (v*.*.*)
    β”‚
    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Release Pipeline Triggers                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚
    β”œβ”€β–Ί Build all platforms (Linux, macOS, Windows)
    β”‚
    β”œβ”€β–Ί Run full test suite
    β”‚
    β”œβ”€β–Ί Package binaries
    β”‚   β”œβ”€β–Ί .tar.gz (Linux)
    β”‚   β”œβ”€β–Ί .pkg (macOS)
    β”‚   └─► .zip (Windows)
    β”‚
    β”œβ”€β–Ί Generate checksums (SHA256)
    β”‚
    β”œβ”€β–Ί Create GitHub Release
    β”‚   β”œβ”€β–Ί Upload artifacts
    β”‚   β”œβ”€β–Ί Generate release notes
    β”‚   └─► Mark as latest/pre-release
    β”‚
    └─► Notify (optional)

Artifact Management

Build Artifacts
    β”‚
    β”œβ”€β–Ί Build Outputs
    β”‚   β”œβ”€β–Ί obs-polyemesis.so (Linux)
    β”‚   β”œβ”€β–Ί obs-polyemesis.dylib (macOS)
    β”‚   └─► obs-polyemesis.dll (Windows)
    β”‚
    β”œβ”€β–Ί Test Results
    β”‚   β”œβ”€β–Ί test-results.xml (JUnit)
    β”‚   └─► coverage.xml (Cobertura)
    β”‚
    β”œβ”€β–Ί Security Reports
    β”‚   β”œβ”€β–Ί *.sarif files
    β”‚   └─► Uploaded to GitHub Security
    β”‚
    β”œβ”€β–Ί Quality Reports
    β”‚   β”œβ”€β–Ί lizard-report.html
    β”‚   β”œβ”€β–Ί valgrind-output.txt
    β”‚   └─► sonarcloud results
    β”‚
    └─► Retention: 30 days

Performance Metrics

Typical pipeline execution times:

Stage Duration
Lint & Format ~2 min
Build (all platforms) ~8 min
Tests ~3 min
Security Scanning ~5 min
Quality Analysis ~6 min
Total ~25 min

Branch Protection Rules

main branch
    β”‚
    β”œβ”€β–Ί Require pull request
    β”‚   β”œβ”€β–Ί Require 1 approval (recommended)
    β”‚   └─► Dismiss stale reviews
    β”‚
    β”œβ”€β–Ί Require status checks
    β”‚   β”œβ”€β–Ί lint (all jobs)
    β”‚   β”œβ”€β–Ί build-and-test (all platforms)
    β”‚   β”œβ”€β–Ί security (CodeQL, Snyk, Trivy)
    β”‚   └─► quality-analysis (SonarCloud)
    β”‚
    β”œβ”€β–Ί Require branches up to date
    β”‚
    β”œβ”€β–Ί Block force pushes
    β”‚
    └─► Block deletions

Monitoring and Debugging

View Pipeline Status

# List recent runs
gh run list --limit 10

# View specific run
gh run view <run-id>

# View logs
gh run view <run-id> --log

# Download artifacts
gh run download <run-id>

Failed Pipeline Debugging

1. Check which job failed:
   gh run view <run-id>

2. View detailed logs:
   gh run view <run-id> --log-failed

3. Download artifacts for inspection:
   gh run download <run-id>

4. Reproduce locally:
   - Use same CMake flags
   - Run same test commands
   - Check dependencies match CI

Local Testing with act

# Install act (GitHub Actions locally)
brew install act  # macOS
# or
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash

# Run lint workflow
act workflow_call -W .github/workflows/lint.yaml

# Run build workflow (Linux only)
act workflow_call -W .github/workflows/build-project.yaml -j ubuntu-build

# List available workflows
act -l

Security Best Practices

  1. No secrets in code - Gitleaks prevents this
  2. Dependency scanning - Snyk, Trivy catch vulnerabilities
  3. Code analysis - CodeQL, Semgrep find security bugs
  4. SARIF upload - All findings go to Security tab
  5. Scheduled scans - Security runs weekly on Monday

Optimization Tips

Speed Up Pipeline

  1. Use caching:

    - uses: actions/cache@v4
      with:
        path: build
        key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}
  2. Parallel jobs:

    • Lint jobs run in parallel
    • Build matrix runs concurrently
    • Security scanners run simultaneously
  3. Fail fast:

    • Lint fails early (Stage 1)
    • Prevents unnecessary builds

Reduce Costs

  1. Self-hosted runners for heavy jobs

  2. Skip CI for docs-only changes:

    git commit -m "docs: update readme [skip ci]"
    
  3. Conditional workflows:

    if: github.event_name == 'push' && github.ref == 'refs/heads/main'

For more information, see: