diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 93e9f4b..f926caf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -58,6 +58,7 @@ jobs: [self-hosted, macos, arm64, 13, test], [self-hosted, macos, arm64, 14, test], ] + vm_type: [ "vz", "qemu" ] runs-on: ${{ matrix.os }} steps: - name: Checkout code @@ -95,4 +96,4 @@ jobs: make install.dependencies - name: Run e2e tests shell: zsh {0} - run: make test-e2e + run: FINCH_VM_TYPE=${{ matrix.vm_type }} make test-e2e diff --git a/Makefile b/Makefile index f10c9e2..75b235e 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ all: install.dependencies # Rootfs required for Windows, require full OS for Mac FINCH_IMAGE_LOCATION ?= FINCH_IMAGE_DIGEST ?= +FINCH_VM_TYPE ?= BUILD_OS ?= $(OS) ifeq ($(BUILD_OS), Windows_NT) include Makefile.windows @@ -60,4 +61,4 @@ clean: .PHONY: test-e2e test-e2e: $(LIMA_TEMPLATE_OUTDIR)/fedora.yaml - cd e2e && go test -timeout 30m -v ./... -ginkgo.v + cd e2e && VM_TYPE=$(FINCH_VM_TYPE) go test -timeout 30m -v ./... -ginkgo.v diff --git a/Makefile.darwin b/Makefile.darwin index 89ab8e2..4786657 100644 --- a/Makefile.darwin +++ b/Makefile.darwin @@ -20,6 +20,10 @@ endif FINCH_IMAGE_LOCATION := $(OS_OUTDIR)/$(FINCH_OS_BASENAME) FINCH_IMAGE_DIGEST := "sha512:$(FINCH_OS_DIGEST)" +# Virtualization framework is the default virtual machine type on Finch on macOS +# This is only used for testing of Finch core bundles. +FINCH_VM_TYPE ?= vz + install.dependencies: install.os install.lima-dependencies install.lima-socket-vmnet .PHONY: install.os diff --git a/Makefile.windows b/Makefile.windows index edad438..2b80fa0 100644 --- a/Makefile.windows +++ b/Makefile.windows @@ -13,6 +13,9 @@ else $(error Finch on Windows ARM not supported) endif +# WSL2 is the only virtual machine type supported for Finch on Windows +FINCH_VM_TYPE := wsl2 + WINGIT_TEMP_DIR := $(CURDIR)/wingit-temp WINGIT_x86_URL := $(or $(WINGIT_x86_URL),https://github.com/git-for-windows/git/releases/download/v2.42.0.windows.2/Git-2.42.0.2-64-bit.tar.bz2) WINGIT_x86_BASENAME ?= $(notdir $(WINGIT_x86_URL)) diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 795cac7..02bf70b 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -29,28 +29,38 @@ func TestE2e(t *testing.T) { // Put ./../_output/bin first on path to override other installations of lima and qemu newPath := limaAbsPath + string(os.PathListSeparator) + currentPath err = os.Setenv("PATH", newPath) - if err != nil { t.Fatalf("Error setting PATH: %v", err) } + wd, err := os.Getwd() if err != nil { t.Fatalf("failed to get the current working directory: %v", err) } - subject := "limactl" + vmConfigFile := filepath.Join(wd, "./../_output/lima-template/fedora.yaml") - vmName := "fedora" + + subject := "limactl" limaOpt, err := option.New([]string{subject}) if err != nil { - t.Fatalf("failed to initialize a testing option %v", err) + t.Fatalf("failed to initialize a testing option: %v", err) } - nerdctlOpt, err := option.New([]string{subject, "shell", "fedora", "sudo", "-E", "nerdctl"}) + + vmName := "fedora" + + nerdctlOpt, err := option.New([]string{subject, "shell", vmName, "sudo", "-E", "nerdctl"}) if err != nil { t.Fatalf("failed to initialize a testing option: %v", err) } + vmType := os.Getenv("VM_TYPE") + if vmType == "" { + // Virtualization framework is the default Finch launch type on macOS. + vmType = "vz" + } + ginkgo.SynchronizedBeforeSuite(func() []byte { - command.New(limaOpt, "start", vmConfigFile).WithTimeoutInSeconds(600).Run() + command.New(limaOpt, "start", vmConfigFile, "--name", vmName, "--vm-type", vmType).WithTimeoutInSeconds(600).Run() tests.SetupLocalRegistry(nerdctlOpt) return nil }, func(bytes []byte) {})