Azure / Azure/azure-sdk-tools

[CODEOWNERS] Detect modifications to the "Client Libraries" CODEOWNERS section in PRs

Open
#14,212 0 comments 0 reactions 1 assignee Claimed by @danieljurek View on GitHub
Dominant language
C#
Stars
135
Forks
260
Avg merge
3d 1h
Merged PRs (30d)
144

Description

Modify eng/common/pipelines/codeowners-linter.yml to detect when a PR modifies the Client Libraries section of CODEOWNERS.

All new steps belong inside the existing ${{ if eq(variables['Build.Reason'], 'PullRequest') }} block. No new pipeline parameters are added.

Steps to add

1. Install azsdk (before the base-branch checkout, using the existing template):

```yaml
- template: /eng/common/pipelines/templates/steps/install-azsdk-cli.yml
parameters:
SourceRootPath: $(Build.SourcesDirectory)
```

2. After "Checkout the base branch" — export the section:

```yaml
- pwsh: |
$(AZSDK) config codeowners export-section `
--codeowners-path "$(Build.SourcesDirectory)/.github/CODEOWNERS" `
--section "Client Libraries" `
--output "$(Build.ArtifactStagingDirectory)/codeowners-sections/before.txt"
displayName: 'Export protected CODEOWNERS section (base branch)'
```

3. After "Checkout the PR branch" — export again:

```yaml
- pwsh: |
$(AZSDK) config codeowners export-section `
--codeowners-path "$(Build.SourcesDirectory)/.github/CODEOWNERS" `
--section "Client Libraries" `
--output "$(Build.ArtifactStagingDirectory)/codeowners-sections/after.txt"
displayName: 'Export protected CODEOWNERS section (PR branch)'
```

4. Compare the two files:

```yaml
- pwsh: |
$before = Get-Content "$(Build.ArtifactStagingDirectory)/codeowners-sections/before.txt" -Raw
$after = Get-Content "$(Build.ArtifactStagingDirectory)/codeowners-sections/after.txt" -Raw
if ($before -ne $after) {
Write-Error "The 'Client Libraries' section of CODEOWNERS has been modified by this PR."
exit 1
}
Write-Host "Protected CODEOWNERS section is unchanged."
displayName: 'Verify protected CODEOWNERS section is unchanged'
```

Notes
* Section name (Client Libraries) is hardcoded in the step commands. No pipeline parameters.
* Output paths use $(Build.ArtifactStagingDirectory)/codeowners-sections/before.txt and .../after.txt.
* install-azsdk-cli.yml always installs the latest released version of azsdk — no version pinning needed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.