|
| 1 | +--- |
| 2 | +applyTo: "eng/pipelines/**,*.yml" |
| 3 | +--- |
| 4 | +# Azure DevOps Pipelines Guide |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +This repository uses Azure DevOps Pipelines for CI/CD. The pipeline configurations are located in `eng/pipelines/`. |
| 9 | + |
| 10 | +**ADO Organization**: sqlclientdrivers |
| 11 | +**ADO Project**: ADO.NET |
| 12 | + |
| 13 | +## Pipeline Structure |
| 14 | + |
| 15 | +``` |
| 16 | +eng/pipelines/ |
| 17 | +├── abstractions/ # Abstractions package pipelines |
| 18 | +├── azure/ # Azure package pipelines |
| 19 | +├── common/ # Shared templates |
| 20 | +│ └── templates/ |
| 21 | +│ ├── jobs/ # Reusable job templates |
| 22 | +│ ├── stages/ # Reusable stage templates |
| 23 | +│ └── steps/ # Reusable step templates |
| 24 | +├── jobs/ # Top-level job definitions |
| 25 | +├── libraries/ # Shared variable definitions |
| 26 | +├── stages/ # Stage definitions |
| 27 | +├── steps/ # Step definitions |
| 28 | +├── variables/ # Variable templates |
| 29 | +├── akv-official-pipeline.yml # AKV provider official/signing build |
| 30 | +├── dotnet-sqlclient-ci-core.yml # Core CI pipeline (reusable) |
| 31 | +├── dotnet-sqlclient-ci-package-reference-pipeline.yml # CI with package references |
| 32 | +├── dotnet-sqlclient-ci-project-reference-pipeline.yml # CI with project references |
| 33 | +├── dotnet-sqlclient-signing-pipeline.yml # Package signing pipeline |
| 34 | +├── sqlclient-pr-package-ref-pipeline.yml # PR validation (package ref) |
| 35 | +├── sqlclient-pr-project-ref-pipeline.yml # PR validation (project ref) |
| 36 | +└── stress-tests-pipeline.yml # Stress testing |
| 37 | +``` |
| 38 | + |
| 39 | +## Main Pipelines |
| 40 | + |
| 41 | +### CI Core Pipeline (`dotnet-sqlclient-ci-core.yml`) |
| 42 | +Reusable core CI pipeline consumed by both project-reference and package-reference CI pipelines. Configurable parameters: |
| 43 | + |
| 44 | +| Parameter | Description | Default | |
| 45 | +|-----------|-------------|---------| |
| 46 | +| `targetFrameworks` | Windows test frameworks | `[net462, net8.0, net9.0, net10.0]` | |
| 47 | +| `targetFrameworksUnix` | Unix test frameworks | `[net8.0, net9.0, net10.0]` | |
| 48 | +| `referenceType` | Project or Package reference | Required | |
| 49 | +| `buildConfiguration` | Debug or Release | Required | |
| 50 | +| `useManagedSNI` | Test with managed SNI | `[false, true]` | |
| 51 | +| `testJobTimeout` | Test job timeout (minutes) | Required | |
| 52 | +| `runAlwaysEncryptedTests` | Include AE tests | `true` | |
| 53 | +| `enableStressTests` | Include stress test stage | `false` | |
| 54 | + |
| 55 | +### CI Reference Pipelines |
| 56 | +- `dotnet-sqlclient-ci-project-reference-pipeline.yml` — Full CI using project references (builds from source) |
| 57 | +- `dotnet-sqlclient-ci-package-reference-pipeline.yml` — Full CI using package references (tests against published NuGet packages) |
| 58 | + |
| 59 | +### PR Validation Pipelines |
| 60 | +- `sqlclient-pr-project-ref-pipeline.yml` — PR validation with project references |
| 61 | +- `sqlclient-pr-package-ref-pipeline.yml` — PR validation with package references |
| 62 | + |
| 63 | +These pipelines trigger on pull requests and run a subset of the full CI matrix to provide fast feedback. |
| 64 | + |
| 65 | +### Official/Signing Pipeline (`dotnet-sqlclient-signing-pipeline.yml`) |
| 66 | +Signs and publishes NuGet packages. Used for official releases. Requires secure service connections and key vault access for code signing. |
| 67 | + |
| 68 | +### AKV Official Pipeline (`akv-official-pipeline.yml`) |
| 69 | +Builds and signs the `Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider` add-on package separately from the main driver. Uses 1ES pipeline templates for compliance. |
| 70 | + |
| 71 | +### Stress Tests Pipeline (`stress-tests-pipeline.yml`) |
| 72 | +Optional pipeline for long-running stress and endurance testing. Enabled via `enableStressTests` parameter in CI core. |
| 73 | + |
| 74 | +## Build Stages |
| 75 | + |
| 76 | +1. **build_abstractions_package_stage**: Build and pack abstractions |
| 77 | +2. **build_mds_akv_packages_stage**: Build main driver and AKV packages |
| 78 | +3. **build_azure_package_stage**: Build Azure extensions package |
| 79 | +4. **stress_tests_stage**: Optional stress testing |
| 80 | +5. **run_tests_stage**: Execute all test suites |
| 81 | + |
| 82 | +## Test Configuration |
| 83 | + |
| 84 | +### Test Sets |
| 85 | +Tests are divided into sets for parallelization: |
| 86 | +- `TestSet=1` — First partition of tests |
| 87 | +- `TestSet=2` — Second partition |
| 88 | +- `TestSet=3` — Third partition |
| 89 | +- `TestSet=AE` — Always Encrypted tests |
| 90 | + |
| 91 | +### Test Filters |
| 92 | +Tests use category-based filtering. The default filter excludes both `failing` and `flaky` tests: |
| 93 | +``` |
| 94 | +category!=failing&category!=flaky |
| 95 | +``` |
| 96 | + |
| 97 | +Category values: |
| 98 | +- `nonnetfxtests` — Excluded on .NET Framework |
| 99 | +- `nonnetcoreapptests` — Excluded on .NET Core |
| 100 | +- `nonwindowstests` — Excluded on Windows |
| 101 | +- `nonlinuxtests` — Excluded on Linux |
| 102 | +- `failing` — Known permanent failures (excluded from all runs) |
| 103 | +- `flaky` — Intermittently failing tests (quarantined, run separately) |
| 104 | + |
| 105 | +### Flaky Test Quarantine in Pipelines |
| 106 | +Quarantined tests (`[Trait("Category", "flaky")]`) run in **separate pipeline steps** after the main test steps. This ensures: |
| 107 | +- Main test runs are **not blocked** by intermittent failures |
| 108 | +- Flaky tests are still **monitored** for regression or resolution |
| 109 | +- Code coverage is **not collected** for flaky test runs |
| 110 | +- Results appear in pipeline output for visibility |
| 111 | + |
| 112 | +The quarantine steps are configured in: |
| 113 | +- `eng/pipelines/common/templates/steps/build-and-run-tests-netcore-step.yml` |
| 114 | +- `eng/pipelines/common/templates/steps/build-and-run-tests-netfx-step.yml` |
| 115 | +- `eng/pipelines/common/templates/steps/run-all-tests-step.yml` |
| 116 | + |
| 117 | +### Test Timeout |
| 118 | +All test runs use `--blame-hang-timeout 10m` (configured in `build.proj`). Tests exceeding 10 minutes are killed and reported as failures. |
| 119 | + |
| 120 | +### SNI Testing |
| 121 | +The `useManagedSNI` parameter controls testing with: |
| 122 | +- Native SNI (`false`) - Windows native library |
| 123 | +- Managed SNI (`true`) - Cross-platform managed implementation |
| 124 | + |
| 125 | +## Variables |
| 126 | + |
| 127 | +### Build Variables (`ci-build-variables.yml`) |
| 128 | +Common build configuration: |
| 129 | +- Package versions |
| 130 | +- Build paths |
| 131 | +- Signing configuration |
| 132 | + |
| 133 | +### Runtime Variables |
| 134 | +Set via pipeline parameters or UI: |
| 135 | +- `Configuration` - Debug/Release |
| 136 | +- `Platform` - AnyCPU/x86/x64 |
| 137 | +- `TF` - Target framework |
| 138 | + |
| 139 | +## Creating Pipeline Changes |
| 140 | + |
| 141 | +### Adding New Test Categories |
| 142 | +1. Add category attribute to tests: `[Category("newcategory")]` |
| 143 | +2. Update filter expressions in test job templates |
| 144 | +3. Document category purpose in test documentation |
| 145 | + |
| 146 | +### Adding New Pipeline Parameters |
| 147 | +1. Define parameter in appropriate `.yml` file |
| 148 | +2. Add to parameter passing in calling templates |
| 149 | +3. Document in this file |
| 150 | + |
| 151 | +### Modifying Build Steps |
| 152 | +1. Changes should be made in template files for reusability |
| 153 | +2. Test changes locally when possible |
| 154 | +3. Submit as PR - validation will run |
| 155 | + |
| 156 | +## Best Practices |
| 157 | + |
| 158 | +### Template Design |
| 159 | +- Use templates for reusable definitions |
| 160 | +- Pass parameters explicitly (avoid global variables) |
| 161 | +- Use descriptive stage/job/step names |
| 162 | + |
| 163 | +### Variable Management |
| 164 | +- Use template variables for shared values |
| 165 | +- Use pipeline parameters for per-run configuration |
| 166 | +- Avoid hardcoding versions (use Directory.Packages.props) |
| 167 | + |
| 168 | +### Test Infrastructure |
| 169 | +- Ensure tests are properly categorized |
| 170 | +- Handle test configuration files properly |
| 171 | +- Use test matrix for cross-platform coverage |
| 172 | + |
| 173 | +## Troubleshooting |
| 174 | + |
| 175 | +### Common Issues |
| 176 | +1. **Test failures due to missing config**: Ensure `config.json` exists |
| 177 | +2. **Platform-specific failures**: Check platform exclusion categories |
| 178 | +3. **Timeout issues**: Increase `testJobTimeout` parameter |
| 179 | + |
| 180 | +### Debugging Pipelines |
| 181 | +- Enable debug mode via `debug: true` parameter |
| 182 | +- Use `dotnetVerbosity: diagnostic` for detailed output |
| 183 | +- Check build logs in Azure DevOps |
| 184 | + |
| 185 | +## Security Considerations |
| 186 | + |
| 187 | +- Pipelines use service connections for artifact publishing |
| 188 | +- Signing uses secure key vault integration |
| 189 | +- Sensitive configuration should use pipeline secrets |
| 190 | +- Never commit credentials in pipeline files |
| 191 | + |
| 192 | +## Related Documentation |
| 193 | + |
| 194 | +- [BUILDGUIDE.md](../../BUILDGUIDE.md) - Local build instructions |
| 195 | +- [Azure DevOps Documentation](https://learn.microsoft.com/azure/devops/pipelines/) |
0 commit comments