Bläddra i källkod

Merge pull request #39846 from thaJeztah/jenkinsfile_add_windows_1903

Jenkinsfile: add stage for Windows 2022 (SAC)
Sebastiaan van Stijn 4 år sedan
förälder
incheckning
1760f8bb7c
2 ändrade filer med 92 tillägg och 0 borttagningar
  1. 64 0
      Jenkinsfile
  2. 28 0
      pkg/archive/changes_test.go

+ 64 - 0
Jenkinsfile

@@ -18,6 +18,7 @@ pipeline {
         booleanParam(name: 'ppc64le', defaultValue: true, description: 'PowerPC (ppc64le) Build/Test')
         booleanParam(name: 'ppc64le', defaultValue: true, description: 'PowerPC (ppc64le) Build/Test')
         booleanParam(name: 'windowsRS1', defaultValue: false, description: 'Windows 2016 (RS1) Build/Test')
         booleanParam(name: 'windowsRS1', defaultValue: false, description: 'Windows 2016 (RS1) Build/Test')
         booleanParam(name: 'windowsRS5', defaultValue: true, description: 'Windows 2019 (RS5) Build/Test')
         booleanParam(name: 'windowsRS5', defaultValue: true, description: 'Windows 2019 (RS5) Build/Test')
+        booleanParam(name: 'windows2022', defaultValue: true, description: 'Windows 2022 (SAC) Build/Test')
         booleanParam(name: 'dco', defaultValue: true, description: 'Run the DCO check')
         booleanParam(name: 'dco', defaultValue: true, description: 'Run the DCO check')
     }
     }
     environment {
     environment {
@@ -1169,6 +1170,69 @@ pipeline {
                         }
                         }
                     }
                     }
                 }
                 }
+                stage('win-2022') {
+                    when {
+                        beforeAgent true
+                        expression { params.windows2022 }
+                    }
+                    environment {
+                        DOCKER_BUILDKIT        = '0'
+                        DOCKER_DUT_DEBUG       = '1'
+                        SKIP_VALIDATION_TESTS  = '1'
+                        SOURCES_DRIVE          = 'd'
+                        SOURCES_SUBDIR         = 'gopath'
+                        TESTRUN_DRIVE          = 'd'
+                        TESTRUN_SUBDIR         = "CI"
+                        // TODO switch to mcr.microsoft.com/windows/servercore:2022 once published
+                        WINDOWS_BASE_IMAGE     = 'mcr.microsoft.com/windows/servercore/insider'
+                        WINDOWS_BASE_IMAGE_TAG = '10.0.20295.1'
+                    }
+                    agent {
+                        node {
+                            customWorkspace 'd:\\gopath\\src\\github.com\\docker\\docker'
+                            label 'windows-2022'
+                        }
+                    }
+                    stages {
+                        stage("Print info") {
+                            steps {
+                                sh 'docker version'
+                                sh 'docker info'
+                            }
+                        }
+                        stage("Run tests") {
+                            steps {
+                                powershell '''
+                                $ErrorActionPreference = 'Stop'
+                                Invoke-WebRequest https://github.com/moby/docker-ci-zap/blob/master/docker-ci-zap.exe?raw=true -OutFile C:/Windows/System32/docker-ci-zap.exe
+                                ./hack/ci/windows.ps1
+                                exit $LastExitCode
+                                '''
+                            }
+                        }
+                    }
+                    post {
+                        always {
+                            junit testResults: 'bundles/junit-report-*.xml', allowEmptyResults: true
+                            catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.zip') {
+                                powershell '''
+                                cd $env:WORKSPACE
+                                $bundleName="win-2022-integration"
+                                Write-Host -ForegroundColor Green "Creating ${bundleName}-bundles.zip"
+
+                                # archiveArtifacts does not support env-vars to , so save the artifacts in a fixed location
+                                Compress-Archive -Path "bundles/CIDUT.out", "bundles/CIDUT.err", "bundles/junit-report-*.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip"
+                                '''
+
+                                archiveArtifacts artifacts: '*-bundles.zip', allowEmptyArchive: true
+                            }
+                        }
+                        cleanup {
+                            sh 'make clean'
+                            deleteDir()
+                        }
+                    }
+                }
             }
             }
         }
         }
     }
     }

+ 28 - 0
pkg/archive/changes_test.go

@@ -8,10 +8,14 @@ import (
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
 	"sort"
 	"sort"
+	"strconv"
+	"strings"
 	"syscall"
 	"syscall"
 	"testing"
 	"testing"
 	"time"
 	"time"
 
 
+	"github.com/Microsoft/hcsshim/osversion"
+	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
 	"gotest.tools/v3/assert"
 	"gotest.tools/v3/assert"
 	"gotest.tools/v3/skip"
 	"gotest.tools/v3/skip"
@@ -246,6 +250,18 @@ func TestChangesWithChangesGH13590(t *testing.T) {
 
 
 // Create a directory, copy it, make sure we report no changes between the two
 // Create a directory, copy it, make sure we report no changes between the two
 func TestChangesDirsEmpty(t *testing.T) {
 func TestChangesDirsEmpty(t *testing.T) {
+	// Note we parse kernel.GetKernelVersion rather than system.GetOSVersion
+	// as test binaries aren't manifested, so would otherwise report the wrong
+	// build number.
+	if runtime.GOOS == "windows" {
+		v, err := kernel.GetKernelVersion()
+		assert.NilError(t, err)
+		build, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0])
+		if build >= osversion.V19H1 {
+			t.Skip("FIXME: broken on Windows 1903 and up; see #39846")
+		}
+	}
+
 	src, err := ioutil.TempDir("", "docker-changes-test")
 	src, err := ioutil.TempDir("", "docker-changes-test")
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	defer os.RemoveAll(src)
 	defer os.RemoveAll(src)
@@ -328,6 +344,18 @@ func mutateSampleDir(t *testing.T, root string) {
 }
 }
 
 
 func TestChangesDirsMutated(t *testing.T) {
 func TestChangesDirsMutated(t *testing.T) {
+	// Note we parse kernel.GetKernelVersion rather than system.GetOSVersion
+	// as test binaries aren't manifested, so would otherwise report the wrong
+	// build number.
+	if runtime.GOOS == "windows" {
+		v, err := kernel.GetKernelVersion()
+		assert.NilError(t, err)
+		build, _ := strconv.Atoi(strings.Split(strings.SplitN(v.String(), " ", 3)[2][1:], ".")[0])
+		if build >= osversion.V19H1 {
+			t.Skip("FIXME: broken on Windows 1903 and up; see #39846")
+		}
+	}
+
 	src, err := ioutil.TempDir("", "docker-changes-test")
 	src, err := ioutil.TempDir("", "docker-changes-test")
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	createSampleDir(t, src)
 	createSampleDir(t, src)