make.ps1 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <#
  2. .NOTES
  3. Author: @jhowardmsft
  4. Summary: Windows native build script. This is similar to functionality provided
  5. by hack\make.sh, but uses native Windows PowerShell semantics. It does
  6. not support the full set of options provided by the Linux counterpart.
  7. For example:
  8. - You can't cross-build Linux docker binaries on Windows
  9. - Hashes aren't generated on binaries
  10. - 'Releasing' isn't supported.
  11. - Integration tests. This is because they currently cannot run inside a container,
  12. and require significant external setup.
  13. It does however provided the minimum necessary to support parts of local Windows
  14. development and Windows to Windows CI.
  15. Usage Examples (run from repo root):
  16. "hack\make.ps1 -Client" to build docker.exe client 64-bit binary (remote repo)
  17. "hack\make.ps1 -TestUnit" to run unit tests
  18. "hack\make.ps1 -Daemon -TestUnit" to build the daemon and run unit tests
  19. "hack\make.ps1 -All" to run everything this script knows about that can run in a container
  20. "hack\make.ps1" to build the daemon binary (same as -Daemon)
  21. "hack\make.ps1 -Binary" shortcut to -Client and -Daemon
  22. .PARAMETER Client
  23. Builds the client binaries.
  24. .PARAMETER Daemon
  25. Builds the daemon binary.
  26. .PARAMETER Binary
  27. Builds the client and daemon binaries. A convenient shortcut to `make.ps1 -Client -Daemon`.
  28. .PARAMETER Race
  29. Use -race in go build and go test.
  30. .PARAMETER Noisy
  31. Use -v in go build.
  32. .PARAMETER ForceBuildAll
  33. Use -a in go build.
  34. .PARAMETER NoOpt
  35. Use -gcflags -N -l in go build to disable optimisation (can aide debugging).
  36. .PARAMETER CommitSuffix
  37. Adds a custom string to be appended to the commit ID (spaces are stripped).
  38. .PARAMETER DCO
  39. Runs the DCO (Developer Certificate Of Origin) test (must be run outside a container).
  40. .PARAMETER PkgImports
  41. Runs the pkg\ directory imports test (must be run outside a container).
  42. .PARAMETER GoFormat
  43. Runs the Go formatting test (must be run outside a container).
  44. .PARAMETER TestUnit
  45. Runs unit tests.
  46. .PARAMETER TestIntegration
  47. Runs integration tests.
  48. .PARAMETER All
  49. Runs everything this script knows about that can run in a container.
  50. TODO
  51. - Unify the head commit
  52. - Add golint and other checks (swagger maybe?)
  53. #>
  54. param(
  55. [Parameter(Mandatory=$False)][switch]$Client,
  56. [Parameter(Mandatory=$False)][switch]$Daemon,
  57. [Parameter(Mandatory=$False)][switch]$Binary,
  58. [Parameter(Mandatory=$False)][switch]$Race,
  59. [Parameter(Mandatory=$False)][switch]$Noisy,
  60. [Parameter(Mandatory=$False)][switch]$ForceBuildAll,
  61. [Parameter(Mandatory=$False)][switch]$NoOpt,
  62. [Parameter(Mandatory=$False)][string]$CommitSuffix="",
  63. [Parameter(Mandatory=$False)][switch]$DCO,
  64. [Parameter(Mandatory=$False)][switch]$PkgImports,
  65. [Parameter(Mandatory=$False)][switch]$GoFormat,
  66. [Parameter(Mandatory=$False)][switch]$TestUnit,
  67. [Parameter(Mandatory=$False)][switch]$TestIntegration,
  68. [Parameter(Mandatory=$False)][switch]$All
  69. )
  70. $ErrorActionPreference = "Stop"
  71. $ProgressPreference = "SilentlyContinue"
  72. $pushed=$False # To restore the directory if we have temporarily pushed to one.
  73. Set-Variable GOTESTSUM_LOCATION -option Constant -value "$env:GOPATH/bin/"
  74. # Utility function to get the commit ID of the repository
  75. Function Get-GitCommit() {
  76. if (-not (Test-Path ".\.git")) {
  77. # If we don't have a .git directory, but we do have the environment
  78. # variable DOCKER_GITCOMMIT set, that can override it.
  79. if ($env:DOCKER_GITCOMMIT.Length -eq 0) {
  80. Throw ".git directory missing and DOCKER_GITCOMMIT environment variable not specified."
  81. }
  82. Write-Host "INFO: Git commit ($env:DOCKER_GITCOMMIT) assumed from DOCKER_GITCOMMIT environment variable"
  83. return $env:DOCKER_GITCOMMIT
  84. }
  85. $gitCommit=$(git rev-parse --short HEAD)
  86. if ($(git status --porcelain --untracked-files=no).Length -ne 0) {
  87. $gitCommit="$gitCommit-unsupported"
  88. Write-Host ""
  89. Write-Warning "This version is unsupported because there are uncommitted file(s)."
  90. Write-Warning "Either commit these changes, or add them to .gitignore."
  91. git status --porcelain --untracked-files=no | Write-Warning
  92. Write-Host ""
  93. }
  94. return $gitCommit
  95. }
  96. # Utility function to determine if we are running in a container or not.
  97. # In Windows, we get this through an environment variable set in `Dockerfile.Windows`
  98. Function Check-InContainer() {
  99. if ($env:FROM_DOCKERFILE.Length -eq 0) {
  100. Write-Host ""
  101. Write-Warning "Not running in a container. The result might be an incorrect build."
  102. Write-Host ""
  103. return $False
  104. }
  105. return $True
  106. }
  107. # Utility function to warn if the version of go is correct. Used for local builds
  108. # outside of a container where it may be out of date with master.
  109. Function Verify-GoVersion() {
  110. Try {
  111. $goVersionDockerfile=(Select-String -Path ".\Dockerfile" -Pattern "^ARG[\s]+GO_VERSION=(.*)$").Matches.groups[1].Value -replace '\.0$',''
  112. $goVersionInstalled=(go version).ToString().Split(" ")[2].SubString(2)
  113. }
  114. Catch [Exception] {
  115. Throw "Failed to validate go version correctness: $_"
  116. }
  117. if (-not($goVersionInstalled -eq $goVersionDockerfile)) {
  118. Write-Host ""
  119. Write-Warning "Building with golang version $goVersionInstalled. You should update to $goVersionDockerfile"
  120. Write-Host ""
  121. }
  122. }
  123. # Utility function to get the commit for HEAD
  124. Function Get-HeadCommit() {
  125. $head = Invoke-Expression "git rev-parse --verify HEAD"
  126. if ($LASTEXITCODE -ne 0) { Throw "Failed getting HEAD commit" }
  127. return $head
  128. }
  129. # Utility function to get the commit for upstream
  130. Function Get-UpstreamCommit() {
  131. Invoke-Expression "git fetch -q https://github.com/docker/docker.git refs/heads/master"
  132. if ($LASTEXITCODE -ne 0) { Throw "Failed fetching" }
  133. $upstream = Invoke-Expression "git rev-parse --verify FETCH_HEAD"
  134. if ($LASTEXITCODE -ne 0) { Throw "Failed getting upstream commit" }
  135. return $upstream
  136. }
  137. # Build a binary (client or daemon)
  138. Function Execute-Build($type, $additionalBuildTags, $directory) {
  139. # Generate the build flags
  140. $buildTags = "autogen"
  141. if ($Noisy) { $verboseParm=" -v" }
  142. if ($Race) { Write-Warning "Using race detector"; $raceParm=" -race"}
  143. if ($ForceBuildAll) { $allParm=" -a" }
  144. if ($NoOpt) { $optParm=" -gcflags "+""""+"-N -l"+"""" }
  145. if ($additionalBuildTags -ne "") { $buildTags += $(" " + $additionalBuildTags) }
  146. # Do the go build in the appropriate directory
  147. # Note -linkmode=internal is required to be able to debug on Windows.
  148. # https://github.com/golang/go/issues/14319#issuecomment-189576638
  149. Write-Host "INFO: Building $type..."
  150. Push-Location $root\cmd\$directory; $global:pushed=$True
  151. $buildCommand = "go build" + `
  152. $raceParm + `
  153. $verboseParm + `
  154. $allParm + `
  155. $optParm + `
  156. " -tags """ + $buildTags + """" + `
  157. " -ldflags """ + "-linkmode=internal" + """" + `
  158. " -o $root\bundles\"+$directory+".exe"
  159. Invoke-Expression $buildCommand
  160. if ($LASTEXITCODE -ne 0) { Throw "Failed to compile $type" }
  161. Pop-Location; $global:pushed=$False
  162. }
  163. # Validates the DCO marker is present on each commit
  164. Function Validate-DCO($headCommit, $upstreamCommit) {
  165. Write-Host "INFO: Validating Developer Certificate of Origin..."
  166. # Username may only contain alphanumeric characters or dashes and cannot begin with a dash
  167. $usernameRegex='[a-zA-Z0-9][a-zA-Z0-9-]+'
  168. $dcoPrefix="Signed-off-by:"
  169. $dcoRegex="^(Docker-DCO-1.1-)?$dcoPrefix ([^<]+) <([^<>@]+@[^<>]+)>( \(github: ($usernameRegex)\))?$"
  170. $counts = Invoke-Expression "git diff --numstat $upstreamCommit...$headCommit"
  171. if ($LASTEXITCODE -ne 0) { Throw "Failed git diff --numstat" }
  172. # Counts of adds and deletes after removing multiple white spaces. AWK anyone? :(
  173. $adds=0; $dels=0; $($counts -replace '\s+', ' ') | %{
  174. $a=$_.Split(" ");
  175. if ($a[0] -ne "-") { $adds+=[int]$a[0] }
  176. if ($a[1] -ne "-") { $dels+=[int]$a[1] }
  177. }
  178. if (($adds -eq 0) -and ($dels -eq 0)) {
  179. Write-Warning "DCO validation - nothing to validate!"
  180. return
  181. }
  182. $commits = Invoke-Expression "git log $upstreamCommit..$headCommit --format=format:%H%n"
  183. if ($LASTEXITCODE -ne 0) { Throw "Failed git log --format" }
  184. $commits = $($commits -split '\s+' -match '\S')
  185. $badCommits=@()
  186. $commits | ForEach-Object{
  187. # Skip commits with no content such as merge commits etc
  188. if ($(git log -1 --format=format: --name-status $_).Length -gt 0) {
  189. # Ignore exit code on next call - always process regardless
  190. $commitMessage = Invoke-Expression "git log -1 --format=format:%B --name-status $_"
  191. if (($commitMessage -match $dcoRegex).Length -eq 0) { $badCommits+=$_ }
  192. }
  193. }
  194. if ($badCommits.Length -eq 0) {
  195. Write-Host "Congratulations! All commits are properly signed with the DCO!"
  196. } else {
  197. $e = "`nThese commits do not have a proper '$dcoPrefix' marker:`n"
  198. $badCommits | %{ $e+=" - $_`n"}
  199. $e += "`nPlease amend each commit to include a properly formatted DCO marker.`n`n"
  200. $e += "Visit the following URL for information about the Docker DCO:`n"
  201. $e += "https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work`n"
  202. Throw $e
  203. }
  204. }
  205. # Validates that .\pkg\... is safely isolated from internal code
  206. Function Validate-PkgImports($headCommit, $upstreamCommit) {
  207. Write-Host "INFO: Validating pkg import isolation..."
  208. # Get a list of go source-code files which have changed under pkg\. Ignore exit code on next call - always process regardless
  209. $files=@(); $files = Invoke-Expression "git diff $upstreamCommit...$headCommit --diff-filter=ACMR --name-only -- `'pkg\*.go`'"
  210. $badFiles=@(); $files | ForEach-Object{
  211. $file=$_
  212. # For the current changed file, get its list of dependencies, sorted and uniqued.
  213. $imports = Invoke-Expression "go list -e -f `'{{ .Deps }}`' $file"
  214. if ($LASTEXITCODE -ne 0) { Throw "Failed go list for dependencies on $file" }
  215. $imports = $imports -Replace "\[" -Replace "\]", "" -Split(" ") | Sort-Object | Get-Unique
  216. # Filter out what we are looking for
  217. $imports = @() + $imports -NotMatch "^github.com/docker/docker/pkg/" `
  218. -NotMatch "^github.com/docker/docker/vendor" `
  219. -Match "^github.com/docker/docker" `
  220. -Replace "`n", ""
  221. $imports | ForEach-Object{ $badFiles+="$file imports $_`n" }
  222. }
  223. if ($badFiles.Length -eq 0) {
  224. Write-Host 'Congratulations! ".\pkg\*.go" is safely isolated from internal code.'
  225. } else {
  226. $e = "`nThese files import internal code: (either directly or indirectly)`n"
  227. $badFiles | ForEach-Object{ $e+=" - $_"}
  228. Throw $e
  229. }
  230. }
  231. # Validates that changed files are correctly go-formatted
  232. Function Validate-GoFormat($headCommit, $upstreamCommit) {
  233. Write-Host "INFO: Validating go formatting on changed files..."
  234. # Verify gofmt is installed
  235. if ($(Get-Command gofmt -ErrorAction SilentlyContinue) -eq $nil) { Throw "gofmt does not appear to be installed" }
  236. # Get a list of all go source-code files which have changed. Ignore exit code on next call - always process regardless
  237. $files=@(); $files = Invoke-Expression "git diff $upstreamCommit...$headCommit --diff-filter=ACMR --name-only -- `'*.go`'"
  238. $files = $files | Select-String -NotMatch "^vendor/"
  239. $badFiles=@(); $files | %{
  240. # Deliberately ignore error on next line - treat as failed
  241. $content=Invoke-Expression "git show $headCommit`:$_"
  242. # Next set of hoops are to ensure we have LF not CRLF semantics as otherwise gofmt on Windows will not succeed.
  243. # Also note that gofmt on Windows does not appear to support stdin piping correctly. Hence go through a temporary file.
  244. $content=$content -join "`n"
  245. $content+="`n"
  246. $outputFile=[System.IO.Path]::GetTempFileName()
  247. if (Test-Path $outputFile) { Remove-Item $outputFile }
  248. [System.IO.File]::WriteAllText($outputFile, $content, (New-Object System.Text.UTF8Encoding($False)))
  249. $currentFile = $_ -Replace("/","\")
  250. Write-Host Checking $currentFile
  251. Invoke-Expression "gofmt -s -l $outputFile"
  252. if ($LASTEXITCODE -ne 0) { $badFiles+=$currentFile }
  253. if (Test-Path $outputFile) { Remove-Item $outputFile }
  254. }
  255. if ($badFiles.Length -eq 0) {
  256. Write-Host 'Congratulations! All Go source files are properly formatted.'
  257. } else {
  258. $e = "`nThese files are not properly gofmt`'d:`n"
  259. $badFiles | ForEach-Object{ $e+=" - $_`n"}
  260. $e+= "`nPlease reformat the above files using `"gofmt -s -w`" and commit the result."
  261. Throw $e
  262. }
  263. }
  264. # Run the unit tests
  265. Function Run-UnitTests() {
  266. Write-Host "INFO: Running unit tests..."
  267. $testPath="./..."
  268. $goListCommand = "go list -e -f '{{if ne .Name """ + '\"github.com/docker/docker\"' + """}}{{.ImportPath}}{{end}}' $testPath"
  269. $pkgList = $(Invoke-Expression $goListCommand)
  270. if ($LASTEXITCODE -ne 0) { Throw "go list for unit tests failed" }
  271. $pkgList = $pkgList | Select-String -Pattern "github.com/docker/docker"
  272. $pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/vendor"
  273. $pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/man"
  274. $pkgList = $pkgList | Select-String -NotMatch "github.com/docker/docker/integration"
  275. $pkgList = $pkgList -replace "`r`n", " "
  276. $goTestArg = "--format=standard-verbose --jsonfile=bundles\go-test-report-unit-tests.json --junitfile=bundles\junit-report-unit-tests.xml -- " + $raceParm + " -cover -ldflags -w -a """ + "-test.timeout=10m" + """ $pkgList"
  277. Write-Host "INFO: Invoking unit tests run with $GOTESTSUM_LOCATION\gotestsum.exe $goTestArg"
  278. $pinfo = New-Object System.Diagnostics.ProcessStartInfo
  279. $pinfo.FileName = "$GOTESTSUM_LOCATION\gotestsum.exe"
  280. $pinfo.WorkingDirectory = "$($PWD.Path)"
  281. $pinfo.UseShellExecute = $false
  282. $pinfo.Arguments = $goTestArg
  283. $p = New-Object System.Diagnostics.Process
  284. $p.StartInfo = $pinfo
  285. $p.Start() | Out-Null
  286. $p.WaitForExit()
  287. if ($p.ExitCode -ne 0) { Throw "Unit tests failed" }
  288. }
  289. # Run the integration tests
  290. Function Run-IntegrationTests() {
  291. $escRoot = [Regex]::Escape($root)
  292. $env:DOCKER_INTEGRATION_DAEMON_DEST = $bundlesDir + "\tmp"
  293. $dirs = go list -test -f '{{- if ne .ForTest `"`" -}}{{- .Dir -}}{{- end -}}' .\integration\...
  294. ForEach($dir in $dirs) {
  295. # Normalize directory name for using in the test results files.
  296. $normDir = $dir.Trim()
  297. $normDir = $normDir -replace $escRoot, ""
  298. $normDir = $normDir -replace "\\", "-"
  299. $normDir = $normDir -replace "\/", "-"
  300. $normDir = $normDir -replace "\.", "-"
  301. if ($normDir.StartsWith("-"))
  302. {
  303. $normDir = $normDir.TrimStart("-")
  304. }
  305. if ($normDir.EndsWith("-"))
  306. {
  307. $normDir = $normDir.TrimEnd("-")
  308. }
  309. $jsonFilePath = $bundlesDir + "\go-test-report-int-tests-$normDir" + ".json"
  310. $xmlFilePath = $bundlesDir + "\junit-report-int-tests-$normDir" + ".xml"
  311. Set-Location $dir
  312. Write-Host "Running $($PWD.Path)"
  313. $pinfo = New-Object System.Diagnostics.ProcessStartInfo
  314. $pinfo.FileName = "gotestsum.exe"
  315. $pinfo.WorkingDirectory = "$($PWD.Path)"
  316. $pinfo.UseShellExecute = $false
  317. $pinfo.Arguments = "--format=standard-verbose --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- -test.timeout=60m $env:INTEGRATION_TESTFLAGS"
  318. $p = New-Object System.Diagnostics.Process
  319. $p.StartInfo = $pinfo
  320. $p.Start() | Out-Null
  321. $p.WaitForExit()
  322. if ($p.ExitCode -ne 0) { Throw "Integration tests failed" }
  323. }
  324. }
  325. # Start of main code.
  326. Try {
  327. Write-Host -ForegroundColor Cyan "INFO: make.ps1 starting at $(Get-Date)"
  328. # Get to the root of the repo
  329. $root = $(Split-Path $MyInvocation.MyCommand.Definition -Parent | Split-Path -Parent)
  330. Push-Location $root
  331. # Ensure the bundles directory exists
  332. $bundlesDir = $root + "\bundles"
  333. Set-Variable bundlesDir -option ReadOnly
  334. New-Item -Force $bundlesDir -ItemType Directory | Out-Null
  335. # Handle the "-All" shortcut to turn on all things we can handle.
  336. # Note we expressly only include the items which can run in a container - the validations tests cannot
  337. # as they require the .git directory which is excluded from the image by .dockerignore
  338. if ($All) { $Client=$True; $Daemon=$True; $TestUnit=$True; }
  339. # Handle the "-Binary" shortcut to build both client and daemon.
  340. if ($Binary) { $Client = $True; $Daemon = $True }
  341. # Default to building the daemon if not asked for anything explicitly.
  342. if (-not($Client) -and -not($Daemon) -and -not($DCO) -and -not($PkgImports) -and -not($GoFormat) -and -not($TestUnit) -and -not($TestIntegration)) { $Daemon=$True }
  343. # Verify git is installed
  344. if ($(Get-Command git -ErrorAction SilentlyContinue) -eq $nil) { Throw "Git does not appear to be installed" }
  345. # Verify go is installed
  346. if ($(Get-Command go -ErrorAction SilentlyContinue) -eq $nil) { Throw "GoLang does not appear to be installed" }
  347. # Get the git commit. This will also verify if we are in a repo or not. Then add a custom string if supplied.
  348. $gitCommit=Get-GitCommit
  349. if ($CommitSuffix -ne "") { $gitCommit += "-"+$CommitSuffix -Replace ' ', '' }
  350. # Get the version of docker (eg 17.04.0-dev)
  351. $dockerVersion="0.0.0-dev"
  352. # Overwrite dockerVersion if VERSION Environment variable is available
  353. if (Test-Path Env:\VERSION) { $dockerVersion=$env:VERSION }
  354. # Give a warning if we are not running in a container and are building binaries or running unit tests.
  355. # Not relevant for validation tests as these are fine to run outside of a container.
  356. if ($Client -or $Daemon -or $TestUnit) { $inContainer=Check-InContainer }
  357. # If we are not in a container, validate the version of GO that is installed.
  358. if (-not $inContainer) { Verify-GoVersion }
  359. # Verify GOPATH is set
  360. if ($env:GOPATH.Length -eq 0) { Throw "Missing GOPATH environment variable. See https://golang.org/doc/code.html#GOPATH" }
  361. # Run autogen if building binaries or running unit tests.
  362. if ($Client -or $Daemon -or $TestUnit) {
  363. Write-Host "INFO: Invoking autogen..."
  364. Try { .\hack\make\.go-autogen.ps1 -CommitString $gitCommit -DockerVersion $dockerVersion -Platform "$env:PLATFORM" -Product "$env:PRODUCT" }
  365. Catch [Exception] { Throw $_ }
  366. }
  367. # DCO, Package import and Go formatting tests.
  368. if ($DCO -or $PkgImports -or $GoFormat) {
  369. # We need the head and upstream commits for these
  370. $headCommit=Get-HeadCommit
  371. $upstreamCommit=Get-UpstreamCommit
  372. # Run DCO validation
  373. if ($DCO) { Validate-DCO $headCommit $upstreamCommit }
  374. # Run `gofmt` validation
  375. if ($GoFormat) { Validate-GoFormat $headCommit $upstreamCommit }
  376. # Run pkg isolation validation
  377. if ($PkgImports) { Validate-PkgImports $headCommit $upstreamCommit }
  378. }
  379. # Build the binaries
  380. if ($Client -or $Daemon) {
  381. # Perform the actual build
  382. if ($Daemon) { Execute-Build "daemon" "daemon" "dockerd" }
  383. if ($Client) {
  384. # Get the Docker channel and version from the environment, or use the defaults.
  385. if (-not ($channel = $env:DOCKERCLI_CHANNEL)) { $channel = "stable" }
  386. if (-not ($version = $env:DOCKERCLI_VERSION)) { $version = "17.06.2-ce" }
  387. # Download the zip file and extract the client executable.
  388. Write-Host "INFO: Downloading docker/cli version $version from $channel..."
  389. $url = "https://download.docker.com/win/static/$channel/x86_64/docker-$version.zip"
  390. Invoke-WebRequest $url -OutFile "docker.zip"
  391. Try {
  392. Add-Type -AssemblyName System.IO.Compression.FileSystem
  393. $zip = [System.IO.Compression.ZipFile]::OpenRead("$PWD\docker.zip")
  394. Try {
  395. if (-not ($entry = $zip.Entries | Where-Object { $_.Name -eq "docker.exe" })) {
  396. Throw "Cannot find docker.exe in $url"
  397. }
  398. [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, "$PWD\bundles\docker.exe", $true)
  399. }
  400. Finally {
  401. $zip.Dispose()
  402. }
  403. }
  404. Finally {
  405. Remove-Item -Force "docker.zip"
  406. }
  407. }
  408. }
  409. # Run unit tests
  410. if ($TestUnit) { Run-UnitTests }
  411. # Run integration tests
  412. if ($TestIntegration) { Run-IntegrationTests }
  413. # Gratuitous ASCII art.
  414. if ($Daemon -or $Client) {
  415. Write-Host
  416. Write-Host -ForegroundColor Green " ________ ____ __."
  417. Write-Host -ForegroundColor Green " \_____ \ `| `|/ _`|"
  418. Write-Host -ForegroundColor Green " / `| \`| `<"
  419. Write-Host -ForegroundColor Green " / `| \ `| \"
  420. Write-Host -ForegroundColor Green " \_______ /____`|__ \"
  421. Write-Host -ForegroundColor Green " \/ \/"
  422. Write-Host
  423. }
  424. }
  425. Catch [Exception] {
  426. Write-Host -ForegroundColor Red ("`nERROR: make.ps1 failed:`n$_")
  427. Write-Host -ForegroundColor Red ($_.InvocationInfo.PositionMessage)
  428. # More gratuitous ASCII art.
  429. Write-Host
  430. Write-Host -ForegroundColor Red "___________ .__.__ .___"
  431. Write-Host -ForegroundColor Red "\_ _____/____ `|__`| `| ____ __`| _/"
  432. Write-Host -ForegroundColor Red " `| __) \__ \ `| `| `| _/ __ \ / __ `| "
  433. Write-Host -ForegroundColor Red " `| \ / __ \`| `| `|_\ ___// /_/ `| "
  434. Write-Host -ForegroundColor Red " \___ / (____ /__`|____/\___ `>____ `| "
  435. Write-Host -ForegroundColor Red " \/ \/ \/ \/ "
  436. Write-Host
  437. exit 1
  438. }
  439. Finally {
  440. Pop-Location # As we pushed to the root of the repo as the very first thing
  441. if ($global:pushed) { Pop-Location }
  442. Write-Host -ForegroundColor Cyan "INFO: make.ps1 ended at $(Get-Date)"
  443. }