This check was used to make sure we don't bump Go versions independently
(Linux/Windows). The Dockerfile switched to using a build-arg to allow
overriding the Go version, which rendered this check non-functional.
It also fails if Linux versions use a specific variant of the image;
08:41:31 ERROR: Failed 'ERROR: Mismatched GO versions between Dockerfile and Dockerfile.windows. Update your PR to ensure that both files are updated and in sync. ${GO_VERSION}-stretch ${GO_VERSION}' at 07/20/2019 08:41:31
08:41:31 At C:\gopath\src\github.com\docker\docker\hack\ci\windows.ps1:448 char:9
08:41:31 + Throw "ERROR: Mismatched GO versions between Dockerfile and D ...
08:41:31 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This patch fixes the check by looking for the value of `GO_VERSION` instead
of looking at the `FROM` line (which is harder to parse).
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 4fa57a8191b1d23c6466725b688519f83c0ac5dd)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -426,20 +426,9 @@ Try {
|
| 426 | 426 |
Write-Host -ForegroundColor Green "INFO: Location for testing is $env:TEMP" |
| 427 | 427 |
|
| 428 | 428 |
# CI Integrity check - ensure Dockerfile.windows and Dockerfile go versions match |
| 429 |
- $goVersionDockerfileWindows=$(Get-Content ".\Dockerfile.windows" | Select-String "^ENV GO_VERSION" | Select-object -First 1).ToString().Replace("ENV GO_VERSION=","").Replace("\","").Replace("``","").Trim()
|
|
| 430 |
- $goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^ENV GO_VERSION" | Select-object -First 1) |
|
| 431 |
- |
|
| 432 |
- # As of go 1.11, Dockerfile changed to be in the format like "FROM golang:1.11.0 AS base". |
|
| 433 |
- # If a version number ends with .0 (as in 1.11.0, a convention used in golang docker |
|
| 434 |
- # image versions), it needs to be removed (i.e. "1.11.0" becomes "1.11"). |
|
| 435 |
- if ($null -eq $goVersionDockerfile) {
|
|
| 436 |
- $goVersionDockerfile=$(Get-Content ".\Dockerfile" | Select-String "^FROM golang:" | Select-object -First 1) |
|
| 437 |
- if ($null -ne $goVersionDockerfile) {
|
|
| 438 |
- $goVersionDockerfile = $goVersionDockerfile.ToString().Split(" ")[1].Split(":")[1] -replace '\.0$',''
|
|
| 439 |
- } |
|
| 440 |
- } else {
|
|
| 441 |
- $goVersionDockerfile = $goVersionDockerfile.ToString().Split(" ")[2]
|
|
| 442 |
- } |
|
| 429 |
+ $goVersionDockerfileWindows=(Select-String -Path ".\Dockerfile.windows" -Pattern "^ARG[\s]+GO_VERSION=(.*)$").Matches.groups[1].Value |
|
| 430 |
+ $goVersionDockerfile=(Select-String -Path ".\Dockerfile" -Pattern "^ARG[\s]+GO_VERSION=(.*)$").Matches.groups[1].Value |
|
| 431 |
+ |
|
| 443 | 432 |
if ($null -eq $goVersionDockerfile) {
|
| 444 | 433 |
Throw "ERROR: Failed to extract golang version from Dockerfile" |
| 445 | 434 |
} |
| ... | ... |
@@ -134,7 +134,7 @@ Function Check-InContainer() {
|
| 134 | 134 |
# outside of a container where it may be out of date with master. |
| 135 | 135 |
Function Verify-GoVersion() {
|
| 136 | 136 |
Try {
|
| 137 |
- $goVersionDockerfile=(Select-String -Path ".\Dockerfile" -Pattern "^FROM golang:").ToString().Split(" ")[1].SubString(7) -replace '\.0$',''
|
|
| 137 |
+ $goVersionDockerfile=(Select-String -Path ".\Dockerfile" -Pattern "^ARG[\s]+GO_VERSION=(.*)$").Matches.groups[1].Value.TrimEnd(".0")
|
|
| 138 | 138 |
$goVersionInstalled=(go version).ToString().Split(" ")[2].SubString(2)
|
| 139 | 139 |
} |
| 140 | 140 |
Catch [Exception] {
|