Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code-quality-reports Scheduled and Manual Runs #27129

Merged
2 changes: 0 additions & 2 deletions eng/pipelines/code-quality-reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ jobs:
arguments: >
-BuildReason $(Build.Reason)
-SourceBranch "HEAD"
-TargetBranch "origin/$("$(System.PullRequest.TargetBranch)"
-replace "refs/heads/")"
-LintingPipelineVariable "LintingGoals"
pwsh: true
displayName: 'Generate Linting Commands'
Expand Down
9 changes: 4 additions & 5 deletions eng/pipelines/scripts/Get-Linting-Commands.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ param(
[Parameter(Mandatory = $true)]
[string]$SourceBranch,

[Parameter(Mandatory = $true)]
[string]$TargetBranch,
[string]$TargetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/"),

[Parameter(Mandatory = $true)]
[string]$LintingPipelineVariable
Expand All @@ -49,8 +48,8 @@ Write-Host "Source branch: ${SourceBranch}"
Write-Host "Target branch: ${TargetBranch}"
Write-Host "Linting pipeline variable: ${LintingPipelineVariable}"

if ($BuildReason -eq "Scheduled") {
Write-Host "Scheduled pipeline runs always use linting goals 'checkstyle:check revapi:check spotbugs:check'"
if ($BuildReason -ne "PullRequest") {
Write-Host "Non-PR pipeline runs always use linting goals 'checkstyle:check revapi:check spotbugs:check'"
Write-Host "##vso[task.setvariable variable=${LintingPipelineVariable};]checkstyle:check revapi:check spotbugs:check"
exit 0
}
Expand All @@ -59,7 +58,7 @@ $lintingGoals = ''
$baseDiffDirectory = 'eng/code-quality-reports/src/main'

$checkstyleSourceChanged = (git diff $TargetBranch $SourceBranch --name-only --relative -- "${baseDiffDirectory}/java/com/azure/tools/checkstyle/*").Count -gt 0
$checkstyleConfigChanged = (git diff $targetBranch $SourceBranch --name-only --relative -- "${baseDiffDirectory}/resources/checkstyle/*").Count -gt 0
$checkstyleConfigChanged = (git diff $TargetBranch $SourceBranch --name-only --relative -- "${baseDiffDirectory}/resources/checkstyle/*").Count -gt 0
if ($checkstyleSourceChanged -or $checkstyleConfigChanged) {
$lintingGoals += 'checkstyle:check'
}
Expand Down