Integration

CI/CD integration

The clean contract is simple: analyze everywhere, protect the committed baseline with diff on pull requests, and publish the HTML report when people need a shareable artifact. Keep the first run simple; add gates only after the team agrees on the baseline.

Minimal pattern

This is the smallest pipeline shape that preserves the zero-config first-run story while still enforcing regressions where it matters.

  1. Install the .NET SDK required by the repo.
  2. Install the global SimplicityTools CLI in the job.
  3. Run dotnet simplicity analyze on all relevant builds.
  4. Run dotnet simplicity diff --fail-on-regression on pull requests once the baseline is committed.
  5. Optionally generate dotnet simplicity report and publish simplicity-report/ as an artifact.

GitHub Actions

The GitHub Actions flow mirrors the docs source exactly: setup SDK, install tool, restore, analyze, and gate PRs with diff.

name: Complexity Check
on: [pull_request, push]

jobs:
  simplicity:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '10.0.x'
      - run: dotnet tool install --global SimplicityTools.Cli
      - run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
      - run: dotnet restore
      - run: dotnet simplicity analyze YourSolution.sln
      - if: github.event_name == 'pull_request'
        run: dotnet simplicity diff YourSolution.sln --fail-on-regression

Azure Pipelines and GitLab CI

The contract does not change. Only the setup step syntax is platform-specific.

Azure Pipelines

- task: UseDotNet@2
  inputs:
    version: '10.0.x'
- script: dotnet tool install --global SimplicityTools.Cli
- script: echo "##vso[task.prependpath]$HOME/.dotnet/tools"
- script: dotnet restore
- script: dotnet simplicity diff $(Build.SourcesDirectory)/YourSolution.sln --fail-on-regression

GitLab CI

complexity-check:
  image: mcr.microsoft.com/dotnet/sdk:10.0
  script:
    - dotnet tool install --global SimplicityTools.Cli
    - export PATH="$HOME/.dotnet/tools:$PATH"
    - dotnet restore
    - dotnet simplicity analyze $CI_PROJECT_DIR/YourSolution.sln
    - dotnet simplicity diff $CI_PROJECT_DIR/YourSolution.sln --fail-on-regression

Do not skip these operational details

The common failures are boring, which is exactly why they keep breaking otherwise good pipelines.

  • Commit .simplicity-baseline.json if you expect diff to work in CI.
  • Add ~/.dotnet/tools (or the Windows equivalent) to PATH explicitly in every job.
  • Restore the solution before running the CLI so analyzers and project references resolve consistently.
  • Publish simplicity-report/ as an artifact if you want the HTML output to survive the job.