Skip to content

Commit 41da6f6

Browse files
authored
Merge branch 'main' into xitzhang/telemetrylog
2 parents fefef7a + dec14b8 commit 41da6f6

2 files changed

Lines changed: 48 additions & 157 deletions

File tree

eng/common/pipelines/templates/steps/verify-codeowners-sections.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ parameters:
88

99
steps:
1010
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
11-
# 1. Check if CODEOWNERS changed; skip everything if it hasn't
11+
# 1. Check if CODEOWNERS changed; if so, check whether the PR was opened by azure-sdk
1212
- pwsh: |
1313
$scriptPath = [System.IO.Path]::Combine("${{ parameters.SourceRootPath }}", "eng", "common", "scripts", "get-changedfiles.ps1")
1414
try {
@@ -27,11 +27,26 @@ steps:
2727
2828
if (!$changedFiles) {
2929
Write-Host "CODEOWNERS file has not changed."
30-
Write-Host "##vso[task.setvariable variable=CodeownersChanged]false"
31-
} else {
32-
Write-Host "CODEOWNERS file has changed."
33-
Write-Host "##vso[task.setvariable variable=CodeownersChanged]true"
30+
Write-Host "##vso[task.setvariable variable=ShouldCheckCodeownersEdits]false"
31+
exit 0
3432
}
33+
34+
Write-Host "CODEOWNERS file has changed."
35+
36+
$prNumber = "$(System.PullRequest.PullRequestNumber)"
37+
$repoName = "$(Build.Repository.Name)"
38+
$prUrl = "https://api.github.com/repos/$repoName/pulls/$prNumber"
39+
$prData = Invoke-RestMethod -Uri $prUrl -MaximumRetryCount 10 -RetryIntervalSec 6
40+
$prAuthor = $prData.user.login
41+
Write-Host "PR author: $prAuthor"
42+
43+
if ($prAuthor -ieq "azure-sdk") {
44+
Write-Host "PR opened by azure-sdk. Skipping CODEOWNERS section check."
45+
Write-Host "##vso[task.setvariable variable=ShouldCheckCodeownersEdits]false"
46+
exit 0
47+
}
48+
49+
Write-Host "##vso[task.setvariable variable=ShouldCheckCodeownersEdits]true"
3550
displayName: 'Check if CODEOWNERS changed'
3651
workingDirectory: ${{ parameters.SourceRootPath }}
3752
condition: and(succeeded(), ne(variables['Skip.VerifyCodeownersSections'], 'true'))
@@ -40,7 +55,7 @@ steps:
4055
- template: /eng/common/pipelines/templates/steps/install-azsdk-cli.yml
4156
parameters:
4257
SourceRootPath: ${{ parameters.SourceRootPath }}
43-
Condition: and(succeeded(), eq(variables['CodeownersChanged'], 'true'))
58+
Condition: and(succeeded(), eq(variables['ShouldCheckCodeownersEdits'], 'true'))
4459

4560
# 3. Prepare before/after CODEOWNERS files
4661
- pwsh: |
@@ -61,13 +76,13 @@ steps:
6176
6277
if ($LASTEXITCODE) {
6378
Write-Host "Could not retrieve CODEOWNERS from HEAD~1. The file may be newly added. Skipping."
64-
Write-Host "##vso[task.setvariable variable=CodeownersChanged]false"
79+
Write-Host "##vso[task.setvariable variable=ShouldCheckCodeownersEdits]false"
6580
exit 0
6681
}
6782
Write-Host "Extracted parent CODEOWNERS to $beforeFile"
6883
displayName: 'Prepare CODEOWNERS before/after files'
6984
workingDirectory: ${{ parameters.SourceRootPath }}
70-
condition: and(succeeded(), eq(variables['CodeownersChanged'], 'true'))
85+
condition: and(succeeded(), eq(variables['ShouldCheckCodeownersEdits'], 'true'))
7186
7287
# 4. Run the section comparison script
7388
- task: Powershell@2
@@ -83,4 +98,4 @@ steps:
8398
-TempDirectory "${{ parameters.TempDirectory }}"
8499
pwsh: true
85100
workingDirectory: ${{ parameters.SourceRootPath }}
86-
condition: and(succeeded(), eq(variables['CodeownersChanged'], 'true'))
101+
condition: and(succeeded(), eq(variables['ShouldCheckCodeownersEdits'], 'true'))

0 commit comments

Comments
 (0)