Skip to content

Commit

Permalink
Merge pull request moby#40979 from thaJeztah/fix_gotestsum_install
Browse files Browse the repository at this point in the history
Fix bug in gotestsum installer causing dependencies to not be downloaded
  • Loading branch information
tiborvass committed May 17, 2020
2 parents dd16f2f + aadc55c commit 327a0b4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
29 changes: 8 additions & 21 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -262,29 +262,16 @@ RUN `
RUN `
Function Build-GoTestSum() { `
Write-Host "INFO: Building gotestsum version $Env:GOTESTSUM_COMMIT in $Env:GOPATH"; `
$optsForGet = @('"get"', '"-d"', '"gotest.tools/gotestsum"'); `
&go $optsForGet; `
$savedExitCode = $LASTEXITCODE; `
if ($savedExitCode -ne 0) { `
$env:GO111MODULE = 'on'; `
&go get -d "gotest.tools/gotestsum@${Env:GOTESTSUM_COMMIT}"; `
$env:GO111MODULE = 'off'; `
if ($LASTEXITCODE -ne 0) { `
Throw '"Failed getting gotestsum sources..."' `
}; `
Write-Host "INFO: Sources obtained for gotestsum..."; `
$GotestsumPath=Join-Path -Path $Env:GOPATH -ChildPath "src\gotest.tools\gotestsum"; `
Push-Location $GotestsumPath; `
$optsForCheckout = @('"checkout"', '"-q"', """$Env:GOTESTSUM_COMMIT"""); `
&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) { `
$env:GO111MODULE = 'on'; `
&go build -buildmode=exe -o "${Env:GOPATH}\bin\gotestsum.exe" gotest.tools/gotestsum; `
$env:GO111MODULE = 'off'; `
if ($LASTEXITCODE -ne 0) { `
Throw '"gotestsum build failed..."'; `
} `
Write-Host "INFO: Build done for gotestsum..."; `
Expand Down
6 changes: 1 addition & 5 deletions hack/ci/windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,7 @@ Try {
Throw "ERROR: Failed to docker cp the daemon binary (dockerd.exe) to $env:TEMP\binary"
}

$GotestsumBinRelLocationInContainer="src\gotest.tools\gotestsum\gotestsum.exe"
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\
docker cp "$COMMITHASH`:c`:\gopath\bin\gotestsum.exe" $env:TEMP\binary\
if (-not (Test-Path "$env:TEMP\binary\gotestsum.exe")) {
Throw "ERROR: gotestsum.exe not found...." `
}
Expand Down
12 changes: 6 additions & 6 deletions hack/dockerfile/install/gotestsum.installer
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

: ${GOTESTSUM_COMMIT:=v0.3.5}

install_gotestsum() {
echo "Installing gotestsum version $GOTESTSUM_COMMIT"
go get -d gotest.tools/gotestsum
cd "$GOPATH/src/gotest.tools/gotestsum"
git checkout -q "$GOTESTSUM_COMMIT"
install_gotestsum() (
set -e
export GO111MODULE=on
go get -d "gotest.tools/gotestsum@${GOTESTSUM_COMMIT}"
go build -buildmode=pie -o "${PREFIX}/gotestsum" 'gotest.tools/gotestsum'
}

)
2 changes: 1 addition & 1 deletion hack/make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ param(
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
$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
Function Get-GitCommit() {
Expand Down

0 comments on commit 327a0b4

Please sign in to comment.