[vcpkg ci] Update formatting CI (#12314)

* stage checking formatting

this means that the port CI won't run if the formatting failed

* fix invalid names

* add formatting of manifests

* fix dependsOn name

* fix a thing

* CRs

* oops, typo
This commit is contained in:
nicole mazzuca 2020-07-07 14:09:33 -07:00 committed by GitHub
parent f8e975d44a
commit 9606917c81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 100 additions and 20 deletions

View File

@ -5,7 +5,36 @@ variables:
windows-pool: 'PrWin-2020-06-30'
linux-pool: 'PrLin-2020-06-30'
jobs:
stages:
- stage: check_cxx_formatting
displayName: 'Check the formatting of the C++'
pool: $(windows-pool)
jobs:
- job:
steps:
- task: Powershell@2
displayName: 'Check C++ Formatting'
inputs:
filePath: 'scripts/azure-pipelines/windows/Check-CxxFormatting.ps1'
arguments: '-Root .'
- stage: check_manifest_formatting
displayName: Check the formatting of port manifests
pool: $(windows-pool)
dependsOn: []
jobs:
- job:
steps:
- task: Powershell@2
displayName: 'Check port manifest Formatting'
inputs:
filePath: 'scripts/azure-pipelines/windows/Check-ManifestFormatting.ps1'
arguments: '-Root . -Downloads D:\Downloads'
- stage: run_port_ci
displayName: 'Run the Port CI'
dependsOn:
- check_cxx_formatting
- check_manifest_formatting
jobs:
- template: windows/azure-pipelines.yml
parameters:
triplet: x86-windows

View File

@ -1,7 +1,7 @@
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$Toolsrc,
[string]$Root,
[Parameter()]
[switch]$IgnoreErrors # allows one to just format
)
@ -13,23 +13,20 @@ if (-not (Test-Path $clangFormat))
throw
}
$Toolsrc = Get-Item $Toolsrc
Push-Location $Toolsrc
$toolsrc = Get-Item "$Root/toolsrc"
Push-Location $toolsrc
try
{
$files = Get-ChildItem -Recurse -LiteralPath "$Toolsrc/src" -Filter '*.cpp'
$files += Get-ChildItem -Recurse -LiteralPath "$Toolsrc/include/vcpkg" -Filter '*.h'
$files += Get-ChildItem -Recurse -LiteralPath "$Toolsrc/include/vcpkg-test" -Filter '*.h'
$files += Get-Item "$Toolsrc/include/pch.h"
$files = Get-ChildItem -Recurse -LiteralPath "$toolsrc/src" -Filter '*.cpp'
$files += Get-ChildItem -Recurse -LiteralPath "$toolsrc/include/vcpkg" -Filter '*.h'
$files += Get-ChildItem -Recurse -LiteralPath "$toolsrc/include/vcpkg-test" -Filter '*.h'
$files += Get-Item "$toolsrc/include/pch.h"
$fileNames = $files.FullName
& $clangFormat -style=file -i @fileNames
$changedFiles = git status --porcelain $Toolsrc | ForEach-Object {
(-split $_)[1]
}
$changedFiles = & "$PSScriptRoot/Get-ChangedFiles.ps1" -Directory $toolsrc
if (-not $IgnoreErrors -and $null -ne $changedFiles)
{
$msg = @(
@ -42,7 +39,7 @@ try
$msg += ""
$msg += "clang-format should produce the following diff:"
$msg += git diff $Toolsrc
$msg += git diff $toolsrc
Write-Error ($msg -join "`n")
throw

View File

@ -0,0 +1,51 @@
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$Root,
[Parameter()]
[string]$DownloadsDirectory,
[Parameter()]
[switch]$IgnoreErrors # allows one to just format
)
$portsTree = Get-Item "$Root/ports"
if (-not (Test-Path "$Root/.vcpkg-root"))
{
Write-Error "The vcpkg root was not at $Root"
throw
}
if (-not [string]::IsNullOrEmpty($DownloadsDirectory))
{
$env:VCPKG_DOWNLOADS = $DownloadsDirectory
}
if (-not (Test-Path "$Root/vcpkg.exe"))
{
& "$Root/bootstrap-vcpkg.bat"
if (-not $?)
{
Write-Error "Bootstrapping vcpkg failed"
throw
}
}
& "$Root/vcpkg.exe" 'x-format-manifest' '--all'
$changedFiles = & "$PSScriptRoot/Get-ChangedFiles.ps1" -Directory $portsTree
if (-not $IgnoreErrors -and $null -ne $changedFiles)
{
$msg = @(
"",
"The formatting of the manifest files didn't match our expectation.",
"If your build fails here, you need to run:"
)
$msg += " vcpkg x-format-manifest --all"
$msg += ""
$msg += "vcpkg should produce the following diff:"
$msg += git diff $portsTree
Write-Error ($msg -join "`n")
throw
}

View File

@ -0,0 +1,9 @@
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$Directory
)
git status --porcelain $Directory | ForEach-Object {
(-split $_)[1]
}

View File

@ -20,13 +20,7 @@ jobs:
condition: always()
inputs:
filePath: 'scripts/azure-pipelines/windows/disk-space.ps1'
- task: Powershell@2
displayName: 'Check C++ Formatting'
condition: eq('${{ parameters.triplet }}', 'x86-windows')
inputs:
filePath: 'scripts/azure-pipelines/windows/check-formatting.ps1'
arguments: '-Toolsrc ./toolsrc'
# Note: D: is the Azure machines' temporary disk.
# Note: D: is the Azure machines' temporary disk.
- task: CmdLine@2
displayName: 'Build vcpkg'
inputs: