# CI/CD Automation

- Section: Documentation > Use Cases > CI/CD Automation
- Canonical: https://covdbg.com/docs/use-cases/ci-cd/

---

Integrate code coverage into your continuous integration pipeline to catch regressions and track coverage trends.

## Typical CI Workflow

```
Build Tests → Run covdbg → Export LCOV → Upload/Store Artifacts
```

1. Build your tests with debug symbols (PDBs)
2. Run tests under covdbg to produce `.covdb`
3. Export to LCOV/GCOV for downstream tooling
4. Upload to coverage services or store as artifacts

## Quick Example

```powershell
# 1. Run tests with coverage
covdbg --output coverage.covdb tests.exe

# 2. Export to LCOV
covdbg convert -i coverage.covdb -f LCOV -o coverage.lcov

# 3. Upload to coverage service (example)
codecov --file coverage.lcov
```

## Environment Setup

A pipeline has nobody to sign in, so it carries a project token:

```powershell
$env:COVDBG_PROJECT_TOKEN = "<your-project-token>"
```

Store `COVDBG_PROJECT_TOKEN` as an encrypted secret in your CI system.

> **Open Source?** Public repositories are free; the pipeline still carries a project token, which is what names who is asking. See [Open Source](/docs/use-cases/open-source/) for details.

## Clean Output

covdbg leaves the console to your test results and only adds its own errors there; its log goes to a file. Use `--log-level NONE` to switch the log file off:

```powershell
covdbg --log-level NONE --output coverage.covdb tests.exe
```

## Merging Multiple Test Runs

If you have multiple test executables or parallel test jobs:

```powershell
# Run each test suite
covdbg --output unit.covdb unit_tests.exe
covdbg --output integration.covdb integration_tests.exe

# Merge results
covdbg merge -i unit.covdb -i integration.covdb -o merged.covdb

# Export merged coverage
covdbg convert -i merged.covdb -f LCOV -o coverage.lcov
```

## Why Automate Coverage

| Benefit | Description |
|---------|-------------|
| **Catch regressions** | Fail builds when coverage drops |
| **Track trends** | Monitor coverage over time |
| **Enforce standards** | Set minimum coverage thresholds |
| **Document quality** | Show coverage badges in README |

## Best Practices

1. **Run on every PR** - Get coverage feedback before merge
2. **Use consistent filters** - Keep `.covdbg.yaml` in version control
3. **Store artifacts** - Save `.covdb` and exports for debugging
4. **Fail on threshold** - Set minimum coverage requirements

## Platform-Specific Guides

* [GitHub Actions](/docs/integrations/github-actions/) - Complete workflow examples

## See Also

* [CLI Reference](/docs/reference/cli-reference/) - Command documentation
* [Configuration](/docs/reference/configuration/) - Filter setup
* [Report Formats](/docs/guides/report-formats/) - Export formats
