CI Integration

Integrate Mutagoph into your CI/CD pipeline.

GitHub Actions

Basic Setup

name: Mutation Testing

on:
  pull_request:
    branches: [main]

jobs:
  mutation:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # Required for diff-base

      - uses: actions/setup-go@v5
        with:
          go-version: '1.23'

      - name: Install mutagoph
        run: go install github.com/its-donkey/mutagoph/cmd/mutagoph@latest

      - name: Run mutation testing
        run: mutagoph run --diff-base origin/main --min-score 70

With Caching

- name: Cache mutagoph results
  uses: actions/cache@v4
  with:
    path: ~/.cache/mutagoph
    key: mutagoph-$-$
    restore-keys: |
      mutagoph-$-

- name: Run mutation testing
  run: mutagoph run --diff-base origin/main --cache

With Artifacts

- name: Run mutation testing
  run: |
    mutagoph run \
      --diff-base origin/main \
      --output json \
      --output-file mutations.json

- name: Upload results
  uses: actions/upload-artifact@v4
  if: always()
  with:
    name: mutation-results
    path: mutations.json

GitLab CI

mutation-testing:
  stage: test
  image: golang:1.23
  script:
    - go install github.com/its-donkey/mutagoph/cmd/mutagoph@latest
    - mutagoph run --diff-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME --min-score 70
  only:
    - merge_requests

Environment Variables

Configure via environment for CI:

env:
  MUTAGOPH_MUTATION_SET: standard
  MUTAGOPH_MIN_MUTATION_SCORE: 70
  MUTAGOPH_PARALLELISM: medium

Best Practices

1. Use Diff-Based Testing

Only test changed code in PRs:

mutagoph run --diff-base origin/main

2. Set Reasonable Thresholds

Start low, increase over time:

# Week 1: 60%
# Month 1: 70%
# Month 3: 80%
mutagoph run --min-score 70

3. Use Caching

Speed up repeated runs:

mutagoph run --cache

4. Use Appropriate Mutation Set

Balance thoroughness and speed:

# PRs: standard (faster)
mutagoph run --mutations standard

# Release: mutilated (thorough)
mutagoph run --mutations mutilated

5. Use Coverage Filter for Speed

Skip testing mutations on uncovered code:

# Fast mode: only test covered code
mutagoph run --coverage-filter

# Combined with diff-base for fastest CI
mutagoph run --diff-base origin/main --coverage-filter

Mutations on uncovered lines are marked as Naked and excluded from the score calculation.

6. Store Reports

Keep mutation reports for trending:

mutagoph run --output json --output-file mutations-$.json