Commit 0cda525258c5b49c7b551db5905a103fee1237a3

Patrick Steinhardt 2019-07-19T12:09:58

azure: use bash scripts across all platforms Right now, we maintain semantically equivalent build scripts in both Bash and Powershell to support both Windows and non-Windows hosts. Azure Pipelines supports Bash on Windows, too, via Git for Windows, and as such it's not really required to maintain the Powershell scripts at all. Remove them to reduce our own maintenance burden.

diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index abe0c3e..2d79dd3 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -78,7 +78,7 @@ jobs:
   displayName: 'Windows (amd64; Visual Studio)'
   pool: Hosted
   steps:
-  - template: azure-pipelines/powershell.yml
+  - template: azure-pipelines/bash.yml
     parameters:
       environmentVariables:
         CMAKE_GENERATOR: Visual Studio 12 2013 Win64
@@ -88,7 +88,7 @@ jobs:
   displayName: 'Windows (x86; Visual Studio)'
   pool: Hosted
   steps:
-  - template: azure-pipelines/powershell.yml
+  - template: azure-pipelines/bash.yml
     parameters:
       environmentVariables:
         CMAKE_GENERATOR: Visual Studio 12 2013
@@ -103,7 +103,7 @@ jobs:
     env:
       TEMP: $(Agent.TempDirectory)
       ARCH: amd64
-  - template: azure-pipelines/powershell.yml
+  - template: azure-pipelines/bash.yml
     parameters:
       environmentVariables:
         BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
@@ -120,7 +120,7 @@ jobs:
     env:
       TEMP: $(Agent.TempDirectory)
       ARCH: x86
-  - template: azure-pipelines/powershell.yml
+  - template: azure-pipelines/bash.yml
     parameters:
       environmentVariables:
         BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
diff --git a/azure-pipelines/build.ps1 b/azure-pipelines/build.ps1
deleted file mode 100644
index 96f39db..0000000
--- a/azure-pipelines/build.ps1
+++ /dev/null
@@ -1,30 +0,0 @@
-Set-StrictMode -Version Latest
-
-$ErrorActionPreference = "Stop"
-$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
-
-if ($Env:SOURCE_DIR) { $SourceDirectory = $Env:SOURCE_DIR } else { $SourceDirectory = Split-Path (Split-Path $MyInvocation.MyCommand.Path -Parent) -Parent }
-$BuildDirectory = $(Get-Location).Path
-
-Write-Host "Source directory: ${SourceDirectory}"
-Write-Host "Build directory:  ${BuildDirectory}"
-Write-Host ""
-Write-Host "Operating system version:"
-Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, ServicePackMajorVersion, BuildNumber, OSArchitecture | Format-List
-Write-Host "PATH: ${Env:PATH}"
-Write-Host ""
-
-Write-Host "##############################################################################"
-Write-Host "## Configuring build environment"
-Write-Host "##############################################################################"
-
-Invoke-Expression "cmake ${SourceDirectory} -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -DENABLE_WERROR=ON -G '${Env:CMAKE_GENERATOR}' ${Env:CMAKE_OPTIONS}"
-if ($LastExitCode -ne 0) { [Environment]::Exit($LastExitCode) }
-
-Write-Host ""
-Write-Host "##############################################################################"
-Write-Host "## Building libgit2"
-Write-Host "##############################################################################"
-
-cmake --build .
-if ($LastExitCode -ne 0) { [Environment]::Exit($LastExitCode) }
diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml
index b6d5ed8..eebc3ed 100644
--- a/azure-pipelines/nightly.yml
+++ b/azure-pipelines/nightly.yml
@@ -79,7 +79,7 @@ jobs:
   displayName: 'Windows (amd64; Visual Studio)'
   pool: Hosted
   steps:
-  - template: powershell.yml
+  - template: bash.yml
     parameters:
       environmentVariables:
         CMAKE_GENERATOR: Visual Studio 12 2013 Win64
@@ -90,7 +90,7 @@ jobs:
   displayName: 'Windows (x86; Visual Studio)'
   pool: Hosted
   steps:
-  - template: powershell.yml
+  - template: bash.yml
     parameters:
       environmentVariables:
         CMAKE_GENERATOR: Visual Studio 12 2013
@@ -106,7 +106,7 @@ jobs:
     env:
       TEMP: $(Agent.TempDirectory)
       ARCH: amd64
-  - template: powershell.yml
+  - template: bash.yml
     parameters:
       environmentVariables:
         BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
@@ -124,7 +124,7 @@ jobs:
     env:
       TEMP: $(Agent.TempDirectory)
       ARCH: x86
-  - template: powershell.yml
+  - template: bash.yml
     parameters:
       environmentVariables:
         BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
diff --git a/azure-pipelines/powershell.yml b/azure-pipelines/powershell.yml
deleted file mode 100644
index 96da4ea..0000000
--- a/azure-pipelines/powershell.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-# These are the steps used for building on machines with PowerShell.
-steps:
-- powershell: . '$(Build.SourcesDirectory)\azure-pipelines\build.ps1'
-  displayName: Build
-  workingDirectory: '$(Build.BinariesDirectory)'
-  env: ${{ parameters.environmentVariables }}
-- powershell: . '$(Build.SourcesDirectory)\azure-pipelines\test.ps1'
-  displayName: Test
-  workingDirectory: '$(Build.BinariesDirectory)'
-  env: ${{ parameters.environmentVariables }}
-- task: PublishTestResults@2
-  displayName: Publish Test Results
-  condition: succeededOrFailed()
-  inputs:
-    testResultsFiles: 'results_*.xml'
-    searchFolder: '$(Build.BinariesDirectory)'
-    mergeTestResults: true
diff --git a/azure-pipelines/test.ps1 b/azure-pipelines/test.ps1
deleted file mode 100644
index 0c9e795..0000000
--- a/azure-pipelines/test.ps1
+++ /dev/null
@@ -1,139 +0,0 @@
-Set-StrictMode -Version Latest
-
-$ErrorActionPreference = "Stop"
-$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
-
-[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
-
-$SourceDir = Split-Path (Split-Path (Get-Variable MyInvocation).Value.MyCommand.Path)
-$BuildDir = Get-Location
-$global:Success = $true
-
-if ($Env:SKIP_TESTS) { exit }
-
-# Ask ctest what it would run if we were to invoke it directly.  This lets
-# us manage the test configuration in a single place (tests/CMakeLists.txt)
-# instead of running clar here as well.  But it allows us to wrap our test
-# harness with a leak checker like valgrind.  Append the option to write
-# JUnit-style XML files.
-function run_test {
-	$TestName = $args[0]
-
-	$TestCommand = (ctest -N -V -R "^$TestName$") -join "`n"
-
-	if (-Not ($TestCommand -match "(?ms).*\n^[0-9]*: Test command: ")) {
-		echo "Could not find tests: $TestName"
-		exit
-	}
-
-	$TestCommand = (ctest -N -V -R "^$TestName$") -join "`n" -replace "(?ms).*\n^[0-9]*: Test command: ","" -replace "\n.*",""
-	$TestCommand += " -r${BuildDir}\results_${TestName}.xml"
-
-	if ($Env:GITTEST_FLAKY_RETRY -gt 0) {
-		$AttemptsRemain = $Env:GITTEST_FLAKY_RETRY
-	} else {
-		$AttemptsRemain = 1
-	}
-
-	$Failed = 0
-	while ($AttemptsRemain -ne 0) {
-		if ($Failed -eq 1) {
-			Write-Host ""
-			Write-Host "Re-running flaky $TestName tests..."
-			Write-Host ""
-		}
-
-		Invoke-Expression $TestCommand
-		if ($LastExitCode -eq 0) {
-			$Failed = 0
-			break
-		} else {
-			$Failed = 1
-		}
-
-		$AttemptsRemain = $AttemptsRemain - 1
-	}
-
-	if ($Failed -eq 1) { $global:Success = $false }
-}
-
-Write-Host "##############################################################################"
-Write-Host "## Configuring test environment"
-Write-Host "##############################################################################"
-
-if (-not $Env:SKIP_PROXY_TESTS) {
-	Invoke-WebRequest -Method GET -Uri https://github.com/ethomson/poxyproxy/releases/download/v0.7.0/poxyproxy-0.7.0.jar -OutFile poxyproxy.jar
-
-	Write-Host ""
-	Write-Host "Starting HTTP proxy (Basic)..."
-	javaw -jar poxyproxy.jar --port 8080 --credentials foo:bar --auth-type basic --quiet
-
-	Write-Host ""
-	Write-Host "Starting HTTP proxy (NTLM)..."
-	javaw -jar poxyproxy.jar --port 8090 --credentials foo:bar --auth-type ntlm --quiet
-}
-
-if (-not $Env:SKIP_OFFLINE_TESTS) {
-	Write-Host ""
-	Write-Host "##############################################################################"
-	Write-Host "## Running (offline) tests"
-	Write-Host "##############################################################################"
-
-	run_test offline
-}
-
-if ($Env:RUN_INVASIVE_TESTS) {
-	Write-Host ""
-	Write-Host "##############################################################################"
-	Write-Host "## Running (invasive) tests"
-	Write-Host "##############################################################################"
-
-	$Env:GITTEST_INVASIVE_FS_SIZE=1
-	$Env:GITTEST_INVASIVE_MEMORY=1
-	$Env:GITTEST_INVASIVE_SPEED=1
-	run_test invasive
-	$Env:GITTEST_INVASIVE_FS_SIZE=$null
-	$Env:GITTEST_INVASIVE_MEMORY=$null
-	$Env:GITTEST_INVASIVE_SPEED=$null
-}
-
-if (-not $Env:SKIP_ONLINE_TESTS) {
-	Write-Host ""
-	Write-Host "##############################################################################"
-	Write-Host "## Running (online) tests"
-	Write-Host "##############################################################################"
-
-	$Env:GITTEST_FLAKY_RETRY=5
-	run_test online
-	$Env:GITTEST_FLAKY_RETRY=0
-}
-
-if (-not $Env:SKIP_PROXY_TESTS) {
-	# Test HTTP Basic authentication
-	Write-Host ""
-	Write-Host "Running proxy tests (Basic authentication)"
-	Write-Host ""
-
-	$Env:GITTEST_REMOTE_PROXY_HOST="localhost:8080"
-	$Env:GITTEST_REMOTE_PROXY_USER="foo"
-	$Env:GITTEST_REMOTE_PROXY_PASS="bar"
-	run_test proxy
-
-	# Test NTLM authentication
-	Write-Host ""
-	Write-Host "Running proxy tests (NTLM authentication)"
-	Write-Host ""
-
-	$Env:GITTEST_REMOTE_PROXY_HOST="localhost:8090"
-	$Env:GITTEST_REMOTE_PROXY_USER="foo"
-	$Env:GITTEST_REMOTE_PROXY_PASS="bar"
-	run_test proxy
-
-	$Env:GITTEST_REMOTE_PROXY_HOST=$null
-	$Env:GITTEST_REMOTE_PROXY_USER=$null
-	$Env:GITTEST_REMOTE_PROXY_PASS=$null
-
-	taskkill /F /IM javaw.exe
-}
-
-if (-Not $global:Success) { exit 1 }