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

[vcpkg ci] Update formatting CI #12314

Merged
merged 7 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion scripts/azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
strega-nil marked this conversation as resolved.
Show resolved Hide resolved
- job:
steps:
- task: Powershell@2
displayName: 'Check C++ Formatting'
inputs:
filePath: 'scripts/azure-pipelines/windows/Check-CxxFormatting.ps1'
arguments: '-Toolsrc ./toolsrc'
- 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: '-PortsTree ./ports'
- 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#Requires -Version 3.0
strega-nil marked this conversation as resolved.
Show resolved Hide resolved

[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
Expand Down Expand Up @@ -26,10 +28,7 @@ try

& $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 = @(
Expand Down
55 changes: 55 additions & 0 deletions scripts/azure-pipelines/windows/Check-ManifestFormatting.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#Requires -Version 3.0

[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$PortsTree,
[Parameter()]
[switch]$IgnoreErrors # allows one to just format
)

# .../vcpkg/scripts/azure-pipelines/windows
# .../vcpkg/scripts/azure-pipelines
# .../vcpkg/scripts
# .../vcpkg
$vcpkgRoot = $PSScriptRoot `
strega-nil marked this conversation as resolved.
Show resolved Hide resolved
| Split-Path `
| Split-Path `
| Split-Path

$PortsTree = Get-Item $PortsTree

if (-not (Test-Path "$vcpkgRoot/.vcpkg-root"))
{
Write-Error "The vcpkg root was not at $vcpkgRoot; did the script get moved?"
throw
}

if (-not (Test-Path "$vcpkgRoot/vcpkg.exe"))
{
& "$vcpkgRoot/bootstrap-vcpkg.bat"
strega-nil marked this conversation as resolved.
Show resolved Hide resolved
if (-not $?)
{
Write-Error "Bootstrapping vcpkg failed"
throw
}
}

& "$vcpkgRoot/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 $Toolsrc

Write-Error ($msg -join "`n")
throw
}
9 changes: 9 additions & 0 deletions scripts/azure-pipelines/windows/Get-ChangedFiles.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$Directory
)

git status --porcelain $Directory | ForEach-Object {
(-split $_)[1]
}
8 changes: 1 addition & 7 deletions scripts/azure-pipelines/windows/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down