Dockerfile.windows: fix build of gotestsum

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-05-16 18:41:46 +02:00
parent 1d9da1b233
commit aadc55c605
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
3 changed files with 10 additions and 27 deletions

View File

@ -262,29 +262,16 @@ RUN `
RUN ` RUN `
Function Build-GoTestSum() { ` Function Build-GoTestSum() { `
Write-Host "INFO: Building gotestsum version $Env:GOTESTSUM_COMMIT in $Env:GOPATH"; ` Write-Host "INFO: Building gotestsum version $Env:GOTESTSUM_COMMIT in $Env:GOPATH"; `
$optsForGet = @('"get"', '"-d"', '"gotest.tools/gotestsum"'); ` $env:GO111MODULE = 'on'; `
&go $optsForGet; ` &go get -d "gotest.tools/gotestsum@${Env:GOTESTSUM_COMMIT}"; `
$savedExitCode = $LASTEXITCODE; ` $env:GO111MODULE = 'off'; `
if ($savedExitCode -ne 0) { ` if ($LASTEXITCODE -ne 0) { `
Throw '"Failed getting gotestsum sources..."' ` Throw '"Failed getting gotestsum sources..."' `
}; ` }; `
Write-Host "INFO: Sources obtained for gotestsum..."; ` $env:GO111MODULE = 'on'; `
$GotestsumPath=Join-Path -Path $Env:GOPATH -ChildPath "src\gotest.tools\gotestsum"; ` &go build -buildmode=exe -o "${Env:GOPATH}\bin\gotestsum.exe" gotest.tools/gotestsum; `
Push-Location $GotestsumPath; ` $env:GO111MODULE = 'off'; `
$optsForCheckout = @('"checkout"', '"-q"', """$Env:GOTESTSUM_COMMIT"""); ` if ($LASTEXITCODE -ne 0) { `
&git $optsForCheckout; `
$savedExitCode = $LASTEXITCODE; `
if ($savedExitCode -eq 0) { `
Write-Host "INFO: Checkout done for gotestsum..."; `
$optsForBuild = @('"build"', '"-buildmode=exe"'); `
&go $optsForBuild; `
$savedExitCode = $LASTEXITCODE; `
} else { `
Throw '"gotestsum checkout failed..."'; `
} `
Pop-Location; `
`
if ($savedExitCode -ne 0) { `
Throw '"gotestsum build failed..."'; ` Throw '"gotestsum build failed..."'; `
} ` } `
Write-Host "INFO: Build done for gotestsum..."; ` Write-Host "INFO: Build done for gotestsum..."; `

View File

@ -528,11 +528,7 @@ Try {
Throw "ERROR: Failed to docker cp the daemon binary (dockerd.exe) to $env:TEMP\binary" Throw "ERROR: Failed to docker cp the daemon binary (dockerd.exe) to $env:TEMP\binary"
} }
$GotestsumBinRelLocationInContainer="src\gotest.tools\gotestsum\gotestsum.exe" docker cp "$COMMITHASH`:c`:\gopath\bin\gotestsum.exe" $env:TEMP\binary\
if (-not($LastExitCode -eq 0)) {
Throw "ERROR: Failed to docker cp the gotestsum binary (gotestsum.exe) to $env:TEMP\binary"
}
docker cp "$COMMITHASH`:c`:\gopath\$GotestsumBinRelLocationInContainer" $env:TEMP\binary\
if (-not (Test-Path "$env:TEMP\binary\gotestsum.exe")) { if (-not (Test-Path "$env:TEMP\binary\gotestsum.exe")) {
Throw "ERROR: gotestsum.exe not found...." ` Throw "ERROR: gotestsum.exe not found...." `
} }

View File

@ -94,7 +94,7 @@ param(
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue" $ProgressPreference = "SilentlyContinue"
$pushed=$False # To restore the directory if we have temporarily pushed to one. $pushed=$False # To restore the directory if we have temporarily pushed to one.
Set-Variable GOTESTSUM_LOCATION -option Constant -value "$env:GOPATH/src/gotest.tools/gotestsum" Set-Variable GOTESTSUM_LOCATION -option Constant -value "$env:GOPATH/bin/"
# Utility function to get the commit ID of the repository # Utility function to get the commit ID of the repository
Function Get-GitCommit() { Function Get-GitCommit() {