sqc 0.4.13

Software Code Quality - CERT C compliance checker
# SqC Static Analysis - GitHub Actions Example Workflow
#
# This workflow runs SqC CERT C analysis on your C/C++ codebase.
# - On PRs: analyzes only changed files (--diff mode)
# - On push to main: full repository scan
# - Uploads SARIF results to GitHub Code Scanning
#
# Prerequisites:
#   - SqC must be built or available as a binary
#   - A sqc-rules.toml manifest (or use built-in defaults)

name: SqC CERT C Analysis

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build SqC
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Cache Cargo registry and build
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Build SqC
        run: cargo build --release

      - name: Upload SqC binary
        uses: actions/upload-artifact@v4
        with:
          name: sqc-binary
          path: target/release/sqc
          retention-days: 1

  analyze-pr:
    name: Analyze PR (diff only)
    if: github.event_name == 'pull_request'
    needs: build
    runs-on: ubuntu-latest
    permissions:
      security-events: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # Full history for --diff mode

      - name: Download SqC binary
        uses: actions/download-artifact@v4
        with:
          name: sqc-binary

      - name: Make SqC executable
        run: chmod +x sqc

      - name: Run SqC (diff mode)
        run: |
          ./sqc . --diff \
            --min-severity Medium \
            --fail-on-severity High \
            --export results.sarif

      - name: Upload SARIF to GitHub Code Scanning
        uses: github/codeql-action/upload-sarif@v3
        if: always()
        with:
          sarif_file: results.sarif

  analyze-full:
    name: Full Analysis
    if: github.event_name == 'push'
    needs: build
    runs-on: ubuntu-latest
    permissions:
      security-events: write
    steps:
      - uses: actions/checkout@v4

      - name: Download SqC binary
        uses: actions/download-artifact@v4
        with:
          name: sqc-binary

      - name: Make SqC executable
        run: chmod +x sqc

      - name: Run SqC (full scan)
        run: |
          ./sqc . -d . \
            --min-severity Medium \
            --fail-on-severity High \
            --export results.sarif

      - name: Upload SARIF to GitHub Code Scanning
        uses: github/codeql-action/upload-sarif@v3
        if: always()
        with:
          sarif_file: results.sarif