diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 249b4b1896..46647cf26a 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -1,7 +1,7 @@ name: Basic e2e test on: - pull_request: + pull_request: branches: ['main'] jobs: @@ -35,9 +35,8 @@ jobs: export PLATFORM=${GOOS}/${GOARCH} if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then - # Always use the nanoserver base image, which matches the Windows - # version used by the GitHub Actions Windows runner. - rm .ko.yaml + OSVERSION="10.0.17763.2366" + PLATFORM=${PLATFORM}:${OSVERSION} export KO_DEFAULTBASEIMAGE=mcr.microsoft.com/windows/nanoserver:1809 else # Explicitly test multiple platform builds (a subset of what's in the base!) diff --git a/pkg/commands/config.go b/pkg/commands/config.go index 287c8c9c19..ef68904ae8 100644 --- a/pkg/commands/config.go +++ b/pkg/commands/config.go @@ -38,7 +38,7 @@ import ( ) // getBaseImage returns a function that determines the base image for a given import path. -func getBaseImage(platform string, bo *options.BuildOptions) build.GetBase { +func getBaseImage(bo *options.BuildOptions) build.GetBase { cache := map[string]build.Result{} fetch := func(ctx context.Context, ref name.Reference) (build.Result, error) { // For ko.local, look in the daemon. @@ -61,10 +61,16 @@ func getBaseImage(platform string, bo *options.BuildOptions) build.GetBase { // // Platforms can be comma-separated if we only want a subset of the base // image. - multiplatform := platform == "all" || strings.Contains(platform, ",") - var p v1.Platform - if platform != "" && !multiplatform { - parts := strings.Split(platform, "/") + multiplatform := bo.Platform == "all" || strings.Contains(bo.Platform, ",") + if bo.Platform != "" && !multiplatform { + var p v1.Platform + + parts := strings.Split(bo.Platform, ":") + if len(parts) == 2 { + p.OSVersion = parts[1] + } + + parts = strings.Split(parts[0], "/") if len(parts) > 0 { p.OS = parts[0] } @@ -75,7 +81,7 @@ func getBaseImage(platform string, bo *options.BuildOptions) build.GetBase { p.Variant = parts[2] } if len(parts) > 3 { - return nil, fmt.Errorf("too many slashes in platform spec: %s", platform) + return nil, fmt.Errorf("too many slashes in platform spec: %s", bo.Platform) } ropt = append(ropt, remote.WithPlatform(p)) } diff --git a/pkg/commands/config_test.go b/pkg/commands/config_test.go index b62abfb221..7f7fc5435d 100644 --- a/pkg/commands/config_test.go +++ b/pkg/commands/config_test.go @@ -41,9 +41,10 @@ func TestOverrideDefaultBaseImageUsingBuildOption(t *testing.T) { wantImage := fmt.Sprintf("%s@%s", baseImage, wantDigest) bo := &options.BuildOptions{ BaseImage: wantImage, + Platform: "all", } - baseFn := getBaseImage("all", bo) + baseFn := getBaseImage(bo) _, res, err := baseFn(context.Background(), "ko://example.com/helloworld") if err != nil { t.Fatalf("getBaseImage(): %v", err) diff --git a/pkg/commands/resolver.go b/pkg/commands/resolver.go index a760a44e5c..bca6f9d0bc 100644 --- a/pkg/commands/resolver.go +++ b/pkg/commands/resolver.go @@ -61,20 +61,19 @@ func gobuildOptions(bo *options.BuildOptions) ([]build.Option, error) { return nil, err } - platform := bo.Platform - if platform == "" { - platform = "linux/amd64" + if bo.Platform == "" { + bo.Platform = "linux/amd64" goos, goarch, goarm := os.Getenv("GOOS"), os.Getenv("GOARCH"), os.Getenv("GOARM") // Default to linux/amd64 unless GOOS and GOARCH are set. if goos != "" && goarch != "" { - platform = path.Join(goos, goarch) + bo.Platform = path.Join(goos, goarch) } // Use GOARM for variant if it's set and GOARCH is arm. if strings.Contains(goarch, "arm") && goarm != "" { - platform = path.Join(platform, "v"+goarm) + bo.Platform = path.Join(bo.Platform, "v"+goarm) } } else { // Make sure these are all unset @@ -86,8 +85,8 @@ func gobuildOptions(bo *options.BuildOptions) ([]build.Option, error) { } opts := []build.Option{ - build.WithBaseImages(getBaseImage(platform, bo)), - build.WithPlatforms(platform), + build.WithBaseImages(getBaseImage(bo)), + build.WithPlatforms(bo.Platform), build.WithJobs(bo.ConcurrentBuilds), } if creationTime != nil {