@@ -21,6 +21,7 @@ stages:
21
21
variables :
22
22
skipComponentGovernanceDetection : true
23
23
nugetMultiFeedWarnLevel : ' none'
24
+ baseBranchBaseline : ' '
24
25
25
26
jobs :
26
27
- job : Run
@@ -30,29 +31,46 @@ stages:
30
31
vmImage : ubuntu-22.04
31
32
32
33
variables :
33
- CodeownersLinterVersion : ' 1.0.0-dev.20240227 .2'
34
+ CodeownersLinterVersion : ' 1.0.0-dev.20240514 .2'
34
35
DotNetDevOpsFeed : " https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json"
35
36
RepoLabelUri : " https://azuresdkartifacts.blob.core.windows.net/azure-sdk-write-teams/repository-labels-blob"
36
37
TeamUserUri : " https://azuresdkartifacts.blob.core.windows.net/azure-sdk-write-teams/azure-sdk-write-teams-blob"
37
38
UserOrgUri : " https://azuresdkartifacts.blob.core.windows.net/azure-sdk-write-teams/user-org-visibility-blob"
38
39
39
40
steps :
40
- # Skip sparse checkout for the `azure-sdk-for-<lang>-pr` private mirrored repositories
41
- # as we require the github service connection to be loaded.
42
- - ${{ if not(contains(variables['Build.DefinitionName'], '-pr - ')) }} :
43
- - template : /eng/common/pipelines/templates/steps/sparse-checkout.yml
44
- parameters :
45
- Paths :
46
- - ' /*'
47
-
48
41
- task : DotNetCoreCLI@2
49
42
displayName : ' Install CodeownersLinter'
50
43
inputs :
51
44
command : custom
52
45
custom : ' tool'
53
46
arguments : ' install --global --add-source "$(DotNetDevOpsFeed)" --version "$(CodeownersLinterVersion)" "Azure.Sdk.Tools.CodeownersLinter"'
54
47
workingDirectory : ' $(Build.SourcesDirectory)/eng/common'
48
+
49
+ - ${{ if eq(variables['Build.Reason'], 'PullRequest') }} :
50
+ - pwsh : |
51
+ Write-Host "git checkout $ENV:SYSTEM_PULLREQUEST_TARGETBRANCH"
52
+ git checkout $ENV:SYSTEM_PULLREQUEST_TARGETBRANCH
53
+ displayName: Checkout the base branch
54
+
55
+ - pwsh : |
56
+ # Generate the base branch baseline file to the Build.BinariesDirectory. This will create
57
+ # a baseline error file against the CODEOWNERS in the base branch
58
+ $baseBranchBaselineFile = "$(Build.BinariesDirectory)/CODEOWNERS_BaseBranch_Baseline_errors.txt"
59
+ Write-Host "codeowners-linter --repoRoot $(Build.SourcesDirectory) --repoName $(Build.Repository.Name) -gbl -rUri ""$(RepoLabelUri)"" -tUri ""$(TeamUserUri)"" -uUri ""$(UserOrgUri)"" -bbf ""$baseBranchBaselineFile"""
60
+ codeowners-linter --repoRoot $(Build.SourcesDirectory) --repoName $(Build.Repository.Name) -gbl -rUri "$(RepoLabelUri)" -tUri "$(TeamUserUri)" -uUri "$(UserOrgUri)" -bbf "$baseBranchBaselineFile"
61
+ echo "##vso[task.setvariable variable=baseBranchBaseline]$baseBranchBaselineFile"
62
+ displayName: 'Generate baseline file for base branch'
63
+ workingDirectory: '$(Build.SourcesDirectory)/eng/common'
64
+
65
+ - pwsh : |
66
+ Write-Host "git checkout refs/remotes/pull/$ENV:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/merge"
67
+ git checkout refs/remotes/pull/$ENV:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/merge
68
+ displayName: Checkout the PR branch
69
+
55
70
- pwsh : |
56
- codeowners-linter --repoRoot $(Build.SourcesDirectory) --repoName $(Build.Repository.Name) -fbl -rUri "$(RepoLabelUri)" -tUri "$(TeamUserUri)" -uUri "$(UserOrgUri)"
71
+ # In the case of a PR, the baseBranchBaseline will be set which will be used to further filter results.
72
+ # For scheduled runs, the baseBranchBaseline won't be set and only the existing baseline file will be used to filter
73
+ Write-Host "codeowners-linter --repoRoot $(Build.SourcesDirectory) --repoName $(Build.Repository.Name) -fbl -rUri ""$(RepoLabelUri)"" -tUri ""$(TeamUserUri)"" -uUri ""$(UserOrgUri)"" -bbf ""$(baseBranchBaseline)"""
74
+ codeowners-linter --repoRoot $(Build.SourcesDirectory) --repoName $(Build.Repository.Name) -fbl -rUri "$(RepoLabelUri)" -tUri "$(TeamUserUri)" -uUri "$(UserOrgUri)" -bbf "$(baseBranchBaseline)"
57
75
displayName: 'Lint CODEOWNERS and filter using baseline'
58
76
workingDirectory: '$(Build.SourcesDirectory)/eng/common'
0 commit comments