-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathcodeowners-linter.yml
More file actions
76 lines (67 loc) · 3.89 KB
/
codeowners-linter.yml
File metadata and controls
76 lines (67 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Lint the CODEOWNERS file for a given repository and filter out baseline errors
# Note: Due to the nature of the verifications, which includes source paths/globs
# for the repository, this pipeline cannot use sparse-checkout.
trigger: none
pr:
branches:
include:
- main
- feature/*
- hotfix/*
- release/*
paths:
include:
- .github/CODEOWNERS
- .github/CODEOWNERS_baseline_errors.txt
- eng/common/pipelines/codeowners-linter.yml
stages:
- stage: Run
variables:
skipComponentGovernanceDetection: true
nugetMultiFeedWarnLevel: 'none'
baseBranchBaseline: ''
jobs:
- job: Run
timeoutInMinutes: 120
pool:
name: azsdk-pool-mms-ubuntu-2204-general
vmImage: ubuntu-22.04
variables:
CodeownersLinterVersion: '1.0.0-dev.20240614.4'
DotNetDevOpsFeed: "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json"
RepoLabelUri: "https://azuresdkartifacts.blob.core.windows.net/azure-sdk-write-teams/repository-labels-blob"
TeamUserUri: "https://azuresdkartifacts.blob.core.windows.net/azure-sdk-write-teams/azure-sdk-write-teams-blob"
UserOrgUri: "https://azuresdkartifacts.blob.core.windows.net/azure-sdk-write-teams/user-org-visibility-blob"
steps:
- task: DotNetCoreCLI@2
displayName: 'Install CodeownersLinter'
inputs:
command: custom
custom: 'tool'
arguments: 'install --global --add-source "$(DotNetDevOpsFeed)" --version "$(CodeownersLinterVersion)" "Azure.Sdk.Tools.CodeownersLinter"'
workingDirectory: '$(Build.SourcesDirectory)/eng/common'
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- pwsh: |
Write-Host "git checkout $ENV:SYSTEM_PULLREQUEST_TARGETBRANCH"
git checkout $ENV:SYSTEM_PULLREQUEST_TARGETBRANCH
displayName: Checkout the base branch
- pwsh: |
# Generate the base branch baseline file to the Build.BinariesDirectory. This will create
# a baseline error file against the CODEOWNERS in the base branch
$baseBranchBaselineFile = "$(Build.BinariesDirectory)/CODEOWNERS_BaseBranch_Baseline_errors.txt"
Write-Host "codeowners-linter --repoRoot $(Build.SourcesDirectory) --repoName $(Build.Repository.Name) -gbl -rUri ""$(RepoLabelUri)"" -tUri ""$(TeamUserUri)"" -uUri ""$(UserOrgUri)"" -bbf ""$baseBranchBaselineFile"""
codeowners-linter --repoRoot $(Build.SourcesDirectory) --repoName $(Build.Repository.Name) -gbl -rUri "$(RepoLabelUri)" -tUri "$(TeamUserUri)" -uUri "$(UserOrgUri)" -bbf "$baseBranchBaselineFile"
echo "##vso[task.setvariable variable=baseBranchBaseline]$baseBranchBaselineFile"
displayName: 'Generate baseline file for base branch'
workingDirectory: '$(Build.SourcesDirectory)/eng/common'
- pwsh: |
Write-Host "git checkout refs/remotes/pull/$ENV:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/merge"
git checkout refs/remotes/pull/$ENV:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER/merge
displayName: Checkout the PR branch
- pwsh: |
# In the case of a PR, the baseBranchBaseline will be set which will be used to further filter results.
# For scheduled runs, the baseBranchBaseline won't be set and only the existing baseline file will be used to filter
Write-Host "codeowners-linter --repoRoot $(Build.SourcesDirectory) --repoName $(Build.Repository.Name) -fbl -rUri ""$(RepoLabelUri)"" -tUri ""$(TeamUserUri)"" -uUri ""$(UserOrgUri)"" -bbf ""$(baseBranchBaseline)"""
codeowners-linter --repoRoot $(Build.SourcesDirectory) --repoName $(Build.Repository.Name) -fbl -rUri "$(RepoLabelUri)" -tUri "$(TeamUserUri)" -uUri "$(UserOrgUri)" -bbf "$(baseBranchBaseline)"
displayName: 'Lint CODEOWNERS and filter using baseline'
workingDirectory: '$(Build.SourcesDirectory)/eng/common'