-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Error Logging for CI checks (#26078)
- Loading branch information
1 parent
f3b2c51
commit be3cd97
Showing
7 changed files
with
162 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,54 @@ | ||
function Get-ChangedFiles($baseCommitish="HEAD^", $targetCommitish="HEAD", $diffFilter="d") | ||
{ | ||
# diff-filter=d is to exclude any deleted files as we don't generally | ||
# want to do work against files that no longer exist. | ||
# https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203 | ||
function Get-ChangedFiles($baseCommitish = "HEAD^", $targetCommitish = "HEAD", $diffFilter = "d") { | ||
# diff-filter=d is to exclude any deleted files as we don't generally | ||
# want to do work against files that no longer exist. | ||
# https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203 | ||
|
||
# core.quotepath=off is to help avoid quoting in the returned paths | ||
# https://git-scm.com/docs/git-config/2.22.0#Documentation/git-config.txt-corequotePath | ||
# core.quotepath=off is to help avoid quoting in the returned paths | ||
# https://git-scm.com/docs/git-config/2.22.0#Documentation/git-config.txt-corequotePath | ||
|
||
# Get all the files that have changed between HEAD and the commit before head | ||
# For PR's that last commit is always a merge commit so HEAD^ will get the parent | ||
# commit of the base branch and as such will diff HEAD against HEAD^ | ||
$changedFiles = git -c core.quotepath=off diff --name-only --diff-filter=$diffFilter $baseCommitish $targetCommitish | ||
# Get all the files that have changed between HEAD and the commit before head | ||
# For PR's that last commit is always a merge commit so HEAD^ will get the parent | ||
# commit of the base branch and as such will diff HEAD against HEAD^ | ||
$changedFiles = git -c core.quotepath=off diff --name-only --diff-filter=$diffFilter $baseCommitish $targetCommitish | ||
|
||
Write-Verbose "Changed files:" | ||
$changedFiles | ForEach-Object { Write-Verbose "$_" } | ||
Write-Verbose "Changed files:" | ||
$changedFiles | ForEach-Object { Write-Verbose "$_" } | ||
|
||
return $changedFiles | ||
return $changedFiles | ||
} | ||
|
||
function Get-ChangedSwaggerFiles() | ||
{ | ||
$changedFiles = Get-ChangedFilesUnderSpecification | ||
function Get-ChangedSwaggerFiles() { | ||
$changedFiles = Get-ChangedFilesUnderSpecification | ||
|
||
$changedSwaggerFiles = $changedFiles | Where-Object { | ||
$_.EndsWith(".json") | ||
} | ||
$changedSwaggerFiles = $changedFiles | Where-Object { | ||
$_.EndsWith(".json") | ||
} | ||
|
||
return $changedSwaggerFiles | ||
return $changedSwaggerFiles | ||
} | ||
|
||
function Get-ChangedFilesUnderSpecification($changedFiles = (Get-ChangedFiles)) | ||
{ | ||
$changedFilesUnderSpecification = $changedFiles | Where-Object { | ||
$_.StartsWith("specification") | ||
} | ||
function Get-ChangedFilesUnderSpecification($changedFiles = (Get-ChangedFiles)) { | ||
$changedFilesUnderSpecification = $changedFiles | Where-Object { | ||
$_.StartsWith("specification") | ||
} | ||
|
||
return $changedFilesUnderSpecification | ||
return $changedFilesUnderSpecification | ||
} | ||
|
||
function Get-ChangedCoreFiles($changedFiles = (Get-ChangedFiles)) | ||
{ | ||
$rootFiles = @( | ||
".gitattributes", | ||
".prettierrc.json", | ||
"package-lock.json", | ||
"package.json", | ||
"tsconfig.json" | ||
) | ||
|
||
$coreFiles = $changedFiles | Where-Object { | ||
$_.StartsWith("eng/") -or | ||
$_.StartsWith("specification/common-types/") -or | ||
$_ -in $rootFiles | ||
} | ||
|
||
return $coreFiles | ||
function Get-ChangedCoreFiles($changedFiles = (Get-ChangedFiles)) { | ||
$rootFiles = @( | ||
".gitattributes", | ||
".prettierrc.json", | ||
"package-lock.json", | ||
"package.json", | ||
"tsconfig.json" | ||
) | ||
|
||
$coreFiles = $changedFiles | Where-Object { | ||
$_.StartsWith("eng/") -or | ||
$_.StartsWith("specification/common-types/") -or | ||
$_ -in $rootFiles | ||
} | ||
|
||
return $coreFiles | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
function Test-SupportsDevOpsLogging() { | ||
return ($null -ne $env:SYSTEM_TEAMPROJECTID) | ||
} | ||
|
||
function LogInfo { | ||
Write-Host "$args" | ||
} | ||
|
||
function LogWarning { | ||
if (Test-SupportsDevOpsLogging) { | ||
Write-Host ("##vso[task.LogIssue type=warning;]$args" -replace "`n", "%0D%0A") | ||
} | ||
else { | ||
Write-Warning "$args" | ||
} | ||
} | ||
|
||
function LogErrorForFile($file, $errorString) | ||
{ | ||
if (Test-SupportsDevOpsLogging) { | ||
Write-Host ("##vso[task.logissue type=error;sourcepath=$file;linenumber=1;columnnumber=1;]$errorString" -replace "`n", "%0D%0A") | ||
} | ||
else { | ||
Write-Error "[Error in file $file]$errorString" | ||
} | ||
} | ||
function LogError { | ||
if (Test-SupportsDevOpsLogging) { | ||
Write-Host ("##vso[task.LogIssue type=error;]$args" -replace "`n", "%0D%0A") | ||
} | ||
else { | ||
Write-Error "$args" | ||
} | ||
} | ||
|
||
function LogDebug { | ||
if (Test-SupportsDevOpsLogging) { | ||
Write-Host "[debug]$args" | ||
} | ||
else { | ||
Write-Debug "$args" | ||
} | ||
} | ||
|
||
function LogGroupStart() { | ||
if (Test-SupportsDevOpsLogging) { | ||
Write-Host "##[group]$args" | ||
} | ||
} | ||
|
||
function LogGroupEnd() { | ||
if (Test-SupportsDevOpsLogging) { | ||
Write-Host "##[endgroup]" | ||
} | ||
} | ||
|
||
function LogJobFailure() { | ||
if (Test-SupportsDevOpsLogging) { | ||
Write-Host "##vso[task.complete result=Failed;]" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters